Commit Graph

36 Commits

Author SHA1 Message Date
Johnson Ding
45f2fcbcf0 fix[osal]: rv1109/rv1126 vcodec_type mismatch problem
RV1126/RV1109 JPEG decoder has no PP. This will be conflict with
vcodec_type queried from kernel. Also VPU_CLIENT_VEPU2_JPEG is defined
and used only for multi-core JPEG encoder at kernel. So the following
changes is made to fix this problem:

1. This reverts commit 9b860cd250.
2. Define a new MppDecHwCap to distinguish normal VPU with only JPEG
   supported from multi-core JPEG encoder.
3. Correct vcodec_type queried from kernel when there is no PP for
   VDPU2.

Change-Id: I58a1abe708721f725a9cf487e8f870dd5820844f
Signed-off-by: Johnson Ding <johnson.ding@rock-chips.com>
2024-06-06 18:07:06 +08:00
Yandong Lin
24fea09634 [mpp_platform]: fix get_kernel_version failed on 5.10
Signed-off-by: Yandong Lin <yandong.lin@rock-chips.com>
Change-Id: I51fe2311641b4a7a64595e8fc8b4813c6a962303
2022-09-06 18:04:03 +08:00
Yandong Lin
def09cb3c2 [jpege]: add new client type for vepu2 jpeg only
Add VPU_CLIENT_VEPU2_JPEG to distinguish vepu2 jpege only device.
And check whether kernel support the client type or not.

rk3588 has 4 jpeg encoder core and we will use VPU_CLIENT_VEPU2_JPEG as
its client type in kernel.

Signed-off-by: Yandong Lin <yandong.lin@rock-chips.com>
Change-Id: Ib1c45781ac9c8f504ba7b46f2f0c7aad5d16fa68
2022-07-01 16:43:19 +08:00
Herman Chen
2b35cee0ce [mpp_log]: Add more log helper function
1. Move mpp_log.h to inc for external user.
2. Add mpp_debug.h for mpp internal logging.
3. Fix some warning.
4. Add log level setup function.
5. Check env log_level value in mpp_get_log_level call.

NOTE:
1. mpp internal module should use mpp_debug.h and mpp external user
should use mpp_log.h
2. Use mpp_get_log_level to update mpp_log_level when the env changed.

Change-Id: I90a55a02a72db177533013280dfe111ca3479229
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2022-05-20 11:42:10 +08:00
Herman Chen
4ecb7de25c [mpp_platform]: Add kernel version detection
Change-Id: Id2110213daeaca606bafe288a6d4cd970c112d4f
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2021-02-02 20:21:29 +08:00
Herman Chen
c106a5bdd0 [mpp_soc]: Add mpp_soc with more detail feature
1. Add soc definition structure to replace old one.
2. Use mpp_soc.h to replace soc detection in mpp_platform.h.
3. Add vcodec_type to each device definition.
4. Add check on soc info init.

Change-Id: Iecc44bd79e6fd09c58afbc1b5c526ecf31acc663
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2020-12-08 19:42:53 +08:00
Herman Chen
2f2e4224b9 [mpp_platform]: Move codec_type detection
1. Move codec_type detection code to vcodec_service.
   Only vcodec_service needs to detect vcodec_type. Mpp_service will
   report this flag from kernel.

2. Remove kernel device detection code when soc type not detected.

3. Add mpp_soc.h for soc definition.

Change-Id: Ic83897bddbcf0fceb0c5d19a05491f75231092c1
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2020-11-25 15:11:28 +08:00
Herman Chen
5967c22284 [mpp_platform]: Add rk3566/rk3568 SOC definition
Change-Id: Ia1972cb95d5497cf95daab46504cfea9522b79e7
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2020-11-10 14:19:41 +08:00
Herman Chen
44443dd7ee [mpp_device]: Add new mpp_device for kernel driver
1. Change mpp_device into a new layer for kernel drvier.
2. Separate mpp_service driver and vcodec_service driver.
3. Add mpp_service.c for /dev/mpp_service driver support.
4. Add global mpp_service info query interface.
5. Remove unused function in mpp_device.c

Change-Id: I3f53bba3aef525ad3b1f450bb55830d1eeaf29a6
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2020-11-03 16:09:19 +08:00
Herman Chen
2e0b487683 [mpp_platform]: Detection code cleanup
Change-Id: I7c1d850b8fd9a2bbfcd870e0be27f381ed88421a
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2020-10-30 17:10:44 +08:00
Herman Chen
b845d7740d [mpp_device]: Fix cmd_butt check error
Change-Id: I247bb3573812903c6bc478cdad17c9e21f515104
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2020-10-28 15:41:41 +08:00
Shunqian Zheng
9464af395b [misc]: Terminate soc_name to fix out of bounds
1. Terminate soc_name string to fix memory out of bounds
2. Fix all snprintf/strnlen warning

