Commit Graph

473 Commits

Author SHA1 Message Date
Herman Chen
6d059f65bf [osal]: Change mpp_env string interface
Set get environment string parameter to const char to avoid modification.

Change-Id: Ib5308407fcac2fa58b194fb8df33380efc1487f9
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-08-03 17:44:55 +08:00
Randy Li
6fe240a469 [oasl]: fix the mem debug condition
Change-Id: Id790199e3a32a9ca93bcb382f473aa59c28c0ecc
Signed-off-by: Randy Li <randy.li@rock-chips.com>
2018-07-16 18:03:50 +08:00
Herman Chen
26889a7bce [mpp_time]: Add MppTimer for time recording
Change-Id: I3d04e677415ae84bc37703cb63a52be66c973798
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-07-06 16:30:11 +08:00
Herman Chen
c71ed0cb96 [osal]: Make mpp_time_diff string to const char *
Change-Id: I20f3c65ccbea28bb01e1f739a1d31bf3c5ae936e
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-07-02 17:29:15 +08:00
Herman Chen
91189232df [osal]: Use access to replace file open
When doing ion / drm detection use access is a better idea. For open
will introduce some unnecessary kernel operation. And access is more
flexible to use library on different stage of boot up.

Change-Id: Ib6e98d26cb59dd1c8b0899cfa43911fc25097bd4
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-05-28 16:56:10 +08:00
Herman Chen
bed754e33f [osal]: Use multiple status in MppThread
One thread May have multiple lock/wait/signal source:

Input  : signal source from input.
Output : signal source from output.
Control: signal source from async control operation.

Then the main working loop may stop on these lock/wait/signal points.

Change-Id: Ia6270b865cfb7087567fc21f07feb9248b929d7a
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-05-28 09:48:35 +08:00
Herman Chen
2098ea9de1 [Thread]: Rename thread lock / signal type
Rename thread lock / signal type by its source.

Change-Id: I426cb9490dd05183badffa36f0a861c439c5f23b
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-05-14 14:49:59 +08:00
Herman Chen
e855cb171a [misc]: Fix some minor issues
1. Fix rga.cpp compile error on Linux.
2. Fix mpp_runtime.cpp warning on Linux.
3. Remove print when fail to dlopen vpuapi library.

Change-Id: I3891bdd39ae77bac68a67a39893d8caa31dbe6fb
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-05-09 16:23:09 +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
fb73f23f53 [alloctor]: add flags for alloctor
Each of the different alloctor has different alloctor modes,
such as allocating physical continuous memory, secure memory,
etc.

Change-Id: Ib032689f0cfd36b494843dcc176a22c6c9587b6a
Signed-off-by: Rimon Xu <rimon.xu@rock-chips.com>
2018-05-07 17:34:34 +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
Randy Li
a78598dab5 [osal]: add new buffer type for DMA import buffer
This buffer type is used for the buffer coming from the
application, the application should make sure those
buffers are the dma buffer.

Change-Id: I2c8491f4dea77e5d7ae8d9157b0a1eda204f4bd6
Signed-off-by: Randy Li <randy.li@rock-chips.com>
2018-04-27 17:20:32 +08:00
Randy Li
86c5f925cd [alloactor]: fix some minior errors
1. fix the header protection
2. the incorrect offset in ion memory mapping
3. the commentment of the buffer type in a header file

Change-Id: If9d1db90d41131750a341ab6177f947f7b966317
Signed-off-by: Randy Li <randy.li@rock-chips.com>
2018-04-27 17:20:32 +08:00
Herman Chen
e4d6d81287 [mpp_mem]: Add error log for mpp mem debug
When mpp_mem debug is enabled there is limit for recording mpp_mem
usage. But there is NO obvious log when this limit is reached.

This case will easily happen on multi-instance decoding in one process.
We add obvious log when this case happen.

Change-Id: Ic9160766d4499d442c25fdefae00231d15d71359
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-03-26 15:41:29 +08:00
Herman Chen
a00b980a71 [mpp_mem]: Fix print error on mpp_mem leak check
Change-Id: I97d7c34034084aed4dfda064b113386d6dede8a8
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-03-26 10:22:06 +08:00
Xingwen Fang
702ccb4a9d [osal]: Reject multiple call mpp queue flush
Change-Id: I31622b38c93e86113ed9a4189d82acadc140e834
Signed-off-by: Xingwen Fang <fxw@rock-chips.com>
2018-03-23 17:34:53 +08:00
Herman Chen
ed4151e245 [osal]: Change time function
Change time function from gettimeofday to clock_gettime.
Output of mpp_time() is still in us.

Change-Id: I7f961bb7bb4007e8e42ae5358bd7f568edf6c3d0
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-03-23 09:20:56 +08:00
Chengmc
e648d65af8 [allocator] lock ion heap detection operation
When in multi-codecs cases, the check_sysfs_iommu function reenters
with high probability, so some codec instances may fail to obtain
the correct memory type.

The root cause is scandir call in find_dir_in_path function. For
efficiency consideration it is better to lock ion_heap_id value.