Change-Id: I4525c6e289a00d1509bc30ee69545d92f2f4b9cb
Signed-off-by: Shunqian Zheng <zhengsq@rock-chips.com>
2020-04-29 16:06:47 +08:00
Johnson Ding
14cae9c4ca [mpp_platform]: fix wrong device getting problem
For vepu2 on kernel-4.4, the device name should be "/dev/vepu" not
"/dev/vpu_service". This happens on RK3328.

Ref issue:
1. https://github.com/rockchip-linux/mpp/issues/125
2. https://github.com/HermanChen/mpp/issues/11

Change-Id: I830f6c5d4d45effb6faeeb3bbf4c2b5589b92d46
Signed-off-by: Johnson Ding <johnson.ding@rock-chips.com>
2020-03-02 10:34:43 +08:00
Herman Chen
e04f0e83e7 [mpp_platform]: Improve ioctl version detection
Move kernel ioctl api version detection to library loading stage.

Change-Id: If8ee750e1eaefb99924fd622d03270ef5032d1be
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2020-02-25 09:35:00 +08:00
Ding Wei
c5a9228e4b [mpp_platform]: Add RV1109 and RV1126 detection
Change-Id: I7281f4284891cf3ba9ebf24a2ff025827d4a0a2b
Signed-off-by: Ding Wei <leo.ding@rock-chips.com>
2020-02-20 11:33:25 +08:00
Ding Wei
7d05e33de8 [mpp]: add /dev/mpp_service support
Add a new ioctl mode for kernel-4.19 or later.
Tips:
    1. There will be only one device /dev/mpp_service in kernel.
       User should use client type to distinguish different device.
    2. Each codec use the same function as before.
    3. Ioctl magic changes from VPU_IOC to MPP_IOC.
    4. Update structure for ioctl argument.
	Original structure:
	    data_ptr | size
	In this mode has many sortcommings:
	a) Need many ioctl cmd for different requirements.
	b) Data_ptr not to differ library for 32 or 64 system.
	c) Contain only one info ioctl once.

    New data structure:
        cmd_type | flags | size | offset | data_ptr
    a) Cmd_type works like previous ioctl cmd.
    b) Flags is extend to mark current data for any purpose.
    c) Size is the same as before.
    d) Data_ptr use 32 bits build in 32 system while 64 bits in 64 system.

kernel-4.19 related commit:
ib94ac0df876dfcc786b25ed3de6a68d861d2ef1e
cda9d27c62017309519bcbf8fe91057dfdc21076

Change-Id: I13d54a2e4823b7378265f100540916a22f62b9d4
Signed-off-by: Ding Wei <leo.ding@rock-chips.com>
2019-12-10 20:12:50 +08:00
Herman Chen
47011cd647 [platform]: Add RK1808 support
Change-Id: Id8d1bdd61888cc0fedb324f9c63be184edf3e6d0
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-09-29 15:48:48 +08:00
Herman Chen
67e80ebfe4 [mpp]: Remove RKPLATFORM macro
Mpp will only run under Linux environment. Windows support will be
removed.

Change-Id: I52de4bd69f6d7b34507edeb6642668e225fcbd38
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-09-11 10:31:08 +08:00
Herman Chen
b03cad1c4f [platform]: Add 3128H capability description
rk3128H can support 1080p@60fps H.264/H.265 decoding. While it
do NOT have jpeg encoder nor VP9 decoder.

Change-Id: Id1b9583831036e2a43361b11f963be3599bfa7f8
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-09-05 10:23:05 +08:00
Yann Dirson
621dd8592f Fix buffer overflow scanning soc_name.
The soc_name we read from device-tree is NUL-separated so we need to
replace intervening NUL chars, but we don't want to replace the last
one, or the next call to strstr() will overflow the buffer.