Change-Id: I60a0eb27c3ac35bc022aa00b2cffc4e26e54bf24
Signed-off-by: Chengmc <Martin.Cheng@rock-chips.com>
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-03-22 17:00:49 +08:00
Herman Chen
82bc016bbb [oasl]: Add debug function to mpp_mem
1. Add memory node record.
2. Add runtime log with memory count and total size.
3. Add extra room for overflow detection.
4. Add memory poison after free to detect write after free.

Change-Id: I4f0fe7295f18a746c3b4c135681127a18337585e
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-01-29 11:47:31 +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
Herman Chen
7b7b509847 [runtime]: Add more runtime detection
As we found that simple ion / drm device detectioin can not cover all the
case. For example on some 3368 platform kernel provide both ion and drm
device. We have better to use allocator chosen in dts.

But later kernel patch from Randy will bring unified dma-fd translation in
kernel then this detection will be removed.

Change-Id: I2746142d1c3d0f36791bacaadb231dc2001a5aa7
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-01-03 16:48:56 +08:00
Herman Chen
321b95ad4d [allocator]: Use auto detect on Android and Linux
There is case that Android 7.1+3.10 kernel without drm and also
Android 7.1+4.4 kernel with both drm and ion.
Use the runtime function to support both of them.

This patch needs more test.

Change-Id: I53f0a30abf057f8e0e6e122e09782896d4789168
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2017-12-18 15:15:07 +08:00
Herman Chen
7d29f32280 [osal]: Add runtime allocator detection function
Due to complexity of different kernel and usespace combination
we have to detect drm and ion allocator on runtime. The HAVE_DRM
flag may not be trust at all time. So we add a simple detection
function on first run.

Change-Id: Id4f6b2278ee0fe50ffc9806fffc5b01267f723da
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2017-12-18 15:15:07 +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
Randy Li
50bdc4de6a [mpp]: turn off a lots of message
I think those information are very anxious and useless
in daily usage.

Change-Id: I946418a476a332588b1d9b9722bbd5e93213e8dc
Signed-off-by: Randy Li <randy.li@rock-chips.com>
2017-11-30 11:32:17 +08:00
Randy Li
c157afe9db [mpp_list]: release the blocked thread at reset
The applcatiion thread is still blocking on the output port.

Change-Id: I4693125362a250e5d2f28af8226d608b3040f138
Signed-off-by: Randy Li <randy.li@rock-chips.com>
2017-11-20 14:34:44 +08:00
Randy Li
6e471a0d14 [osal]: add queue data type
Only the src port supports blocking operation. Please
notice the sink port is neither block nor atomic.

Change-Id: Ib710eaca9fe1b5d5aada8e56481102589b52fc52
Signed-off-by: Randy Li <randy.li@rock-chips.com>
2017-11-20 11:54:58 +08:00
sliver.chen
5a830697a8 [osal]: force mpp use drm buffer when HAVE_DRM are defined.
Force allocator use drm buffer,otherwise user will get a tuntime error
when they use kernel without /dev/ion.

Change-Id: I8151b743a9b19a03716dec3bdb909ce91b6af0b6
Signed-off-by: sliver.chen <sliver.chen@rock-chips.com>
2017-11-08 17:13:36 +08:00
Randy Li
c56a9365f6 [ion]: file descriptor for the external buffer
The imported buffer may be released from its origin allocator,
I would suggest to use the new file descriptor from new ion
handle.

The ion only has map_user() to export buffer to userspace,
There is no unmap_user() because the mapping is represented as
a file descriptor in user space. The closing of that file
descriptor will cause the memory to be unmapped from
the calling process.

Change-Id: Ief855aab11793238b40b73da92af853ca3b58349
Signed-off-by: Randy Li <randy.li@rock-chips.com>
Signed-off-by: ayaka <ayaka@soulik.info>
2017-11-02 17:55:23 +08:00
Herman Chen
ba4b1db7ce [ioctl]: Add compatible patch for different kernel
New kernel use u32 as a fix length ioctl parameter then mpp should keep
compatible to all kernel driver case.

Change-Id: I73afe00971d7b73d6c4695254bc5fdf82422b1f5
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2017-11-01 17:23:13 +08:00
Randy Li
e0a1d6579d [drm]: use mmap() in native way for GNU Linux target
The "[drm]: fix runtime error for 32bit library" is hack way,
it won't work at GNU Linux platform. Also you need to check
_FILE_OFFSET_BITS and _LARGEFILE64_SOURCE before use the
mmap64().

For the normal mmap() with glibc, we only request to
check offset is aligned with page size but not the lenght.
But that doesn't apply for the memory from the drm device,
also the android use a different rule.

I decide not to map all the buffer to cpu at beginning
since most of them won't be access by the cpu.

Change-Id: I74ac7b5b63d45029cae076985a3d0b4526c62bbc
Signed-off-by: Randy Li <randy.li@rock-chips.com>
2017-10-27 10:06:20 +08:00
Randy Li
8083d5ca60 [drm]: fix a various of bugs in drm allocator
1. The wrong size information;
2. Release the drm buffer when the life of the buffer is ended.