Detected with address-sanitizer:

    ==3271==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f940026a0 at pc 0x7f97df7160 bp 0x7fee1fa8e0 sp 0x7fee1fa958
    READ of size 97 at 0x7f940026a0 thread T0
        #0 0x7f97df715f  (/usr/lib/libasan.so.3+0x4215f)
        #1 0x7f97df745b in __interceptor_strstr (/usr/lib/libasan.so.3+0x4245b)
        #2 0x7f97d6b27b in MppPlatformService::MppPlatformService() (/usr/lib/librockchip_mpp.so.1+0x8727b)
        #3 0x7f97d6b64f in mpp_get_vcodec_type (/usr/lib/librockchip_mpp.so.1+0x8764f)
        #4 0x7f97d38da3 in hal_h264d_init (/usr/lib/librockchip_mpp.so.1+0x54da3)

    0x7f940026a0 is located 0 bytes to the right of 96-byte region [0x7f94002640,0x7f940026a0)
    allocated by thread T0 here:
        #0 0x7f97e6445b in __interceptor_posix_memalign (/usr/lib/libasan.so.3+0xaf45b)
        #1 0x7f97d6ed13 in os_malloc (/usr/lib/librockchip_mpp.so.1+0x8ad13)
        #2 0x7f97d6e54b in mpp_osal_malloc (/usr/lib/librockchip_mpp.so.1+0x8a54b)
        #3 0x7f97d6b1d7 in MppPlatformService::MppPlatformService() (/usr/lib/librockchip_mpp.so.1+0x871d7)
        #4 0x7f97d6b64f in mpp_get_vcodec_type (/usr/lib/librockchip_mpp.so.1+0x8764f)
        #5 0x7f97d38da3 in hal_h264d_init (/usr/lib/librockchip_mpp.so.1+0x54da3)
        #6 0x7f97d387c7 in mpp_hal_init (/usr/lib/librockchip_mpp.so.1+0x547c7)
        #7 0x7f97d02ad3 in mpp_dec_init (/usr/lib/librockchip_mpp.so.1+0x1ead3)
        #8 0x7f97cfda3f in Mpp::init(MppCtxType, MppCodingType) (/usr/lib/librockchip_mpp.so.1+0x19a3f)
        #9 0x7f97d0056f in mpp_init (/usr/lib/librockchip_mpp.so.1+0x1c56f)
        #10 0x404347 in mpi_dec_test_decode (/home/root/rockchip-mpp-test/mpi_dec_test+0x404347)
        #11 0x4057b3 in main (/home/root/rockchip-mpp-test/mpi_dec_test+0x4057b3)
        #12 0x7f97bba563 in __libc_start_main (/lib/libc.so.6+0x1f563)
        #13 0x402217  (/home/root/rockchip-mpp-test/mpi_dec_test+0x402217)

    SUMMARY: AddressSanitizer: heap-buffer-overflow (/usr/lib/libasan.so.3+0x4215f)
    Shadow bytes around the buggy address:
      0x1ff2800480: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      0x1ff2800490: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      0x1ff28004a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      0x1ff28004b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      0x1ff28004c0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
    =>0x1ff28004d0: 00 00 00 00[fa]fa fa fa fa fa fa fa 00 00 00 00
      0x1ff28004e0: 00 00 00 00 00 00 00 00 fa fa fa fa fa fa fa fa
      0x1ff28004f0: 00 00 00 00 00 00 00 00 00 00 00 00 fa fa fa fa
      0x1ff2800500: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      0x1ff2800510: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      0x1ff2800520: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
    Shadow byte legend (one shadow byte represents 8 application bytes):
      Addressable:           00
      Partially addressable: 01 02 03 04 05 06 07
      Heap left redzone:       fa

Change-Id: Ia529035847cc23c612e4039e3d445db9d014d31f
Signed-off-by: Yann Dirson <yann@blade-group.com>
2018-09-05 09:02:22 +08:00
Herman Chen
c87119b698 [platform]: Update some SOC's codec support
rk3228 do NOT have jpeg encoder and rk3036 do NOT have all encoder. we
update the device name in mpp_get_vcodec_dev_name function.

Change-Id: If80d864543761572645928e59e1e09fc906fec31
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-05-09 15:50:57 +08:00
Rimon Xu
ed620a310b [mpp_device]: move dev_fd in mppDevCtx
In order to separate the hardware and decoding protocols
more clearly, all API must be implemented in context.

Change-Id: I9f8128c5399149699b2e0a03bfa72ff902c25b87
Signed-off-by: Rimon Xu <rimon.xu@rock-chips.com>
Signed-off-by: Ding Wei <leo.ding@rock-chips.com>
2018-05-03 16:52:41 +08:00
james.lin
bbc3cfe7a9 [mpp_platform]: add rk3128h support
Change-Id: I9d14872ab1537f9aa23c747f4b3319a284c88c81
Signed-off-by: james.lin <james.lin@rock-chips.com>
2018-05-03 16:02:53 +08:00
Ding Wei
0a87e905a2 [mpp_platform]: add px30 && rk3326 support
Change-Id: If4f69842c9468faee3d6f598e2e2453cb9d8511c
Signed-off-by: Ding Wei <leo.ding@rock-chips.com>
2018-01-24 14:14:18 +08:00
Randy Li
97907dc549 [osal]: add rk3036 platform
Change-Id: I82029e8345d3c8e2a9a3baf4be55b7f4c9b284f0
Signed-off-by: Randy Li <randy.li@rock-chips.com>
2017-12-01 14:07:53 +08:00
leo.ding
b7cbd8a9c0 [mpp_device]: add MppDevCtx for control device status
1. add Mppdevctx to store some infos in every codec.
reason:each codec has its own unique characteristics.
2. add mpp_device_control interface for get or set ctx values.
reason:it simplity interface, which flexible, easy to use and versatile.

Change-Id: I56c9332768c86f62a3ca248ad254fba9e798c577
Signed-off-by: leo.ding <leo.ding@rock-chips.com>
2017-06-07 15:14:30 +08:00
leo.ding
8cd076afae [mpp_platform]: rename HAVE_265E to HAVE_265ENC for buid warnnig
H265E had defined in Cmakelist.txt to choose whether build
h265 encode module, so it here is redefined.

Change-Id: I54e9704d396d0a8a0e6d0f2ae8595d033131d81b
Signed-off-by: leo.ding <leo.ding@rock-chips.com>
2017-05-15 17:28:16 +08:00
Randy Li
1b0d5bc016 [platform]: fixup for reading compatible
Change-Id: Ia0ff40644daaaec90a32d173675fadca7327d79b
Reported-by: Jacob Chen <jacob2.chen@rock-chips.com>
Signed-off-by: Randy Li <randy.li@rock-chips.com>
2017-04-27 15:49:32 +08:00
leo.ding
4a1e6c3671 [platform]: Add default case for known compatible
Change-Id: Icaaa6b72a395248f53a8f902fa8d62e48bcd351f
Signed-off-by: leo.ding <leo.ding@rock-chips.com>
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2017-04-06 16:26:35 +08:00
Randy Li
d99cc7f2ff [osal]: fixup for reading system compatible
The kernel uses termination character to divisive compatible.

Change-Id: I5db14e22aefa1ea54b8d32a4af7b112f22358dfb
Signed-off-by: Randy Li <randy.li@rock-chips.com>
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
Signed-off-by: leo.ding <leo.ding@rock-chips.com>
2017-04-06 14:40:23 +08:00
Herman Chen
8900385917 [platform]: Update chipset name and feature case
3228/3229 3228H/3328 support feature list:
3228 : dec vpu2 + 4K H.264/H.265       + enc vpu2
3229 : dec vpu2 + 4K H.264/H.265/VP9   + enc vpu2
3228H: dec vpu2 + 4K H.264/H.265 + avs + enc vpu2 + H.265
3328 : dec vpu2 + 4K H.264/H.265/VP9   + enc vpu2 + H.265

Change-Id: Ia4f63e764f12f8117757ea05645ffb9b65dc6b12
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2017-04-05 14:42:58 +08:00
Herman Chen
4b41fdd8bc [mpp_platform]: Modify chip vcodec detection
1. Add video codec information and kernel driver device detection code for all
supported chips.
2. Add video codec type and device name detection test

Change-Id: I275c0e616acd80c9a4ad2fee00588479e47a92db
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2017-03-03 16:12:36 +08:00
Herman Chen
51a7f82285 [osal]: Fix compiling error on Linux
Change-Id: Ia8daa63718fd8912093e5197fcfe823e378d1972
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2017-01-06 16:41:53 +08:00
leo.ding
b0902117fc [osal]: Add hardware platform detection
Change-Id: I0223b79608a9ea8346dbf194805c2536a90beb3b
Signed-off-by: leo.ding <leo.ding@rock-chips.com>
2017-01-06 09:06:54 +08:00
Herman Chen
e2ba112070 [osal]: Fix compile error on windows
Change-Id: Id908c592aaee3b8f16f7529c8c3995b3f4af78f8
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2016-12-16 11:22:31 +08:00
Herman Chen
2fc024529e [osal]: add environment detection function
1. add software runtime detection
2. add hardware platform detection

Change-Id: I75736ae85130325029023d948e4d756e27953af8
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2016-11-08 18:22:29 +08:00