Change-Id: I8a17bf807609dfa940545f2391a62bd0a4f51670
Signed-off-by: Randy Li <randy.li@rock-chips.com>
2017-10-27 10:05:55 +08:00
Randy Li
f49475dfc3 [osal]: fixup for build in linux
Change-Id: I9535c66997f299c9d37f5b3c12b1b73fff5997d6
Signed-off-by: Randy Li <randy.li@rock-chips.com>
2017-09-13 10:05:14 +08:00
Randy Li
e6ade9b712 [mpp_dec]: remove obsoleted code and format comments
It would be more easy to look into those code next time.

The functions in mpp_time.c have removed the internal debug
flag checking.

Change-Id: I6392190896f74e86a8407f06fa3621dd92371e56
Signed-off-by: Randy Li <randy.li@rock-chips.com>
2017-08-03 16:21:13 +08:00
Randy Li
5504570c3d Revert "[osal]: linux: add -ldl -lct to link relative library"
This reverts commit 8d42511773.

It will cause a problem in the platform skipping those library.
since those libraries are not necessary for any platform,
I think don't link with them would be better.

Change-Id: I33f48750f70838e393c02eb55971d5ebe0d3df31
Signed-off-by: Randy Li <randy.li@rock-chips.com>
2017-07-25 17:13:32 +08:00
Randy Li
0aa2191f26 [allocator]: force using drm allocator in Linux platform
The buffer management system still have a problem with different
memory type, I have to fake the drm buffer as the ion buffer this
time.

Change-Id: I57d972d45419caeaf0f086372d1ecd0c8dd9b9f5
Signed-off-by: Randy Li <randy.li@rock-chips.com>
Signed-off-by: leo.ding <leo.ding@rock-chips.com>
2017-07-11 11:49:28 +08:00
Herman Chen
75660ca37b [oasl]: Add lock timing test
Add pthread lock / unlock and condition wait / signal performance test

Change-Id: Ia0b9ae968d3bbe0b8f802b36afb93c6b564d91dc
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2017-07-05 11:27:22 +08:00
leo.ding
8d42511773 [osal]: linux: add -ldl -lct to link relative library
Change-Id: I4058c948a93f6e615843bcafd31bbf8568305b0c
Signed-off-by: leo.ding <leo.ding@rock-chips.com>
2017-07-04 19:27:26 +08:00
Herman Chen
2c3c72a815 [osal]: Change mpp time print to us
Change-Id: Ifd73aad1e3b65b44a8d7e284647c065fde66ca98
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2017-06-27 09:44:40 +08:00
Randy Li
19c0237886 [ion]: file descriptor for the external buffer
The imported buffer may be released from its origin allocator,
I would suggest to use the new file descriptor from new ion
handle.

NOTE: User may use file descriptor outside mpp as buffer index.
If mpp chooses new map fd as its output user may lost the
connection between user external buffer and mpp output buffer.

Change-Id: Ie0f42cd3268dfd08ddcbd5148a68406ff4b66b7a
Signed-off-by: Randy Li <randy.li@rock-chips.com>
Signed-off-by: ayaka <ayaka@soulik.info>
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2017-06-14 11:38:32 +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
Randy Li
7990b52e8d [osal]: update the build system
The cross toolchains in Linux distributions are more prefer to
auto conf way, move those detecting from build system to toolchain
itself would be more welcome.

Change-Id: Ib42d9a0c65646b679ed14c96d16d1845c596f741
Signed-off-by: Randy Li <randy.li@rock-chips.com>
2017-06-06 08:38:31 +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
5fa4ff0d48 [osal]: match system implementation with compiler marco
It would make the build system more simple, and the cross
toolchains would do the rest to you.

Toolchains like buildroot default not enable the __gnu_linux__
marco in the pre-processor will surfure from the systsm unknown
problem. You should enable the marco in building toolchains
or have a look on those scripts in build directory.

Change-Id: I8f6af3391aa3d94d602ec8d84ba5e43839859169
Signed-off-by: Randy Li <randy.li@rock-chips.com>
2017-05-04 14:29:29 +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
ayaka
8bde251d54 [osal]: fix the timeout function
Please notice that clock source is only confirm to work
on the currently Rockchip ARMv7/ARMv8 SoC.
You may meet problem with the other platform.

The time granularities is miliseconds level.

Change-Id: Icf56f88dd15045d7c899bdcfaf3637fab159b35a
Signed-off-by: ayaka <ayaka@soulik.info>
Signed-off-by: Randy Li <randy.li@rock-chips.com>
Reviewed-by: timkingh.huang <timkingh.huang@rock-chips.com>
2017-04-14 11:25:58 +08:00
Randy Li
0de5e0599c [osal]: don't install unit test
The build system may store those files into a package.

Change-Id: I2ab54da5880d1979a19430520d36324629b8a7d8
Signed-off-by: Randy Li <randy.li@rock-chips.com>
2017-04-07 10:13:44 +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