Multi Format Codec 5.1 driver for S5PC110 SoC
Subsystems (4)
v6 cover Multi Format Codec 5.1 driver for S5PC110 SoC
Hello,
This is the sixth version of the MFC 5.1 driver, decoding part. The suggestions and comments from the group members have been very helpful.
I would be grateful for your comments. Original cover letter ant detailed change log has been attached below.
Best regards,
Kamil Debski
* Changelog:
==================
Changes since v5
==================
1) Changes suggested by Hans Verkuil:
- small change in videodev2.h - corrected control offsets
- made the code more readable by simplifying if statements and using temporary pointers
- mfc_mutex is now included in s5p_mfc_dev structure
- after discussion with Peter Oh modification of fourcc defintions (replaced DX52 and DX53 with DX50)
2) Changes suggested by JongHun Han:
- comsmetic changed of defines in regs-mfc5.h
- in buffers that have no width adn height, such as the buffer for compressed stream, those values are set to 0 instead of 1
- remove redundant pointer to MFC registers
- change name of the union in s5p_mfc_buf from paddr to cookie
- removed global variable (struct s5p_mfc_dev *dev) and moved to use video_drvdata
3) Other changes:
- added check for values returned after parsing header - in rare circumstances MFC hw returned 0x0 as image size and this could cause problems
==================
Changes since v4
==================
1) Changes suggested by Kukjin Kim from:
- removed comment arch/arm/mach-s5pv210/include/mach/map.h
- changed device name to s5p-mfc (removed "5", MFC version number) also removed the version number from the name of MFC device file
- added GPL license to arch/arm/plat-s5p/dev-mfc.c
- removed unused include file from dev-mfc.c and unnecessary comments
2) Cache handling improvement:
- changed cache handling to use dma_map_single and dma_unmap_single
==================
Changes since v3
==================
1) Update to the v6 videobuf2 API (here thanks go to Marek Szyprowski)
- s5p_mfc_buf_negotiate and s5p_mfc_buf_setup_plane functions have been merged
- queue initialization has been adapted to the new API
- use of the allocator memops has been changed, now there are single memops for all the allocator contexts
2) Split of the s5p_mfc_try_run and s5p_mfc_handle_frame_int functions
- parts of the s5p_mfc_try_run function have been moved to separate functions (s5p_mfc_get_new_ctx, s5p_mfc_run_dec_last_frames, s5p_mfc_run_dec_frame, s5p_mfc_run_get_inst_no, s5p_mfc_run_return_inst s5p_mfc_run_init_dec,s5p_mfc_run_init_dec_buffers)
- s5p_mfc_handle_frame_int has been split to the following functions:s5p_mfc_handle_frame_all_extracted, s5p_mfc_handle_frame_new and s5p_mfc_handle_frame to handle different cases
3) Remove remaining magic numbers and tidy up comments
==================
Changes since v2
==================
1) Update to newest videobuf2 API
This is the major change from v2. The videobuf2 API will hopefully have no more major API changes. Buffer initialization has been moved from buf_prepare callback to buf_init to simplify the process. Locking mechanism has been modified to the requirements of new videobuf2 version.
2) Code cleanup
Removed more magic contants and replaced them with appropriate defines. Changed code to use unlocked_ioctl instead of ioctl in v4l2 file ops.
3) Allocators
All internal buffer allocations are done using the selected vb2 allocator, instead of using CMA functions directly.
==================
Changes since v1
==================
1) Cleanup accoridng to Peter Oh suggestions on the mailing list (Thanks).
* Original cover letter:
==============
Introduction
==============
The purpose of this RFC is to discuss the driver for a hw video codec embedded in the new Samusng's SoCs. Multi Format Codec 5.0 is able to handle video decoding of in a range of formats.
So far no hardware codec was supported in V4L2 and this would be the first one. I guess there are more similar device that would benefit from a V4L2 unified interface. I suggest a separate control class for codec devices - V4L2_CTRL_CLASS_CODEC.
Internally the driver uses videobuf2 framework and CMA memory allocator. I am aware that those have not yet been merged, but I wanted to start discussion about the driver earlier so it could be merged sooner. The driver posted here is the initial version, so I suppose it will require more work.
==================
Device interface
==================
The driver principle is based on the idea of memory-to-memory devices:
it provides a single video node and each opened file handle gets its own private context with separate buffer queues. Each context consist of 2 buffer queues: OUTPUT (for source buffers, i.e. encoded video frames) and CAPTURE (for destination buffers, i.e. decoded raw video frames). The process of decoding video data from stream is a bit more complicated than typical memory-to-memory processing, that's why the m2m framework is not directly used (it is too limited for this case). The main reason for this is the fact that the CAPTURE buffers can be dequeued in a different order than they queued. The hw block decides which buffer has been completely processed. This is due to the structure of most compressed video streams - use of B frames causes that decoding and display order may be different.
==============================
Decoding initialization path
==============================
First the OUTPUT queue is initialized. With S_FMT the application chooses which video format to decode and what size should be the input buffer. Fourcc values have been defined for different codecs e.g. V4L2_PIX_FMT_H264 for h264. Then the OUTPUT buffers are requested and mmaped. The stream header frame is loaded into the first buffer, queued and streaming is enabled. At this point the hardware is able to start processing the stream header and afterwards it will have information about the video dimensions and the size of the buffers with raw video data.
The next step is setting up the CAPTURE queue and buffers. The width, height, buffer size and minimum number of buffers can be read with G_FMT call. The application can request more output buffer if necessary. After requesting and mmaping buffers the device is ready to decode video stream.
The stream frames (ES frames) are written to the OUTPUT buffers, and decoded video frames can be read from the CAPTURE buffers. When no more source frames are present a single buffer with bytesused set to 0 should be queued. This will inform the driver that processing should be finished and it can dequeue all video frames that are still left. The number of such frames is dependent on the stream and its internal structure (how many frames had to be kept as reference frames for decoding, etc).
===============
Usage summary
===============
This is a step by step summary of the video decoding (from user application point of view, with 2 treads and blocking api):
01. S_FMT(OUTPUT, V4L2_PIX_FMT_H264, ...)
02. REQ_BUFS(OUTPUT, n)
03. for i=1..n MMAP(OUTPUT, i)
04. put stream header to buffer #1
05. QBUF(OUTPUT, #1)
06. STREAM_ON(OUTPUT)
07. G_FMT(CAPTURE)
08. REQ_BUFS(CAPTURE, m)
09. for j=1..m MMAP(CAPTURE, j)
10. for j=1..m QBUF(CAPTURE, #j)
11. STREAM_ON(CAPTURE)
display thread:
12. DQBUF(CAPTURE) -> got decoded video data in buffer #j
13. display buffer #j
14. QBUF(CAPTURE, #j)
15. goto 12
parser thread:
16. put next ES frame to buffer #i
17. QBUF(OUTPUT, #i)
18. DQBUF(OUTPUT) -> get next empty buffer #i 19. goto 16
...
Similar usage sequence can be achieved with single threaded application and non-blocking api with poll() call.
Branch with MFC, CMA and videobuf2 will be soon available at
http://git.infradead.org/users/kmpark/linux-2.6-samsung/shortlog/refs/heads/vb2-mfc-fimc
This tree is based on 2.6.37 rc4.
Please have a look at the code and the idea of how to introduce codec devices to V4L2. Comments will be very much appreciated.
Patch summary:
Subject: [PATCH 0/4] *** SUBJECT HERE ***
*** BLURB HERE ***
Kamil Debski (4):
Changes in include/linux/videodev2.h for MFC
MFC: Add MFC 5.1 driver to plat-s5p and mach-s5pv210
MFC: Add MFC 5.1 V4L2 driver
s5pv210: Enable MFC on Goni
arch/arm/mach-s5pv210/Kconfig | 1 + arch/arm/mach-s5pv210/clock.c | 6 + arch/arm/mach-s5pv210/include/mach/map.h | 4 + arch/arm/mach-s5pv210/mach-goni.c | 3 +- arch/arm/plat-s5p/Kconfig | 5 + arch/arm/plat-s5p/Makefile | 2 +- arch/arm/plat-s5p/dev-mfc.c | 49 + arch/arm/plat-samsung/include/plat/devs.h | 2 + drivers/media/video/Kconfig | 8 + drivers/media/video/Makefile | 1 + drivers/media/video/s5p-mfc/Makefile | 3 + drivers/media/video/s5p-mfc/regs-mfc5.h | 335 ++++ drivers/media/video/s5p-mfc/s5p_mfc.c | 2072 +++++++++++++++++++++++ drivers/media/video/s5p-mfc/s5p_mfc_common.h | 224 +++ drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h | 173 ++ drivers/media/video/s5p-mfc/s5p_mfc_debug.h | 47 + drivers/media/video/s5p-mfc/s5p_mfc_intr.c | 92 + drivers/media/video/s5p-mfc/s5p_mfc_intr.h | 26 + drivers/media/video/s5p-mfc/s5p_mfc_memory.h | 43 + drivers/media/video/s5p-mfc/s5p_mfc_opr.c | 885 ++++++++++ drivers/media/video/s5p-mfc/s5p_mfc_opr.h | 160 ++ include/linux/videodev2.h | 45 + 25 files changed, 4233 insertions(+), 3 deletions(-) create mode 100644 arch/arm/plat-s5p/dev-mfc.c create mode 100644 drivers/media/video/s5p-mfc/Makefile create mode 100644 drivers/media/video/s5p-mfc/regs-mfc5.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_common.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_debug.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_intr.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_intr.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_memory.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_opr.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_opr.h
PATCH v6 1/4 Changes in include/linux/videodev2.h for MFC 5.1
This patch adds fourcc values for compressed video stream formats and V4L2_CTRL_CLASS_CODEC. Also adds controls used by MFC 5.1 driver.
--- include/linux/videodev2.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-)
include/linux/videodev2.h +45 -0
@@ -339,6 +339,14 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6')/* 16 Y/CbCr 4:2:2 */ #define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1')/* 16 Y/CrCb 4:2:2 */ +/* two non contiguous planes -- one Y, one Cr + Cb interleaved */ +#define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2')/* 12 Y/CbCr 4:2:0 */ +/* 12 Y/CbCr 4:2:0 64x32 macroblocks */ +#define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2') + +/* three non contiguous planes -- Y, Cb, Cr */ +#define V4L2_PIX_FMT_YUV420M v4l2_fourcc('Y', 'M', '1', '2')/* 12 YUV420 planar */ +/* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */ #define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1')/* 8 BGBG.. GRGR.. */ #define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G')/* 8 GBGB.. RGRG.. */
@@ -362,6 +370,18 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_DV v4l2_fourcc('d', 'v', 's', 'd')/* 1394 */ #define V4L2_PIX_FMT_MPEG v4l2_fourcc('M', 'P', 'E', 'G')/* MPEG-1/2/4 */ +#define V4L2_PIX_FMT_H264 v4l2_fourcc('H', '2', '6', '4')/* H264 */ +#define V4L2_PIX_FMT_H263 v4l2_fourcc('H', '2', '6', '3')/* H263 */ +#define V4L2_PIX_FMT_MPEG12 v4l2_fourcc('M', 'P', '1', '2')/* MPEG-1/2 */ +#define V4L2_PIX_FMT_MPEG4 v4l2_fourcc('M', 'P', 'G', '4')/* MPEG-4 */ +#define V4L2_PIX_FMT_DIVX v4l2_fourcc('D', 'I', 'V', 'X')/* DivX */ +#define V4L2_PIX_FMT_DIVX3 v4l2_fourcc('D', 'I', 'V', '3')/* DivX 3.11 */ +#define V4L2_PIX_FMT_DIVX4 v4l2_fourcc('D', 'I', 'V', '4')/* DivX 4.12 */ +#define V4L2_PIX_FMT_DIVX5 v4l2_fourcc('D', 'X', '5', '0')/* DivX 5 */ +#define V4L2_PIX_FMT_XVID v4l2_fourcc('X', 'V', 'I', 'D')/* Xvid */ +#define V4L2_PIX_FMT_VC1 v4l2_fourcc('V', 'C', '1', 'A')/* VC-1 */ +#define V4L2_PIX_FMT_VC1_RCV v4l2_fourcc('V', 'C', '1', 'R')/* VC-1 RCV */ +/* Vendor-specific formats */ #define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A')/* cpia1 YUV */ #define V4L2_PIX_FMT_WNVA v4l2_fourcc('W', 'N', 'V', 'A')/* Winnov hw compress */
@@ -972,6 +992,7 @@ struct v4l2_output {#define V4L2_OUTPUT_TYPE_ANALOG 2#define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3 +/* capabilities flags */ #define V4L2_OUT_CAP_PRESETS 0x00000001/* Supports S_DV_PRESET */ #define V4L2_OUT_CAP_CUSTOM_TIMINGS 0x00000002/* Supports S_DV_TIMINGS */
@@ -1009,6 +1030,7 @@ struct v4l2_ext_controls {#define V4L2_CTRL_CLASS_MPEG 0x00990000/* MPEG-compression controls */ #define V4L2_CTRL_CLASS_CAMERA 0x009a0000/* Camera class controls */ #define V4L2_CTRL_CLASS_FM_TX 0x009b0000/* FM Modulator control class */ +#define V4L2_CTRL_CLASS_CODEC 0x009c0000/* Codec control class */ #define V4L2_CTRL_ID_MASK (0x0fffffff)#define V4L2_CTRL_ID2CLASS (id) ((id) & 0x0fff0000UL)
@@ -1342,6 +1364,29 @@ enum v4l2_mpeg_cx2341x_video_median_filter_type {#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10)#define V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS (V4L2_CID_MPEG_CX2341X_BASE+11) +/* For codecs */ + +#define V4L2_CID_CODEC_BASE (V4L2_CTRL_CLASS_CODEC | 0x900) +#define V4L2_CID_CODEC_CLASS (V4L2_CTRL_CLASS_CODEC | 1) + +/* For both decoding and encoding */ + +/* For encoding */ +#define V4L2_CID_CODEC_LOOP_FILTER_H264 (V4L2_CID_CODEC_BASE + 0) +enum v4l2_cid_codec_loop_filter_h264 { +V4L2_CID_CODEC_LOOP_FILTER_H264_ENABLE =0 , +V4L2_CID_CODEC_LOOP_FILTER_H264_DISABLE =1 , +V4L2_CID_CODEC_LOOP_FILTER_H264_DISABLE_AT_BOUNDARY =2 , +}; + +/* For decoding */ + +#define V4L2_CID_CODEC_LOOP_FILTER_MPEG4_ENABLE (V4L2_CID_CODEC_BASE + 1) +#define V4L2_CID_CODEC_DISPLAY_DELAY (V4L2_CID_CODEC_BASE + 2) +#define V4L2_CID_CODEC_REQ_NUM_BUFS (V4L2_CID_CODEC_BASE + 3) +#define V4L2_CID_CODEC_SLICE_INTERFACE (V4L2_CID_CODEC_BASE + 4) +#define V4L2_CID_CODEC_PACKED_PB (V4L2_CID_CODEC_BASE + 5) +/* Camera class control IDs */ #define V4L2_CID_CAMERA_CLASS_BASE (V4L2_CTRL_CLASS_CAMERA | 0x900)#define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1)
Signature · 1 line
1.6.3.3
Re: [RFC/PATCH v6 1/4] Changes in include/linux/videodev2.h for MFC 5.1
Hi Kamil,
Here is a review of this patch. I didn't really look that closely at the others, other than noticing that they didn't use the control framework yet.
The main issue really is lack of documentation. It's hard to review something if you don't know what a new define stands for.
Quoted 15 lines · On Friday, January 07, 2011 17:25:31 Kamil Debski wrote:
This patch adds fourcc values for compressed video stream formats and
V4L2_CTRL_CLASS_CODEC. Also adds controls used by MFC 5.1 driver.Signed-off-by Kamil Debski <[email protected]>Signed-off-by Kyungmin Park <[email protected]>--- include/linux/videodev2.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-)include/linux/videodev2.h +0
-0@@ -339,6 +339,14 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6')/* 16 Y/CbCr 4:2:2 */
include/linux/videodev2.h struct v4l2_pix_format { · line 349
Quoted 10 lines
include/linux/videodev2.h +8
-0#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1')/* 16 Y/CrCb 4:2:2 */ +/* two non contiguous planes -- one Y, one Cr + Cb interleaved */ +#define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2')/* 12 Y/CbCr 4:2:0 */ +/* 12 Y/CbCr 4:2:0 64x32 macroblocks */ +#define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2') + +/* three non contiguous planes -- Y, Cb, Cr */ +#define V4L2_PIX_FMT_YUV420M v4l2_fourcc('Y', 'M', '1', '2')/* 12 YUV420 planar */ +
Don't forget to document these formats in the V4L2 spec.
Quoted 9 lines
include/linux/videodev2.h +2
-0/* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */ #define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1')/* 8 BGBG.. GRGR.. */ #define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G')/* 8 GBGB.. RGRG.. */ @@ -362,6 +370,18 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_DV v4l2_fourcc('d', 'v', 's', 'd')/* 1394 */ #define V4L2_PIX_FMT_MPEG v4l2_fourcc('M', 'P', 'E', 'G')/* MPEG-1/2/4 */ +#define V4L2_PIX_FMT_H264 v4l2_fourcc('H', '2', '6', '4')/* H264 */ +#define V4L2_PIX_FMT_H263 v4l2_fourcc('H', '2', '6', '3')/* H263 */
include/linux/videodev2.h struct v4l2_pix_format { · line 384
Quoted 10 lines
include/linux/videodev2.h +10
-0+#define V4L2_PIX_FMT_MPEG12 v4l2_fourcc('M', 'P', '1', '2')/* MPEG-1/2 */ +#define V4L2_PIX_FMT_MPEG4 v4l2_fourcc('M', 'P', 'G', '4')/* MPEG-4 */ +#define V4L2_PIX_FMT_DIVX v4l2_fourcc('D', 'I', 'V', 'X')/* DivX */ +#define V4L2_PIX_FMT_DIVX3 v4l2_fourcc('D', 'I', 'V', '3')/* DivX 3.11 */ +#define V4L2_PIX_FMT_DIVX4 v4l2_fourcc('D', 'I', 'V', '4')/* DivX 4.12 */ +#define V4L2_PIX_FMT_DIVX5 v4l2_fourcc('D', 'X', '5', '0')/* DivX 5 */ +#define V4L2_PIX_FMT_XVID v4l2_fourcc('X', 'V', 'I', 'D')/* Xvid */ +#define V4L2_PIX_FMT_VC1 v4l2_fourcc('V', 'C', '1', 'A')/* VC-1 */ +#define V4L2_PIX_FMT_VC1_RCV v4l2_fourcc('V', 'C', '1', 'R')/* VC-1 RCV */ +
Ditto. Note: FMT_MPEG and FMT_MPEG12 and possibly FMT_MPEG4 seem to describe the same format. What's the difference? And do these formats describe raw video streams or program/transport streams? Can I just put in any old DivX file or does the hardware understand only a specific dialect or even a hardware-specific variation of the standard?
Does the codec just go from compressed video to raw video? If it also goes in the other direction, how does one set bitrates, etc.?
Does it accept multiplexed streams containing audio as well? If so, what does it do with the audio?
Quoted 36 lines
include/linux/videodev2.h +15
-0/* Vendor-specific formats */ #define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A')/* cpia1 YUV */ #define V4L2_PIX_FMT_WNVA v4l2_fourcc('W', 'N', 'V', 'A')/* Winnov hw compress */ @@ -972,6 +992,7 @@ struct v4l2_output {#define V4L2_OUTPUT_TYPE_ANALOG 2#define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3 +/* capabilities flags */ #define V4L2_OUT_CAP_PRESETS 0x00000001/* Supports S_DV_PRESET */ #define V4L2_OUT_CAP_CUSTOM_TIMINGS 0x00000002/* Supports S_DV_TIMINGS */ @@ -1009,6 +1030,7 @@ struct v4l2_ext_controls {#define V4L2_CTRL_CLASS_MPEG 0x00990000/* MPEG-compression controls */ #define V4L2_CTRL_CLASS_CAMERA 0x009a0000/* Camera class controls */ #define V4L2_CTRL_CLASS_FM_TX 0x009b0000/* FM Modulator control class */ +#define V4L2_CTRL_CLASS_CODEC 0x009c0000/* Codec control class */ #define V4L2_CTRL_ID_MASK (0x0fffffff)#define V4L2_CTRL_ID2CLASS (id) ((id) & 0x0fff0000UL)@@ -1342,6 +1364,29 @@ enum v4l2_mpeg_cx2341x_video_median_filter_type {#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10)#define V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS (V4L2_CID_MPEG_CX2341X_BASE+11) +/* For codecs */ + +#define V4L2_CID_CODEC_BASE (V4L2_CTRL_CLASS_CODEC | 0x900) +#define V4L2_CID_CODEC_CLASS (V4L2_CTRL_CLASS_CODEC | 1) + +/* For both decoding and encoding */ + +/* For encoding */ +#define V4L2_CID_CODEC_LOOP_FILTER_H264 (V4L2_CID_CODEC_BASE + 0) +enum v4l2_cid_codec_loop_filter_h264 { +V4L2_CID_CODEC_LOOP_FILTER_H264_ENABLE =0 , +V4L2_CID_CODEC_LOOP_FILTER_H264_DISABLE =1 , +V4L2_CID_CODEC_LOOP_FILTER_H264_DISABLE_AT_BOUNDARY =2 ,
include/linux/videodev2.h enum v4l2_mpeg_cx2341x_video_median_filter_type { · line 1389
Quoted 10 lines
include/linux/videodev2.h +10
-0+}; + +/* For decoding */ + +#define V4L2_CID_CODEC_LOOP_FILTER_MPEG4_ENABLE (V4L2_CID_CODEC_BASE + 1) +#define V4L2_CID_CODEC_DISPLAY_DELAY (V4L2_CID_CODEC_BASE + 2) +#define V4L2_CID_CODEC_REQ_NUM_BUFS (V4L2_CID_CODEC_BASE + 3) +#define V4L2_CID_CODEC_SLICE_INTERFACE (V4L2_CID_CODEC_BASE + 4) +#define V4L2_CID_CODEC_PACKED_PB (V4L2_CID_CODEC_BASE + 5) +
This needs to be documented in the spec as well.
It seems to me just looking at the names that these controls are highly hardware specific. If so, then these controls would have to be in the range of (V4L2_CTRL_CLASS_CODEC | 0x1000) and up and need the name of the chipset as part of their ID. Similar to the cx2341x specific controls (see V4L2_CID_MPEG_CX2341X_BASE in videodev2.h).
Creating a CODEC control class seems sensible to me, so I'm fine with that.
include/linux/videodev2.h enum v4l2_mpeg_cx2341x_video_median_filter_type { · line 1392
Quoted 4 lines
include/linux/videodev2.h +0
-0/* Camera class control IDs */ #define V4L2_CID_CAMERA_CLASS_BASE (V4L2_CTRL_CLASS_CAMERA | 0x900)#define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1)
Regards,
Hans
Signature · 1 line
Hans Verkuil - video4linux developer - sponsored by Cisco
RE: [RFC/PATCH v6 1/4] Changes in include/linux/videodev2.h for MFC 5.1
Hi Hans,
I am pretty busy with other work now. That's why I have little time to work on the open source driver for the open source. I hope to have more time soon.
Quoted 11 lines
From: Hans Verkuil [mailto:[email protected]]
Hi Kamil,
Here is a review of this patch. I didn't really look that closely at the others,
other than noticing that they didn't use the control framework yet.The main issue really is lack of documentation. It's hard to review something if
you don't know what a new define stands for.
Yes, no control framework so far, but I understand this is high priority.
Quoted 30 lines · On Friday, January 07, 2011 17:25:31 Kamil Debski wrote:
Quoted 7 lines
This patch adds fourcc values for compressed video stream formats and
V4L2_CTRL_CLASS_CODEC. Also adds controls used by MFC 5.1 driver.Signed-off-by Kamil Debski <[email protected]>Signed-off-by Kyungmin Park <[email protected]>--- include/linux/videodev2.h | 45+++++++++++++++++++++++++++++++++++++++++++++
include/linux/videodev2.h struct v4l2_pix_format { · line 339
Quoted 8 lines
1 files changed, 45 insertions(+), 0 deletions(-)include/linux/videodev2.h +0
-0@@ -339,6 +339,14 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6')/* 16 Y/CbCr 4:2:2 */
include/linux/videodev2.h struct v4l2_pix_format { · line 340
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1')/* 16 Y/CrCb 4:2:2 */
include/linux/videodev2.h struct v4l2_pix_format { · line 342
Quoted 3 lines
include/linux/videodev2.h +2
-0+/* two non contiguous planes -- one Y, one Cr + Cb interleaved */ +#define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2')/* 12 Y/CbCr 4:2:0 */
include/linux/videodev2.h struct v4l2_pix_format {
Quoted 5 lines
include/linux/videodev2.h +5
-0+/* 12 Y/CbCr 4:2:0 64x32 macroblocks */ +#define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2') + +/* three non contiguous planes -- Y, Cb, Cr */ +#define V4L2_PIX_FMT_YUV420M v4l2_fourcc('Y', 'M', '1', '2')/* 12 YUV420 planar */
Quoted 3 lines
include/linux/videodev2.h struct v4l2_pix_format { · line 348
Quoted 1 line
include/linux/videodev2.h +1
-0+Don't forget to document these formats in the V4L2 spec.
Sylwester has described two of the formats.
You can find it here
http://linuxtv.org/downloads/v4l-dvb-apis/V4L2-PIX-FMT-YUV420M.html
or look at the patch here
http://git.linuxtv.org/media_tree.git?a=commit;h=8104f63b9af30c22530d1c5cea05d241566fad90
As to V4L2_PIX_FMT_NV12MT - this format is pretty complicated. The layout of the macro blocks is non obvious. Actually, I have been
working on the documentation not long ago, but I have received some higher priority work recently...
Quoted 37 lines
include/linux/videodev2.h struct v4l2_pix_format { · line 349
Quoted 2 lines
include/linux/videodev2.h +0
-0/* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */
include/linux/videodev2.h struct v4l2_pix_format { · line 350
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1')/* 8 BGBG.. GRGR.. */
include/linux/videodev2.h struct v4l2_pix_format { · line 351
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G')/* 8 GBGB.. RGRG.. */
include/linux/videodev2.h struct v4l2_pix_format { · line 370
Quoted 2 lines
include/linux/videodev2.h +0
-0@@ -362,6 +370,18 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_DV v4l2_fourcc('d', 'v', 's', 'd')/* 1394 */
include/linux/videodev2.h struct v4l2_pix_format { · line 371
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_PIX_FMT_MPEG v4l2_fourcc('M', 'P', 'E', 'G')/* MPEG-1/2/4 */
include/linux/videodev2.h struct v4l2_pix_format { · line 372
Quoted 2 lines
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_H264 v4l2_fourcc('H', '2', '6', '4')/* H264 */
include/linux/videodev2.h struct v4l2_pix_format { · line 373
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_H263 v4l2_fourcc('H', '2', '6', '3')/* H263 */
include/linux/videodev2.h struct v4l2_pix_format { · line 374
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_MPEG12 v4l2_fourcc('M', 'P', '1', '2')/* MPEG-1/2 */
include/linux/videodev2.h struct v4l2_pix_format { · line 375
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_MPEG4 v4l2_fourcc('M', 'P', 'G', '4')/* MPEG-4 */
include/linux/videodev2.h struct v4l2_pix_format { · line 376
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_DIVX v4l2_fourcc('D', 'I', 'V', 'X')/* DivX */
include/linux/videodev2.h struct v4l2_pix_format { · line 377
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_DIVX3 v4l2_fourcc('D', 'I', 'V', '3')/* DivX 3.11 */
include/linux/videodev2.h struct v4l2_pix_format { · line 378
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_DIVX4 v4l2_fourcc('D', 'I', 'V', '4')/* DivX 4.12 */
include/linux/videodev2.h struct v4l2_pix_format { · line 379
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_DIVX5 v4l2_fourcc('D', 'X', '5', '0')/* DivX 5 */
include/linux/videodev2.h struct v4l2_pix_format { · line 380
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_XVID v4l2_fourcc('X', 'V', 'I', 'D')/* Xvid */
include/linux/videodev2.h struct v4l2_pix_format { · line 381
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_VC1 v4l2_fourcc('V', 'C', '1', 'A')/* VC- 1 */
include/linux/videodev2.h struct v4l2_pix_format { · line 382
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_VC1_RCV v4l2_fourcc('V', 'C', '1', 'R')/* VC-1 RCV */
include/linux/videodev2.h struct v4l2_pix_format { · line 383
Quoted 1 line
include/linux/videodev2.h +1
-0+
Quoted 9 lines
Ditto. Note:
FMT_MPEGandFMT_MPEG12and possiblyFMT_MPEG4seem to describe the
same format. What's the difference? And do these formats describe raw video
streams or program/transport streams? Can I just put in any old DivX file or
does the hardware understand only a specific dialect or even a hardware-specific
variation of the standard?
The idea was to choose the codec by using the pixel formats. The hardware needs the application to specify what kind of stream it will deal with. Hence the different pixel formats. I think that MPEG1, 2 and 4 may fall in the V4L2_PIX_FMT_MPEG category. But when I look at the enum v4l2_mpeg_stream_type
there is no value for MPEG4 value. In addition - for MPEG1 and 2 MFC accepts elementary stream (ES) and I don't see it in the enum too.
It will accept only elementary stream. As to DivX one should select the version and the hardware will support the features defined by the standard. I think Jaeryul Oh could provide more information about DivX support.
In H264 you can have different profiles supported by hardware, still I imagine that the drivers would use V4L2_PIX_FMT_H264.
Quoted 4 lines
Does the codec just go from compressed video to raw video? If it also goes in
the other direction, how does one set bitrates, etc.?
This is the decoder only version of the driver. The hardware supports also encoding and we are working at an updated driver. There will be a set of controls for adjusting the encoding parameters.
Quoted 3 lines
Does it accept multiplexed streams containing audio as well? If so, what does
it do with the audio?
Only video elementary streams are supported.
Quoted 30 lines
include/linux/videodev2.h struct v4l2_pix_format { · line 385
Quoted 3 lines
include/linux/videodev2.h +0
-0/* Vendor-specific formats */ #define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A')/* cpia1 YUV */
include/linux/videodev2.h struct v4l2_pix_format { · line 386
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W', 'N', 'V', 'A')/* Winnov hw compress */
include/linux/videodev2.h struct v4l2_output { · line 997
Quoted 7 lines
include/linux/videodev2.h +1
-0@@ -972,6 +992,7 @@ struct v4l2_output {#define V4L2_OUTPUT_TYPE_ANALOG 2#define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3 +/* capabilities flags */ #define V4L2_OUT_CAP_PRESETS 0x00000001/* Supports
S_DV_PRESET*/include/linux/videodev2.h struct v4l2_output { · line 998
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_OUT_CAP_CUSTOM_TIMINGS 0x00000002/* Supports
S_DV_TIMINGS*/include/linux/videodev2.h struct v4l2_ext_controls { · line 1030
Quoted 2 lines
include/linux/videodev2.h +0
-0@@ -1009,6 +1030,7 @@ struct v4l2_ext_controls {#define V4L2_CTRL_CLASS_MPEG 0x00990000/* MPEG-compression controls */
include/linux/videodev2.h struct v4l2_ext_controls { · line 1031
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_CTRL_CLASS_CAMERA 0x009a0000/* Camera class controls */
include/linux/videodev2.h struct v4l2_ext_controls { · line 1032
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_CTRL_CLASS_FM_TX 0x009b0000/* FM Modulator control class */
include/linux/videodev2.h struct v4l2_ext_controls { · line 1033
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_CTRL_CLASS_CODEC 0x009c0000/* Codec control class */
include/linux/videodev2.h enum
Quoted 4 lines
include/linux/videodev2.h +0
-0#define V4L2_CTRL_ID_MASK (0x0fffffff)#define V4L2_CTRL_ID2CLASS (id) ((id) & 0x0fff0000UL)@@ -1342,6 +1364,29 @@ enum
v4l2_mpeg_cx2341x_video_median_filter_type{
Quoted 8 lines
include/linux/videodev2.h enum · line 1364
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10)include/linux/videodev2.h enum · line 1365
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS (V4L2_CID_MPEG_CX2341X_BASE+11)include/linux/videodev2.h enum v4l2_mpeg_cx2341x_video_median_filter_type {
Quoted 4 lines
include/linux/videodev2.h +3
-0+/* For codecs */ + +#define V4L2_CID_CODEC_BASE
(V4L2_CTRL_CLASS_CODEC
Quoted 2 lines
|
0x900)Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_CID_CODEC_CLASS
(V4L2_CTRL_CLASS_CODEC
Quoted 7 lines
| 1)
include/linux/videodev2.h enum v4l2_mpeg_cx2341x_video_median_filter_type {
Quoted 5 lines
include/linux/videodev2.h +5
-0+ +/* For both decoding and encoding */ + +/* For encoding */ +#define V4L2_CID_CODEC_LOOP_FILTER_H264 (V4L2_CID_CODEC_BASE + 0)
Quoted 11 lines
include/linux/videodev2.h enum v4l2_mpeg_cx2341x_video_median_filter_type {
Quoted 9 lines
include/linux/videodev2.h +9
-0+enum v4l2_cid_codec_loop_filter_h264 { +V4L2_CID_CODEC_LOOP_FILTER_H264_ENABLE =0 , +V4L2_CID_CODEC_LOOP_FILTER_H264_DISABLE =1 , +V4L2_CID_CODEC_LOOP_FILTER_H264_DISABLE_AT_BOUNDARY =2 , +}; + +/* For decoding */ + +#define V4L2_CID_CODEC_LOOP_FILTER_MPEG4_ENABLE (V4L2_CID_CODEC_BASE + 1)Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_CID_CODEC_DISPLAY_DELAY (V4L2_CID_CODEC_BASE
+
Quoted 2 lines
2)
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_CID_CODEC_REQ_NUM_BUFS (V4L2_CID_CODEC_BASE
+
Quoted 2 lines
3)
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_CID_CODEC_SLICE_INTERFACE (V4L2_CID_CODEC_BASE
+
Quoted 5 lines
4)
include/linux/videodev2.h enum v4l2_mpeg_cx2341x_video_median_filter_type { · line 1389
Quoted 2 lines
include/linux/videodev2.h +2
-0+#define V4L2_CID_CODEC_PACKED_PB (V4L2_CID_CODEC_BASE + 5) +This needs to be documented in the spec as well.
Ok.
Quoted 7 lines
It seems to me just looking at the names that these controls are highly hardware specific. If so, then these controls would have to be in the range
of (V4L2_CTRL_CLASS_CODEC|0x1000) and up and need the name of the chipset
as part of their ID. Similar to the cx2341x specific controls (seeV4L2_CID_MPEG_CX2341X_BASEinvideodev2.h).
I think that DISPLAY_DELAY would be used by more than one codec. It may be difficult to judge what is common until more chip vendors decide to include drivers for their hardware codecs in the video4linux.
Quoted 2 lines
Creating a CODEC control class seems sensible to me, so I'm fine with that.
That's good news.
Quoted 7 lines
include/linux/videodev2.h enum · line 1390
Quoted 3 lines
include/linux/videodev2.h +0
-0/* Camera class control IDs */ #define V4L2_CID_CAMERA_CLASS_BASE (V4L2_CTRL_CLASS_CAMERA |
0x900)Quoted 2 lines
include/linux/videodev2.h +0
-0#define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1)
Thank you for your comments.
Best wishes,
--
Kamil Debski
Linux Platform Group
Samsung Poland R&D Center
RE: [RFC/PATCH v6 1/4] Changes in include/linux/videodev2.h for MFC 5.1
I added something on the Kamil's comments.
Quoted 134 lines
-----Original Message-----
From: Kamil Debski [mailto:[email protected]]
Sent: Tuesday, January 25, 2011 11:38 AM
To: 'Hans Verkuil'
Cc: [email protected]; [email protected]; Marek Szyprowski; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [RFC/PATCH v6 1/4] Changes ininclude/linux/videodev2.hfor MFC 5.1Hi Hans,
I am pretty busy with other work now. That's why I have little time to work on the open source driver for the open source. I hope to have more time soon.
Quoted 11 lines
From: Hans Verkuil [mailto:[email protected]]
Hi Kamil,
Here is a review of this patch. I didn't really look that closely at the others,
other than noticing that they didn't use the control framework yet.The main issue really is lack of documentation. It's hard to review something if
you don't know what a new define stands for.Yes, no control framework so far, but I understand this is high priority.
Quoted 30 lines · On Friday, January 07, 2011 17:25:31 Kamil Debski wrote:
Quoted 7 lines
This patch adds fourcc values for compressed video stream formats and
V4L2_CTRL_CLASS_CODEC. Also adds controls used by MFC 5.1 driver.Signed-off-by Kamil Debski <[email protected]>Signed-off-by Kyungmin Park <[email protected]>--- include/linux/videodev2.h | 45+++++++++++++++++++++++++++++++++++++++++++++
include/linux/videodev2.h struct v4l2_pix_format { · line 339
Quoted 8 lines
1 files changed, 45 insertions(+), 0 deletions(-)include/linux/videodev2.h +0
-0@@ -339,6 +339,14 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6')/* 16 Y/CbCr 4:2:2 */
include/linux/videodev2.h struct v4l2_pix_format { · line 340
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1')/* 16 Y/CrCb 4:2:2 */
include/linux/videodev2.h struct v4l2_pix_format { · line 342
Quoted 3 lines
include/linux/videodev2.h +2
-0+/* two non contiguous planes -- one Y, one Cr + Cb interleaved */ +#define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2')/* 12 Y/CbCr 4:2:0 */
include/linux/videodev2.h struct v4l2_pix_format {
Quoted 5 lines
include/linux/videodev2.h +5
-0+/* 12 Y/CbCr 4:2:0 64x32 macroblocks */ +#define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2') + +/* three non contiguous planes -- Y, Cb, Cr */ +#define V4L2_PIX_FMT_YUV420M v4l2_fourcc('Y', 'M', '1', '2')/* 12 YUV420 planar */
Quoted 3 lines
include/linux/videodev2.h struct v4l2_pix_format { · line 348
Quoted 1 line
include/linux/videodev2.h +1
-0+Don't forget to document these formats in the V4L2 spec.
Sylwester has described two of the formats.
You can find it here
http://linuxtv.org/downloads/v4l-dvb-apis/V4L2-PIX-FMT-YUV420M.html
or look at the patch here
http://git.linuxtv.org/media_tree.git?a=commit;h=8104f63b9af30c22530d1c5ce
a05d241566fad90As to
V4L2_PIX_FMT_NV12MT- this format is pretty complicated. The layout of
the macro blocks is non obvious. Actually, I have been
working on the documentation not long ago, but I have received some higher priority work recently...Quoted 37 lines
include/linux/videodev2.h struct v4l2_pix_format { · line 349
Quoted 2 lines
include/linux/videodev2.h +0
-0/* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */
include/linux/videodev2.h struct v4l2_pix_format { · line 350
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1')/* 8 BGBG.. GRGR.. */
include/linux/videodev2.h struct v4l2_pix_format { · line 351
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G')/* 8 GBGB.. RGRG.. */
include/linux/videodev2.h struct v4l2_pix_format { · line 370
Quoted 2 lines
include/linux/videodev2.h +0
-0@@ -362,6 +370,18 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_DV v4l2_fourcc('d', 'v', 's', 'd')/* 1394 */
include/linux/videodev2.h struct v4l2_pix_format { · line 371
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_PIX_FMT_MPEG v4l2_fourcc('M', 'P', 'E', 'G')/* MPEG-1/2/4 */
include/linux/videodev2.h struct v4l2_pix_format { · line 372
Quoted 2 lines
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_H264 v4l2_fourcc('H', '2', '6', '4')/* H264 */
include/linux/videodev2.h struct v4l2_pix_format { · line 373
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_H263 v4l2_fourcc('H', '2', '6', '3')/* H263 */
include/linux/videodev2.h struct v4l2_pix_format { · line 374
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_MPEG12 v4l2_fourcc('M', 'P', '1', '2')/* MPEG-1/2 */
include/linux/videodev2.h struct v4l2_pix_format { · line 375
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_MPEG4 v4l2_fourcc('M', 'P', 'G', '4')/* MPEG-4 */
include/linux/videodev2.h struct v4l2_pix_format { · line 376
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_DIVX v4l2_fourcc('D', 'I', 'V', 'X')/* DivX */
include/linux/videodev2.h struct v4l2_pix_format { · line 377
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_DIVX3 v4l2_fourcc('D', 'I', 'V', '3')/* DivX 3.11 */
include/linux/videodev2.h struct v4l2_pix_format { · line 378
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_DIVX4 v4l2_fourcc('D', 'I', 'V', '4')/* DivX 4.12 */
include/linux/videodev2.h struct v4l2_pix_format { · line 379
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_DIVX5 v4l2_fourcc('D', 'X', '5', '0')/* DivX 5 */
include/linux/videodev2.h struct v4l2_pix_format { · line 380
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_XVID v4l2_fourcc('X', 'V', 'I', 'D')/* Xvid */
include/linux/videodev2.h struct v4l2_pix_format { · line 381
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_VC1 v4l2_fourcc('V', 'C', '1', 'A')/* VC- 1 */
include/linux/videodev2.h struct v4l2_pix_format { · line 382
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_PIX_FMT_VC1_RCV v4l2_fourcc('V', 'C', '1', 'R')/* VC-1 RCV */
include/linux/videodev2.h struct v4l2_pix_format { · line 383
Quoted 1 line
include/linux/videodev2.h +1
-0+Quoted 9 lines
Ditto. Note:
FMT_MPEGandFMT_MPEG12and possiblyFMT_MPEG4seem to describe the
same format. What's the difference? And do these formats describe raw video
streams or program/transport streams? Can I just put in any old DivX file or
does the hardware understand only a specific dialect or even a hardware-specific
variation of the standard?The idea was to choose the codec by using the pixel formats. The hardware needs the application to specify what kind of stream it will deal with. Hence the different pixel formats. I think that MPEG1, 2 and 4 may fall in the
V4L2_PIX_FMT_MPEGcategory. But when I look at the enumv4l2_mpeg_stream_type
there is no value for MPEG4 value. In addition - for MPEG1 and 2 MFC accepts
elementary stream (ES) and I don't see it in the enum too.
Quoted 2 lines
It will accept only elementary stream. As to DivX one should select the version and the hardware will support the features defined by the
standard.
Quoted 5 lines
I think Jaeryul Oh could provide more information about DivX support.
In H264 you can have different profiles supported by hardware, still I imagine that the drivers would use
V4L2_PIX_FMT_H264.
Basically, it was defined based on fourcc.org. but in the current fourcc.org DIV3, DIV4, DIV5, DX50 have been described. But we need one more thing to differentiate
DX53(DIV 5.03 ~) from DX50. which is required for MFC HW. Practically, to decode higher
version of DivX5.03, we should set DX53 format. But DX53(V4L2_PIX_FMT_DIVX503) is
NOT yet included in [RFC/PATCH v6 1/4] Changes in include/linux/videodev2.h for MFC 5.1
Quoted 122 lines
Quoted 4 lines
Does the codec just go from compressed video to raw video? If it also goes in
the other direction, how does one set bitrates, etc.?This is the decoder only version of the driver. The hardware supports also encoding and we are working at an updated driver. There will be a set of controls for adjusting the encoding parameters.
Quoted 3 lines
Does it accept multiplexed streams containing audio as well? If so, what does
it do with the audio?Only video elementary streams are supported.
Quoted 30 lines
include/linux/videodev2.h struct v4l2_pix_format { · line 385
Quoted 3 lines
include/linux/videodev2.h +0
-0/* Vendor-specific formats */ #define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A')/* cpia1 YUV */
include/linux/videodev2.h struct v4l2_pix_format { · line 386
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W', 'N', 'V', 'A')/* Winnov hw compress */
include/linux/videodev2.h struct v4l2_output { · line 997
Quoted 7 lines
include/linux/videodev2.h +1
-0@@ -972,6 +992,7 @@ struct v4l2_output {#define V4L2_OUTPUT_TYPE_ANALOG 2#define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3 +/* capabilities flags */ #define V4L2_OUT_CAP_PRESETS 0x00000001/* Supports
S_DV_PRESET*/include/linux/videodev2.h struct v4l2_output { · line 998
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_OUT_CAP_CUSTOM_TIMINGS 0x00000002/* Supports
S_DV_TIMINGS*/include/linux/videodev2.h struct v4l2_ext_controls { · line 1030
Quoted 2 lines
include/linux/videodev2.h +0
-0@@ -1009,6 +1030,7 @@ struct v4l2_ext_controls {#define V4L2_CTRL_CLASS_MPEG 0x00990000/* MPEG-compression controls */
include/linux/videodev2.h struct v4l2_ext_controls { · line 1031
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_CTRL_CLASS_CAMERA 0x009a0000/* Camera class controls */
include/linux/videodev2.h struct v4l2_ext_controls { · line 1032
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_CTRL_CLASS_FM_TX 0x009b0000/* FM Modulator control class */
include/linux/videodev2.h struct v4l2_ext_controls { · line 1033
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_CTRL_CLASS_CODEC 0x009c0000/* Codec control class */
include/linux/videodev2.h enum
Quoted 4 lines
include/linux/videodev2.h +0
-0#define V4L2_CTRL_ID_MASK (0x0fffffff)#define V4L2_CTRL_ID2CLASS (id) ((id) & 0x0fff0000UL)@@ -1342,6 +1364,29 @@ enum
v4l2_mpeg_cx2341x_video_median_filter_type{Quoted 8 lines
include/linux/videodev2.h enum · line 1364
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10)include/linux/videodev2.h enum · line 1365
Quoted 1 line
include/linux/videodev2.h +0
-0#define V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS (V4L2_CID_MPEG_CX2341X_BASE+11)include/linux/videodev2.h enum v4l2_mpeg_cx2341x_video_median_filter_type {
Quoted 4 lines
include/linux/videodev2.h +3
-0+/* For codecs */ + +#define V4L2_CID_CODEC_BASE (
V4L2_CTRL_CLASS_CODECQuoted 2 lines
|
0x900)Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_CID_CODEC_CLASS (
V4L2_CTRL_CLASS_CODECQuoted 7 lines
| 1)
include/linux/videodev2.h enum v4l2_mpeg_cx2341x_video_median_filter_type {
Quoted 5 lines
include/linux/videodev2.h +5
-0+ +/* For both decoding and encoding */ + +/* For encoding */ +#define V4L2_CID_CODEC_LOOP_FILTER_H264 (V4L2_CID_CODEC_BASE + 0)Quoted 11 lines
include/linux/videodev2.h enum v4l2_mpeg_cx2341x_video_median_filter_type {
Quoted 9 lines
include/linux/videodev2.h +9
-0+enum v4l2_cid_codec_loop_filter_h264 { +V4L2_CID_CODEC_LOOP_FILTER_H264_ENABLE =0 , +V4L2_CID_CODEC_LOOP_FILTER_H264_DISABLE =1 , +V4L2_CID_CODEC_LOOP_FILTER_H264_DISABLE_AT_BOUNDARY =2 , +}; + +/* For decoding */ + +#define V4L2_CID_CODEC_LOOP_FILTER_MPEG4_ENABLE (V4L2_CID_CODEC_BASE + 1)Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_CID_CODEC_DISPLAY_DELAY (V4L2_CID_CODEC_BASE+
Quoted 2 lines
2)
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_CID_CODEC_REQ_NUM_BUFS (V4L2_CID_CODEC_BASE+
Quoted 2 lines
3)
Quoted 1 line
include/linux/videodev2.h +1
-0+#define V4L2_CID_CODEC_SLICE_INTERFACE (V4L2_CID_CODEC_BASE+
Quoted 5 lines
4)
include/linux/videodev2.h enum v4l2_mpeg_cx2341x_video_median_filter_type { · line 1389
Quoted 2 lines
include/linux/videodev2.h +2
-0+#define V4L2_CID_CODEC_PACKED_PB (V4L2_CID_CODEC_BASE + 5) +This needs to be documented in the spec as well.
Ok.
Quoted 7 lines
It seems to me just looking at the names that these controls are highly hardware specific. If so, then these controls would have to be in the range
of (V4L2_CTRL_CLASS_CODEC|0x1000) and up and need the name of the chipset
as part of their ID. Similar to the cx2341x specific controls (seeV4L2_CID_MPEG_CX2341X_BASEinvideodev2.h).I think that
DISPLAY_DELAYwould be used by more than one codec. It may be difficult to judge what is common until more chip vendors decide to include drivers for their hardware codecs in the video4linux.Quoted 2 lines
Creating a CODEC control class seems sensible to me, so I'm fine with that.
That's good news.
Quoted 7 lines
include/linux/videodev2.h enum · line 1390
Quoted 3 lines
include/linux/videodev2.h +0
-0/* Camera class control IDs */ #define V4L2_CID_CAMERA_CLASS_BASE (V4L2_CTRL_CLASS_CAMERA |
0x900)Quoted 2 lines
include/linux/videodev2.h +0
-0#define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1)Thank you for your comments.
Best wishes,
--
Kamil Debski
Linux Platform Group
Samsung Poland R&D Center
PATCH v6 2/4 MFC: Add MFC 5.1 driver to plat-s5p
In reply to Kamil DebskiThis patch adds platform support for Multi Format Codec 5.1. MFC 5.1 is capable of handling a range of video codecs and this driver provides V4L2 interface for video decoding.
--- arch/arm/mach-s5pv210/clock.c | 6 +++ arch/arm/mach-s5pv210/include/mach/map.h | 4 ++ arch/arm/plat-s5p/Kconfig | 5 ++ arch/arm/plat-s5p/Makefile | 2 +- arch/arm/plat-s5p/dev-mfc.c | 49 +++++++++++++++++++++++ arch/arm/plat-samsung/include/plat/devs.h | 2 + 9 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 arch/arm/plat-s5p/dev-mfc.c
arch/arm/mach-s5pv210/clock.c +6 -0
@@ -364,6 +364,12 @@ static struct clk init_clocks_disable[] = { .enable = s5pv210_clk_ip0_ctrl, .ctrlbit = (1 << 26), }, { + .name = "mfc", + .id = -1, + .parent = &clk_pclk_psys.clk, + .enable = s5pv210_clk_ip0_ctrl, + .ctrlbit = (1 << 16), + }, { .name = "nfcon", .id = -1, .parent = &clk_hclk_psys.clk,
arch/arm/mach-s5pv210/include/mach/map.h +4 -0
@@ -73,6 +73,8 @@#define S5PV210_PA_FIMC1 (0xFB300000)#define S5PV210_PA_FIMC2 (0xFB400000) +#define S5PV210_PA_MFC (0xF1700000) +#define S5PV210_PA_HSMMC (x) (0xEB000000 + ((x) * 0x100000))#define S5PV210_PA_HSOTG (0xEC000000)
@@ -107,6 +109,7 @@#define S5PV210_PA_DMC0 (0xF0000000)#define S5PV210_PA_DMC1 (0xF1400000) +/* compatibiltiy defines. */ #define S3C_PA_UART S5PV210_PA_UART#define S3C_PA_HSMMC0 S5PV210_PA_HSMMC(0)
@@ -123,6 +126,7 @@#define S5P_PA_FIMC0 S5PV210_PA_FIMC0#define S5P_PA_FIMC1 S5PV210_PA_FIMC1#define S5P_PA_FIMC2 S5PV210_PA_FIMC2 +#define S5P_PA_MFC S5PV210_PA_MFC#define SAMSUNG_PA_ADC S5PV210_PA_ADC#define SAMSUNG_PA_CFCON S5PV210_PA_CFCON
arch/arm/plat-s5p/Kconfig +5 -0
@@ -5,6 +5,11 @@ # # Licensed under GPLv2 +config S5P_DEV_MFC + bool + help + Compile in platform device definitions for MFC + config PLAT_S5P bool depends on (ARCH_S5P64X0 || ARCH_S5P6442 || ARCH_S5PC100 || ARCH_S5PV210 || ARCH_S5PV310)
arch/arm/plat-s5p/Makefile +1 -1
@@ -23,7 +23,7 @@ obj-$(CONFIG_PM) += pm.o obj-$(CONFIG_PM) += irq-pm.o # devices - +obj-$(CONFIG_S5P_DEV_MFC) += dev-mfc.o obj-$(CONFIG_S5P_DEV_FIMC0) += dev-fimc0.o obj-$(CONFIG_S5P_DEV_FIMC1) += dev-fimc1.o obj-$(CONFIG_S5P_DEV_FIMC2) += dev-fimc2.o
arch/arm/plat-s5p/dev-mfc.c new file +49 -0
49 lines not on this page · raw message
arch/arm/plat-samsung/include/plat/devs.h +2 -0
@@ -124,6 +124,8 @@ extern struct platform_device s5p_device_fimc2;extern struct platform_device s5p_device_fimc3;extern struct platform_device s5pv310_device_fb0; +extern struct platform_device s5p_device_mfc; +/* s3c2440 specific devices */ #ifdef CONFIG_CPU_S3C2440
Signature · 1 line
1.6.3.3
PATCH v6 3/4 MFC: Add MFC 5.1 V4L2 driver
In reply to Kamil DebskiMulti Format Codec 5.1 is capable of handling a range of video codecs and this driver provides V4L2 interface for video decoding.
--- drivers/media/video/Kconfig | 8 + drivers/media/video/Makefile | 1 + drivers/media/video/s5p-mfc/Makefile | 3 + drivers/media/video/s5p-mfc/regs-mfc5.h | 335 +++++ drivers/media/video/s5p-mfc/s5p_mfc.c | 2072 ++++++++++++++++++++++++++ drivers/media/video/s5p-mfc/s5p_mfc_common.h | 224 +++ drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h | 173 +++ drivers/media/video/s5p-mfc/s5p_mfc_debug.h | 47 + drivers/media/video/s5p-mfc/s5p_mfc_intr.c | 92 ++ drivers/media/video/s5p-mfc/s5p_mfc_intr.h | 26 + drivers/media/video/s5p-mfc/s5p_mfc_memory.h | 43 + drivers/media/video/s5p-mfc/s5p_mfc_opr.c | 885 +++++++++++ drivers/media/video/s5p-mfc/s5p_mfc_opr.h | 160 ++ 13 files changed, 4069 insertions(+), 0 deletions(-) create mode 100644 drivers/media/video/s5p-mfc/Makefile create mode 100644 drivers/media/video/s5p-mfc/regs-mfc5.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_common.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_debug.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_intr.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_intr.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_memory.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_opr.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_opr.h
drivers/media/video/Kconfig +8 -0
@@ -1035,4 +1035,12 @@ config VIDEO_SAMSUNG_S5P_FIMC This is a v4l2 driver for the S5P camera interface (video postprocessor) +config VIDEO_SAMSUNG_S5P_MFC + tristate "Samsung S5P MFC 5.1 Video Codec" + depends on VIDEO_V4L2 && CMA + select VIDEOBUF2_CMA + default n + help + MFC 5.1 driver for V4L2. + endif # V4L_MEM2MEM_DRIVERS
drivers/media/video/Makefile +1 -0
@@ -172,6 +172,7 @@ obj-$(CONFIG_VIDEO_SH_MOBILE_CSI2) += sh_mobile_csi2.o obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o obj-$(CONFIG_VIDEO_OMAP1) += omap1_camera.o obj-$(CONFIG_VIDEO_SAMSUNG_S5P_FIMC) += s5p-fimc/ +obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC) += s5p-mfc/ obj-$(CONFIG_ARCH_DAVINCI) += davinci/
drivers/media/video/s5p-mfc/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC) := s5p-mfc.o +s5p-mfc-y := s5p_mfc.o s5p_mfc_intr.o s5p_mfc_opr.o +
drivers/media/video/s5p-mfc/regs-mfc5.h new file +335 -0
335 lines not on this page · raw message
drivers/media/video/s5p-mfc/s5p_mfc.c new file +2072 -0
2,072 lines not on this page · raw message
drivers/media/video/s5p-mfc/s5p_mfc_common.h new file +224 -0
224 lines not on this page · raw message
drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h new file +173 -0
173 lines not on this page · raw message
drivers/media/video/s5p-mfc/s5p_mfc_debug.h new file +47 -0
47 lines not on this page · raw message
drivers/media/video/s5p-mfc/s5p_mfc_intr.c new file +92 -0
92 lines not on this page · raw message
drivers/media/video/s5p-mfc/s5p_mfc_intr.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* drivers/media/video/samsung/mfc5/s5p_mfc_intr.h +* +* Header file for Samsung MFC (Multi Function Codec - FIMV) driver +* It contains waiting functions declarations. +* +* Kamil Debski, Copyright (c) 2010 Samsung Electronics +* http://www.samsung.com/ +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef _S5P_MFC_INTR_H_ +#define _S5P_MFC_INTR_H_ + +#include "s5p_mfc_common.h" + +int s5p_mfc_wait_for_done_ctx (struct s5p_mfc_ctx *ctx, +int command,int interrupt); +int s5p_mfc_wait_for_done_dev (struct s5p_mfc_dev *dev,int command); +void s5p_mfc_clean_ctx_int_flags (struct s5p_mfc_ctx *ctx); +void s5p_mfc_clean_dev_int_flags (struct s5p_mfc_dev *dev); + +#endif /* _S5P_MFC_INTR_H_ */
drivers/media/video/s5p-mfc/s5p_mfc_memory.h new file +43 -0
9 lines not on this page · raw message
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +885 -0
885 lines not on this page · raw message
drivers/media/video/s5p-mfc/s5p_mfc_opr.h new file +160 -0
160 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.6.3.3
Part of the diff is not shown here. View the raw message.
RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driver
Hi,
Kamil Debski wrote:
<snip>
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 3 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +3
-0+/* Reqeust buffers */ +static int vidioc_reqbufs (struct file *file,void *priv, + struct v4l2_requestbuffers
*reqbufs)
Quoted 4 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+{ +struct s5p_mfc_dev *dev =video_drvdata (file); +struct s5p_mfc_ctx *ctx = priv; +int ret =0 ;
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+unsigned long flags; + +mfc_debug_enter (); +mfc_debug ("Memory type: %d\n" , reqbufs->memory); +if (reqbufs->memory !=V4L2_MEMORY_MMAP ) { +mfc_err ("Only V4L2_MEMORY_MAP is supported.\n" ); +return -EINVAL ; + } +if (reqbufs->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) { +/* Can only request buffers after an instance has been
opened.*/
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 4 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+if (ctx->state ==MFCINST_DEC_GOT_INST ) { +/* Decoding */ +if (ctx->output_state !=QUEUE_FREE ) { + mfc_err("Bufs have already been
requested.\n");
Quoted 54 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +11
-0+return -EINVAL ; + } + ret =vb2_reqbufs (&ctx->vq_src, reqbufs); +if (ret) { +mfc_err ("vb2_reqbufs on output failed.\n" ); +return ret; + } +mfc_debug ("vb2_reqbufs: %d\n" , ret); + ctx->output_state =QUEUE_BUFS_REQUESTED ; + } + } else if (reqbufs->type ==
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {drivers/media/video/s5p-mfc/s5p_mfc.c new file +41
-0+if (ctx->capture_state !=QUEUE_FREE ) { +mfc_err ("Bufs have already been requested.\n" ); +return -EINVAL ; + } + ctx->capture_state =QUEUE_BUFS_REQUESTED ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +if (ret) { +mfc_err ("vb2_reqbufs on capture failed.\n" ); +return ret; + } +if (reqbufs->count < ctx->dpb_count) { +mfc_err ("Not enough buffers allocated.\n" ); + reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +return -ENOMEM ; + } + ctx->total_dpb_count = reqbufs->count; + ret =s5p_mfc_alloc_dec_buffers (ctx); +if (ret) { +mfc_err ("Failed to allocate decoding buffers.\n" ); + reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +return -ENOMEM ; + } +if (ctx->dst_bufs_cnt == ctx->total_dpb_count) { + ctx->capture_state =QUEUE_BUFS_MMAPED ; + }else { +mfc_err ("Not all buffers passed to buf_init.\n" ); + reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +s5p_mfc_release_dec_buffers (ctx); +return -ENOMEM ; + } +if (s5p_mfc_ctx_ready (ctx)) { +spin_lock_irqsave (&dev->condlock, flags); +set_bit (ctx->num, &dev->ctx_work_bits); +spin_unlock_irqrestore (&dev->condlock, flags); + } +s5p_mfc_try_run (dev); + s5p_mfc_wait_for_done_ctx(ctx, +
S5P_FIMV_R2H_CMD_INIT_BUFFERS_RET, 1);
drivers/media/video/s5p-mfc/s5p_mfc.c line 466
Quoted 4 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+ } +mfc_debug_leave (); +return ret; +}
I don't know how to handle the followings.
So I suggest that in reqbufs->type == V4L2_BUF_TYPE_VIDEO_OUTPUT case, how about return -EINVAL if reqbufs->count is bigger than 1.
Because if reqbufs->count is bigger than 1, it is hard to handle the encoded input stream.
For example: Dynamic resolution change
Dynamic resolution change means that resolution can be changed at any I-frame with header on the fly during streaming.
MFC H/W can detect it after getting decoding command from the driver. If the dynamic resolution change is detected by MFC H/W, driver should let application know the fact to do the following Sequence 1 by application.
Sequence 1:
streamoff -> munmap -> reqbufs(0) -> S_FMT(changed resolution) -> querybuf -> mmap -> re-QBUF with the I-frame -> STREAMON -> ...
Why it is hard to handle the encoded input stream in multiple input stream case is the following Sequence 2.
Sequence 2:
QBUF(0) -> QBUF(1: resolution changed I-frame) -> QBUF(2: already changed) -> QBUF(3: already changed) -> DQBUF(0) -> DQBUF(1): return fail -> ...
Application cannot know the resolution change in the QBUF ioctl. Driver will return 0 at the QBUF because all parameters are fine. But after sending the decode command to MFC H/W, driver can know that the I-frame needs to change resolution.
In that case driver can return error at the DQBUF of the buffer.
In the sequence 2, application can know the resolution change in the DQBUF(1).
So the application should re-QBUF the buffer 2, 3 after Sequence 1. It is hard to re-control the buffers which are already queued in the point of application.
Because in the reqbufs(0) buffers will be freed.
So application has to copy them to the temporary buffer to re-QBUF after Sequence 1.
How can we solve this case ?
Best regards,
RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driver
Hi,
Quoted 143 lines
-----Original Message-----
From: Jonghun Han [mailto:[email protected]]Hi,
Kamil Debski wrote:
<snip>
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 3 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +3
-0+/* Reqeust buffers */ +static int vidioc_reqbufs (struct file *file,void *priv, + struct v4l2_requestbuffers*reqbufs)
Quoted 4 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+{ +struct s5p_mfc_dev *dev =video_drvdata (file); +struct s5p_mfc_ctx *ctx = priv; +int ret =0 ;drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+unsigned long flags; + +mfc_debug_enter (); +mfc_debug ("Memory type: %d\n" , reqbufs->memory); +if (reqbufs->memory !=V4L2_MEMORY_MMAP ) { +mfc_err ("Only V4L2_MEMORY_MAP is supported.\n" ); +return -EINVAL ; + } +if (reqbufs->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) { +/* Can only request buffers after an instance has been opened.*/
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 4 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+if (ctx->state ==MFCINST_DEC_GOT_INST ) { +/* Decoding */ +if (ctx->output_state !=QUEUE_FREE ) { + mfc_err("Bufs have already beenrequested.\n");
Quoted 54 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +11
-0+return -EINVAL ; + } + ret =vb2_reqbufs (&ctx->vq_src, reqbufs); +if (ret) { +mfc_err ("vb2_reqbufs on output failed.\n" ); +return ret; + } +mfc_debug ("vb2_reqbufs: %d\n" , ret); + ctx->output_state =QUEUE_BUFS_REQUESTED ; + } + } else if (reqbufs->type ==
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {drivers/media/video/s5p-mfc/s5p_mfc.c new file +41
-0+if (ctx->capture_state !=QUEUE_FREE ) { +mfc_err ("Bufs have already been requested.\n" ); +return -EINVAL ; + } + ctx->capture_state =QUEUE_BUFS_REQUESTED ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +if (ret) { +mfc_err ("vb2_reqbufs on capture failed.\n" ); +return ret; + } +if (reqbufs->count < ctx->dpb_count) { +mfc_err ("Not enough buffers allocated.\n" ); + reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +return -ENOMEM ; + } + ctx->total_dpb_count = reqbufs->count; + ret =s5p_mfc_alloc_dec_buffers (ctx); +if (ret) { +mfc_err ("Failed to allocate decoding buffers.\n" ); + reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +return -ENOMEM ; + } +if (ctx->dst_bufs_cnt == ctx->total_dpb_count) { + ctx->capture_state =QUEUE_BUFS_MMAPED ; + }else { +mfc_err ("Not all buffers passed to buf_init.\n" ); + reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +s5p_mfc_release_dec_buffers (ctx); +return -ENOMEM ; + } +if (s5p_mfc_ctx_ready (ctx)) { +spin_lock_irqsave (&dev->condlock, flags); +set_bit (ctx->num, &dev->ctx_work_bits); +spin_unlock_irqrestore (&dev->condlock, flags); + } +s5p_mfc_try_run (dev); + s5p_mfc_wait_for_done_ctx(ctx, +
S5P_FIMV_R2H_CMD_INIT_BUFFERS_RET, 1);drivers/media/video/s5p-mfc/s5p_mfc.c line 466
Quoted 4 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+ } +mfc_debug_leave (); +return ret; +}I don't know how to handle the followings.
So I suggest that in
reqbufs->type==V4L2_BUF_TYPE_VIDEO_OUTPUTcase, how about return-EINVALifreqbufs->countis bigger than 1.Because if
reqbufs->countis bigger than 1, it is hard to handle the encoded
input stream.For example: Dynamic resolution change
Dynamic resolution change means that resolution can be changed at any I-frame with header on the fly during streaming.MFC H/W can detect it after getting decoding command from the driver. If the dynamic resolution change is detected by MFC H/W, driver should let application know the fact to do the following Sequence 1
by application.Sequence 1:
streamoff -> munmap -> reqbufs(0) ->S_FMT(changed resolution)-> querybuf
-> mmap -> re-QBUF with the I-frame -> STREAMON -> ...Why it is hard to handle the encoded input stream in multiple input stream
case is the following Sequence 2.Sequence 2:
QBUF(0) -> QBUF(1: resolution changed I-frame) -> QBUF(2: already changed)
-> QBUF(3: already changed) -> DQBUF(0) -> DQBUF(1): return fail -> ...Application cannot know the resolution change in the QBUF ioctl. Driver will return 0 at the QBUF because all parameters are fine. But after sending the decode command to MFC H/W, driver can know that the
I-frame needs to change resolution.
In that case driver can return error at the DQBUF of the buffer.In the sequence 2, application can know the resolution change in the DQBUF(1).
So the application should re-QBUF the buffer 2, 3 after Sequence 1. It is hard to re-control the buffers which are already queued in the point
of application.
Because in the reqbufs(0) buffers will be freed.
So application has to copy them to the temporary buffer to re-QBUF after
Sequence 1.
Quoted 1 line
How can we solve this case ?
There are two buffer queues - the OUTPUT is the queue for the compressed source. I don't see the need to do anything with this queue when resolution is changed.
There could be 3 src buffers queued for example. Let's say the first is an I-frame
with changed resolution. This does not affect the following source buffers. I
agree with you that it will have impact on the destination (CAPTURE) buffers.
The problem is how to notify the application that the resolution has been changed.
After the application is notified by the driver that resolution has been changed it has to do the following:
1. DQBUF all the remaining destination CAPTURE buffers (with old resolution)
2. Do stream off on CAPUTRE
3. unmap all the CAPTURE buffers
4. REQBUFS(0) on CAPTURE
5. G_FMT on CAPTURE to get the new resolution
6. REQBUFS(n) on CAPTURE
7. mmap the CAPTURE buffers
8. QBUF all the new CAPTURE buffers
9. Do stream on on CAPTURE
As you can see, the OUTPUT queue has not been modified. All the 3 source buffers
are still queued until after step 9 when the processing restarts.
Quoted 1 line
From the driver perspective it looks like this:
a) After it has received DISP_STATUS [5:4] != 0 it sends the FRAME_START_REALLOC
command. Then it behave the same as if the stream was finished - running FRAME_START
and returning the remaining buffers. This is the step 1 for application described above.
b) When no more buffers are left (DISP_STATUS[2:0]= 3) it has to notify the application
that the resolution have changed. I will discuss how to do it below.
c) The application was notified and completed steps 2-4, at this time the driver has to
reinitialize the stream. Here it will use the source buffer that had resolution change
again with command INIT_CODEC.
d) The instance is reinitialized, and new resolution is read from MFC. The application now
completes steps 5-9.
e) As destination (CAPTURE) buffers are now queued the driver continues decoding.FRAME_START command is issued for the source buffer that had resolution change and it is
decoded. This is the place when this source buffer is marked as done and it can be dequeued
by the application.
As you can see - there was no need to reinitialize the OUTPUT queue. Only CAPTURE, so there
is no need to restrict number of source (OUTPUT) buffers to 1.
The question is how to notify the application. I think I could be done same as end of stream
notification - by returning a buffer with size equal to 0.
If the application knows that source stream has ended, and queued a source buffer of size 0
to notify the driver - then a destination buffer of size 0 means that decoding is finished.
In case of resolution change the application still has source buffers queued and it receives
a destination buffer with size=0. Knowing this the application can do the resolution change
procedure.
I welcome your comments.
Best regards,
--
Kamil Debski
Linux Platform Group
Samsung Poland R&D Center
RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driver
Hi,
I was confused the source and destination.
I agree with you mostly.
In my opinion, the way how to notify the resolution change is return value of the DQBUF.
But if we use DQBUF, there are some problem as below.
DQBUF means that the buffer has been operated already and application will have the buffer's right.
Although application new QBUF destination buffers after changing destination(CAPTURE),
driver cannot re-decode the I-frame which has the resolution change information
because the I-frame has been dequeued already.
If application re-QBUF the buffer, the buffer sequence will be out of order as below.
Original: I -> B -> B .....
Out of order: missed -> B -> B -> I .....
How do you think about the following sequence.
1. getting the resolution change from the MFC H/W
2. copy the buffer to driver's internal memory.
3. send the result with DQBUF
4. changing destination buffers by application
5. QBUF for new destination buffers
6. in the first vb2_try_schedule
re-decode the driver's internal buffer instead of the B frame.
7. in the next vb2_try_schedule
decode the B frame in order.
I also welcome your comments.
Best regards,
Quoted 154 lines
-----Original Message-----
From: Kamil Debski [mailto:[email protected]]
Sent: Friday, January 14, 2011 4:24 PM
To: 'Jonghun Han'; [email protected]; linux-samsung- [email protected]
Cc: Marek Szyprowski; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driverHi,
Quoted 143 lines
-----Original Message-----
From: Jonghun Han [mailto:[email protected]]Hi,
Kamil Debski wrote:
<snip>
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 3 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +3
-0+/* Reqeust buffers */ +static int vidioc_reqbufs (struct file *file,void *priv, + struct v4l2_requestbuffers*reqbufs)
Quoted 4 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+{ +struct s5p_mfc_dev *dev =video_drvdata (file); +struct s5p_mfc_ctx *ctx = priv; +int ret =0 ;drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+unsigned long flags; + +mfc_debug_enter (); +mfc_debug ("Memory type: %d\n" , reqbufs->memory); +if (reqbufs->memory !=V4L2_MEMORY_MMAP ) { +mfc_err ("Only V4L2_MEMORY_MAP is supported.\n" ); +return -EINVAL ; + } +if (reqbufs->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) { +/* Can only request buffers after an instance has been opened.*/
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 4 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+if (ctx->state ==MFCINST_DEC_GOT_INST ) { +/* Decoding */ +if (ctx->output_state !=QUEUE_FREE ) { + mfc_err("Bufs have already beenrequested.\n");
Quoted 54 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +11
-0+return -EINVAL ; + } + ret =vb2_reqbufs (&ctx->vq_src, reqbufs); +if (ret) { +mfc_err ("vb2_reqbufs on output failed.\n" ); +return ret; + } +mfc_debug ("vb2_reqbufs: %d\n" , ret); + ctx->output_state =QUEUE_BUFS_REQUESTED ; + } + } else if (reqbufs->type ==
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {drivers/media/video/s5p-mfc/s5p_mfc.c new file +41
-0+if (ctx->capture_state !=QUEUE_FREE ) { +mfc_err ("Bufs have already been requested.\n" ); +return -EINVAL ; + } + ctx->capture_state =QUEUE_BUFS_REQUESTED ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +if (ret) { +mfc_err ("vb2_reqbufs on capture failed.\n" ); +return ret; + } +if (reqbufs->count < ctx->dpb_count) { +mfc_err ("Not enough buffers allocated.\n" ); + reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +return -ENOMEM ; + } + ctx->total_dpb_count = reqbufs->count; + ret =s5p_mfc_alloc_dec_buffers (ctx); +if (ret) { +mfc_err ("Failed to allocate decoding buffers.\n" ); + reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +return -ENOMEM ; + } +if (ctx->dst_bufs_cnt == ctx->total_dpb_count) { + ctx->capture_state =QUEUE_BUFS_MMAPED ; + }else { +mfc_err ("Not all buffers passed to buf_init.\n" ); + reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +s5p_mfc_release_dec_buffers (ctx); +return -ENOMEM ; + } +if (s5p_mfc_ctx_ready (ctx)) { +spin_lock_irqsave (&dev->condlock, flags); +set_bit (ctx->num, &dev->ctx_work_bits); +spin_unlock_irqrestore (&dev->condlock, flags); + } +s5p_mfc_try_run (dev); + s5p_mfc_wait_for_done_ctx(ctx, +
S5P_FIMV_R2H_CMD_INIT_BUFFERS_RET, 1);drivers/media/video/s5p-mfc/s5p_mfc.c line 466
Quoted 4 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+ } +mfc_debug_leave (); +return ret; +}I don't know how to handle the followings.
So I suggest that in
reqbufs->type==V4L2_BUF_TYPE_VIDEO_OUTPUTcase, how about return-EINVALifreqbufs->countis bigger than 1.Because if
reqbufs->countis bigger than 1, it is hard to handle the encoded
input stream.For example: Dynamic resolution change
Dynamic resolution change means that resolution can be changed at any I-frame with header on the fly during streaming.MFC H/W can detect it after getting decoding command from the driver. If the dynamic resolution change is detected by MFC H/W, driver should let application know the fact to do the following Sequence 1
by application.Sequence 1:
streamoff -> munmap -> reqbufs(0) ->S_FMT(changed resolution)-> querybuf
-> mmap -> re-QBUF with the I-frame -> STREAMON -> ...Why it is hard to handle the encoded input stream in multiple input stream
case is the following Sequence 2.Sequence 2:
QBUF(0) -> QBUF(1: resolution changed I-frame) -> QBUF(2: already changed)
-> QBUF(3: already changed) -> DQBUF(0) -> DQBUF(1): return fail -> ...Application cannot know the resolution change in the QBUF ioctl. Driver will return 0 at the QBUF because all parameters are fine. But after sending the decode command to MFC H/W, driver can know that the
I-frame needs to change resolution.
In that case driver can return error at the DQBUF of the buffer.In the sequence 2, application can know the resolution change in the DQBUF(1).
So the application should re-QBUF the buffer 2, 3 after Sequence 1. It is hard to re-control the buffers which are already queued in the point
of application.
Because in the reqbufs(0) buffers will be freed.
So application has to copy them to the temporary buffer to re-QBUF after
Sequence 1.
Quoted 4 lines
Quoted 1 line
How can we solve this case ?
There are two buffer queues - the OUTPUT is the queue for the compressed source. I don't see the need to do anything with this queue when
resolution
Quoted 5 lines
is changed.
There could be 3 src buffers queued for example. Let's say the first is an I-frame
with changed resolution. This does not affect the following source
buffers.
Quoted 9 lines
I
agree with you that it will have impact on the destination (CAPTURE) buffers.
The problem is how to notify the application that the resolution has been changed.After the application is notified by the driver that resolution has been changed it has to do the following:
1. DQBUF all the remaining destination CAPTURE buffers (with old
resolution)
Quoted 13 lines
2. Do stream off on CAPUTRE
3. unmap all the CAPTURE buffers
4. REQBUFS(0) on CAPTURE
5.G_FMTon CAPTURE to get the new resolution
6. REQBUFS(n) on CAPTURE
7. mmap the CAPTURE buffers
8. QBUF all the new CAPTURE buffers
9. Do stream on on CAPTUREAs you can see, the OUTPUT queue has not been modified. All the 3 source buffers
are still queued until after step 9 when the processing restarts.
Quoted 8 lines
From the driver perspective it looks like this:
a) After it has receivedDISP_STATUS[5:4] != 0 it sends theFRAME_START_REALLOC
command. Then it behave the same as if the stream was finished - runningFRAME_START
and returning the remaining buffers. This is the step 1 for application described above.
b) When no more buffers are left (DISP_STATUS[2:0]= 3) it has to notify
the
Quoted 7 lines
application
that the resolution have changed. I will discuss how to do it below.
c) The application was notified and completed steps 2-4, at this time the driver has to
reinitialize the stream. Here it will use the source buffer that had resolution change
again with commandINIT_CODEC.
Quoted 8 lines
d) The instance is reinitialized, and new resolution is read from MFC. The application now
completes steps 5-9.
e) As destination (CAPTURE) buffers are now queued the driver continues decoding.FRAME_STARTcommand is issued for the source buffer that had resolution change and it is
decoded. This is the place when this source buffer is marked as done and
it
Quoted 8 lines
can be dequeued
by the application.As you can see - there was no need to reinitialize the OUTPUT queue. Only CAPTURE, so there
is no need to restrict number of source (OUTPUT) buffers to 1.The question is how to notify the application. I think I could be done
same
Quoted 7 lines
as end of stream
notification - by returning a buffer with size equal to 0.
If the application knows that source stream has ended, and queued a source buffer of size 0
to notify the driver - then a destination buffer of size 0 means that decoding is finished.
In case of resolution change the application still has source buffers
queued
Quoted 12 lines
and it receives
a destination buffer with size=0. Knowing this the application can do the resolution change
procedure.I welcome your comments.
Best regards,
--
Kamil Debski
Linux Platform Group
Samsung Poland R&D Center
RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driver
I added my comments.
I guess that Kamil's way could be possible to run seq. of dynamic resolution change.
Quoted 45 lines
-----Original Message-----
From: Jonghun Han [mailto:[email protected]]
Sent: Friday, January 14, 2011 6:45 PM
To: 'Kamil Debski'; [email protected]; linux-samsung- [email protected]
Cc: 'Marek Szyprowski'; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driverHi,
I was confused the source and destination.
I agree with you mostly.In my opinion, the way how to notify the resolution change is return value of the DQBUF.
But if we use DQBUF, there are some problem as below.DQBUF means that the buffer has been operated already and application will have the buffer's right.
Although application new QBUF destination buffers after changing destination(CAPTURE),
driver cannot re-decode the I-frame which has the resolution change information
because the I-frame has been dequeued already.
If application re-QBUF the buffer, the buffer sequence will be out of order
as below.
Original: I -> B -> B .....
Out of order: missed -> B -> B -> I .....How do you think about the following sequence.
1. getting the resolution change from the MFC H/W
2. copy the buffer to driver's internal memory.
3. send the result with DQBUF
4. changing destination buffers by application
5. QBUF for new destination buffers
Quoted 7 lines
6. in the first
vb2_try_schedule
re-decode the driver's internal buffer instead of the B frame.7. in the next
vb2_try_schedule
decode the B frame in order.I also welcome your comments.
In the blocking sequence, blocking will be done in DQBUF.
1. QBUF done for I1 frame with hdr(first buf, res. chd)
: Copy I1 frame in the driver
2. DQBUF done for I1 frame
3. QBUF P2,P3,P4 frame, but it should NOT be DEQUED which means Qbufed p2,p3,p4 is not executed
: P4(third buf) -> P3(second buf) -> P2 frame(first buf)
4. While waiting for DEQUE about P2, copied I1 frame is executed forINIT_CODEC
5. Copied I1 frame is runned FRAME_START after dst buffer is reallocated
(5~9 in your seq.)
6. Queued P2 frame is executed, then DQBUF will be OK
Quoted 27 lines
Best regards,
Quoted 24 lines
-----Original Message-----
From: Kamil Debski [mailto:[email protected]]
Sent: Friday, January 14, 2011 4:24 PM
To: 'Jonghun Han'; [email protected]; linux-samsung- [email protected]
Cc: Marek Szyprowski; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driverHi,
Quoted 13 lines
-----Original Message-----
From: Jonghun Han [mailto:[email protected]]Hi,
Kamil Debski wrote:
<snip>
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 3 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +3
-0+/* Reqeust buffers */ +static int vidioc_reqbufs (struct file *file,void *priv, + struct v4l2_requestbuffers*reqbufs)
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +6
-0+{ +struct s5p_mfc_dev *dev =video_drvdata (file); +struct s5p_mfc_ctx *ctx = priv; +int ret =0 ; +unsigned long flags; +Quoted 8 lines
Quoted 8 lines
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 8 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +8
-0+mfc_debug_enter (); +mfc_debug ("Memory type: %d\n" , reqbufs->memory); +if (reqbufs->memory !=V4L2_MEMORY_MMAP ) { +mfc_err ("Only V4L2_MEMORY_MAP is supported.\n" ); +return -EINVAL ; + } +if (reqbufs->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) { +/* Can only request buffers after an instance has
been
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
opened.*/
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 4 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+if (ctx->state ==MFCINST_DEC_GOT_INST ) { +/* Decoding */ +if (ctx->output_state !=QUEUE_FREE ) { + mfc_err("Bufs have already beenrequested.\n");
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 5 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +5
-0+return -EINVAL ; + } + ret =vb2_reqbufs (&ctx->vq_src, reqbufs); +if (ret) { + mfc_err("vb2_reqbufs on outputfailed.\n");
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Review
Quoted 9 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +6
-0+return ret; + } +mfc_debug ("vb2_reqbufs: %d\n" , ret); + ctx->output_state =QUEUE_BUFS_REQUESTED ; + } + } else if (reqbufs->type ==
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {(quoted diff) +2
-0+ if (ctx->capture_state != QUEUE_FREE) { + mfc_err("Bufs have already been
requested.\n");
Quoted 28 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+return -EINVAL ; + } + ctx->capture_state =QUEUE_BUFS_REQUESTED ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +if (ret) { +mfc_err ("vb2_reqbufs on capture failed.\n" ); +return ret; + } +if (reqbufs->count < ctx->dpb_count) { +mfc_err ("Not enough buffers allocated.\n" );Quoted 8 lines
Quoted 8 lines
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 8 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +8
-0+ reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +return -ENOMEM ; + } + ctx->total_dpb_count = reqbufs->count; + ret =s5p_mfc_alloc_dec_buffers (ctx); +if (ret) { + mfc_err("Failed to allocate decodingbuffers.\n");
Quoted 8 lines
Quoted 8 lines
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 8 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +8
-0+ reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +return -ENOMEM ; + } +if (ctx->dst_bufs_cnt == ctx->total_dpb_count) { + ctx->capture_state =QUEUE_BUFS_MMAPED ; + }else { + mfc_err("Not all buffers passed tobuf_init.\n");
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 9 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +9
-0+ reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +s5p_mfc_release_dec_buffers (ctx); +return -ENOMEM ; + } +if (s5p_mfc_ctx_ready (ctx)) { +spin_lock_irqsave (&dev->condlock, flags); +set_bit (ctx->num, &dev->ctx_work_bits); + spin_unlock_irqrestore(&dev->condlock,
flags);
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
drivers/media/video/s5p-mfc/s5p_mfc.c line 466
Quoted 9 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+ } +s5p_mfc_try_run (dev); + s5p_mfc_wait_for_done_ctx(ctx, +
S5P_FIMV_R2H_CMD_INIT_BUFFERS_RET, 1);drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+ } +mfc_debug_leave (); +return ret; +}I don't know how to handle the followings.
So I suggest that in
reqbufs->type==V4L2_BUF_TYPE_VIDEO_OUTPUTcase, how about return-EINVALifreqbufs->countis bigger than 1.Because if
reqbufs->countis bigger than 1, it is hard to handle the encoded
input stream.For example: Dynamic resolution change
Dynamic resolution change means that resolution can be changed at any I-frame with header on the fly during streaming.MFC H/W can detect it after getting decoding command from the driver. If the dynamic resolution change is detected by MFC H/W, driver should let application know the fact to do the following Sequence 1
by application.Sequence 1:
streamoff -> munmap -> reqbufs(0) ->S_FMT(changed resolution)-> querybuf
-> mmap -> re-QBUF with the I-frame -> STREAMON -> ...Why it is hard to handle the encoded input stream in multiple input stream
case is the following Sequence 2.Sequence 2:
QBUF(0) -> QBUF(1: resolution changed I-frame) -> QBUF(2: already changed)
-> QBUF(3: already changed) -> DQBUF(0) -> DQBUF(1): return fail ->
...
Quoted 114 lines
Quoted 19 lines
Quoted 19 lines
Application cannot know the resolution change in the QBUF ioctl. Driver will return 0 at the QBUF because all parameters are fine. But after sending the decode command to MFC H/W, driver can know that the
I-frame needs to change resolution.
In that case driver can return error at the DQBUF of the buffer.In the sequence 2, application can know the resolution change in the DQBUF(1).
So the application should re-QBUF the buffer 2, 3 after Sequence 1. It is hard to re-control the buffers which are already queued in the point
of application.
Because in the reqbufs(0) buffers will be freed.
So application has to copy them to the temporary buffer to re-QBUF after
Sequence 1.Quoted 4 lines
Quoted 1 line
How can we solve this case ?
There are two buffer queues - the OUTPUT is the queue for the compressed source. I don't see the need to do anything with this queue when
resolution
Quoted 3 lines
is changed.
There could be 3 src buffers queued for example. Let's say the first is
an
Quoted 2 lines
I-frame
with changed resolution. This does not affect the following sourcebuffers.
Quoted 4 lines
I
agree with you that it will have impact on the destination (CAPTURE) buffers.
The problem is how to notify the application that the resolution hasbeen
Quoted 5 lines
changed.
After the application is notified by the driver that resolution has been changed it has to do the following:
1. DQBUF all the remaining destination CAPTURE buffers (with oldresolution)
Quoted 13 lines
2. Do stream off on CAPUTRE
3. unmap all the CAPTURE buffers
4. REQBUFS(0) on CAPTURE
5.G_FMTon CAPTURE to get the new resolution
6. REQBUFS(n) on CAPTURE
7. mmap the CAPTURE buffers
8. QBUF all the new CAPTURE buffers
9. Do stream on on CAPTUREAs you can see, the OUTPUT queue has not been modified. All the 3 source buffers
are still queued until after step 9 when the processing restarts.Quoted 8 lines
From the driver perspective it looks like this:
a) After it has receivedDISP_STATUS[5:4] != 0 it sends theFRAME_START_REALLOC
command. Then it behave the same as if the stream was finished - runningFRAME_START
and returning the remaining buffers. This is the step 1 for application described above.
b) When no more buffers are left (DISP_STATUS[2:0]= 3) it has to notifythe
Quoted 3 lines
application
that the resolution have changed. I will discuss how to do it below.
c) The application was notified and completed steps 2-4, at this timethe
Quoted 5 lines
driver has to
reinitialize the stream. Here it will use the source buffer that had resolution change
again with commandINIT_CODEC.
d) The instance is reinitialized, and new resolution is read from MFC.The
Quoted 7 lines
application now
completes steps 5-9.
e) As destination (CAPTURE) buffers are now queued the driver continues decoding.FRAME_STARTcommand is issued for the source buffer that had resolution change and it is
decoded. This is the place when this source buffer is marked as done andit
Quoted 4 lines
can be dequeued
by the application.As you can see - there was no need to reinitialize the OUTPUT queue.
Only
Quoted 4 lines
CAPTURE, so there
is no need to restrict number of source (OUTPUT) buffers to 1.The question is how to notify the application. I think I could be done
same
Quoted 3 lines
as end of stream
notification - by returning a buffer with size equal to 0. If the application knows that source stream has ended, and queued asource
Quoted 4 lines
buffer of size 0
to notify the driver - then a destination buffer of size 0 means that decoding is finished.
In case of resolution change the application still has source buffersqueued
Quoted 2 lines
and it receives
a destination buffer with size=0. Knowing this the application can dothe
Quoted 10 lines
resolution change
procedure.I welcome your comments.
Best regards,
--
Kamil Debski
Linux Platform Group
Samsung Poland R&D Center
RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driver
Hi,
I don't see the need to do DQBUF on the source buffer that has the I-frame with changed resolution. I think that one could notify the application by setting size=0 on the CAPTURE buffer. So the OUTPUT buffer would not be dequeued. It would be dequeued after it has been decoded. Do you think anything is wrong with this approach?
I really think that copying the source buffer contents is unnecessary.
Best wishes,
--
Kamil Debski
Linux Platform Group
Samsung Poland R&D Center
Quoted 374 lines
-----Original Message-----
From: Jaeryul Oh [mailto:[email protected]]
Sent: 14 January 2011 19:21
To: 'Jonghun Han'; 'Kamil Debski'; [email protected]; linux- [email protected]
Cc: 'Marek Szyprowski'; [email protected]; [email protected]; [email protected]
Subject: RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driverI added my comments.
I guess that Kamil's way could be possible to run seq. of dynamic resolution
change.Quoted 10 lines
-----Original Message-----
From: Jonghun Han [mailto:[email protected]]
Sent: Friday, January 14, 2011 6:45 PM
To: 'Kamil Debski'; [email protected]; linux-samsung- [email protected]
Cc: 'Marek Szyprowski'; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driverQuoted 6 lines
Hi,
I was confused the source and destination. I agree with you mostly.
In my opinion, the way how to notify the resolution change is return
value
Quoted 4 lines
of the DQBUF.
But if we use DQBUF, there are some problem as below.DQBUF means that the buffer has been operated already and application
will
Quoted 25 lines
have the buffer's right.
Although application new QBUF destination buffers after changing destination(CAPTURE),
driver cannot re-decode the I-frame which has the resolution change information
because the I-frame has been dequeued already.
If application re-QBUF the buffer, the buffer sequence will be out of order
as below.
Original: I -> B -> B .....
Out of order: missed -> B -> B -> I .....How do you think about the following sequence.
1. getting the resolution change from the MFC H/W
2. copy the buffer to driver's internal memory.
3. send the result with DQBUF
4. changing destination buffers by application
5. QBUF for new destination buffers
Quoted 7 lines
6. in the first
vb2_try_schedule
re-decode the driver's internal buffer instead of the B frame.7. in the next
vb2_try_schedule
decode the B frame in order.I also welcome your comments.
In the blocking sequence, blocking will be done in DQBUF.
1. QBUF done for I1 frame with hdr(first buf, res. chd)
: Copy I1 frame in the driver
2. DQBUF done for I1 frame
3. QBUF P2,P3,P4 frame, but it should NOT be DEQUED which means Qbufed p2,p3,p4 is not executed
: P4(third buf) -> P3(second buf) -> P2 frame(first buf)
4. While waiting for DEQUE about P2, copied I1 frame is executed forINIT_CODEC
5. Copied I1 frame is runnedFRAME_STARTafter dst buffer is
reallocated(5~9 in your seq.)6. Queued P2 frame is executed, then DQBUF will be OK
Quoted 27 lines
Best regards,
Quoted 24 lines
-----Original Message-----
From: Kamil Debski [mailto:[email protected]]
Sent: Friday, January 14, 2011 4:24 PM
To: 'Jonghun Han'; [email protected]; linux-samsung- [email protected]
Cc: Marek Szyprowski; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driverHi,
Quoted 13 lines
-----Original Message-----
From: Jonghun Han [mailto:[email protected]]Hi,
Kamil Debski wrote:
<snip>
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 3 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +3
-0+/* Reqeust buffers */ +static int vidioc_reqbufs (struct file *file,void *priv, + struct v4l2_requestbuffers*reqbufs)
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +6
-0+{ +struct s5p_mfc_dev *dev =video_drvdata (file); +struct s5p_mfc_ctx *ctx = priv; +int ret =0 ; +unsigned long flags; +Quoted 8 lines
Quoted 8 lines
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 8 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +8
-0+mfc_debug_enter (); +mfc_debug ("Memory type: %d\n" , reqbufs->memory); +if (reqbufs->memory !=V4L2_MEMORY_MMAP ) { +mfc_err ("Only V4L2_MEMORY_MAP is supported.\n" ); +return -EINVAL ; + } +if (reqbufs->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) { +/* Can only request buffers after an instance has been
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
opened.*/
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 4 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+if (ctx->state ==MFCINST_DEC_GOT_INST ) { +/* Decoding */ +if (ctx->output_state !=QUEUE_FREE ) { + mfc_err("Bufs have already beenrequested.\n");
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 5 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +5
-0+return -EINVAL ; + } + ret =vb2_reqbufs (&ctx->vq_src, reqbufs); +if (ret) { + mfc_err("vb2_reqbufs on outputfailed.\n");
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Review
Quoted 9 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +6
-0+return ret; + } +mfc_debug ("vb2_reqbufs: %d\n" , ret); + ctx->output_state =QUEUE_BUFS_REQUESTED ; + } + } else if (reqbufs->type ==
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {(quoted diff) +2
-0+ if (ctx->capture_state != QUEUE_FREE) { + mfc_err("Bufs have already beenrequested.\n");
Quoted 28 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+return -EINVAL ; + } + ctx->capture_state =QUEUE_BUFS_REQUESTED ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +if (ret) { +mfc_err ("vb2_reqbufs on capture failed.\n" ); +return ret; + } +if (reqbufs->count < ctx->dpb_count) { +mfc_err ("Not enough buffers allocated.\n" );Quoted 8 lines
Quoted 8 lines
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 8 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +8
-0+ reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +return -ENOMEM ; + } + ctx->total_dpb_count = reqbufs->count; + ret =s5p_mfc_alloc_dec_buffers (ctx); +if (ret) { + mfc_err("Failed to allocate decodingbuffers.\n");
Quoted 8 lines
Quoted 8 lines
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 8 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +8
-0+ reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +return -ENOMEM ; + } +if (ctx->dst_bufs_cnt == ctx->total_dpb_count) { + ctx->capture_state =QUEUE_BUFS_MMAPED ; + }else { + mfc_err("Not all buffers passed tobuf_init.\n");
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 9 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +9
-0+ reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +s5p_mfc_release_dec_buffers (ctx); +return -ENOMEM ; + } +if (s5p_mfc_ctx_ready (ctx)) { +spin_lock_irqsave (&dev->condlock, flags); +set_bit (ctx->num, &dev->ctx_work_bits); + spin_unlock_irqrestore(&dev->condlock,flags);
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/media/video/s5p-mfc/s5p_mfc.c line 466
Quoted 9 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+ } +s5p_mfc_try_run (dev); + s5p_mfc_wait_for_done_ctx(ctx, +
S5P_FIMV_R2H_CMD_INIT_BUFFERS_RET, 1);drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+ } +mfc_debug_leave (); +return ret; +}I don't know how to handle the followings.
Quoted 1 line
Quoted 1 line
Quoted 1 line
So I suggest that in
reqbufs->type==V4L2_BUF_TYPE_VIDEO_OUTPUTcase,
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
how about return
-EINVALifreqbufs->countis bigger than 1.Because if
reqbufs->countis bigger than 1, it is hard to handlethe
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
encoded
input stream.For example: Dynamic resolution change
Dynamic resolution change means that resolution can be changed atany
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
I-frame with header on the fly during streaming.
MFC H/W can detect it after getting decoding command from the
driver.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
If the dynamic resolution change is detected by MFC H/W, driver should let application know the fact to do the following Sequence 1
by application.Sequence 1:
streamoff -> munmap -> reqbufs(0) ->S_FMT(changed resolution)-> querybuf
-> mmap -> re-QBUF with the I-frame -> STREAMON -> ...Why it is hard to handle the encoded input stream in multiple
input
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
stream
case is the following Sequence 2.Sequence 2:
QBUF(0) -> QBUF(1: resolution changed I-frame) -> QBUF(2: already changed)
-> QBUF(3: already changed) -> DQBUF(0) -> DQBUF(1): return fail->
...Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Application cannot know the resolution change in the QBUF ioctl. Driver will return 0 at the QBUF because all parameters are fine. But after sending the decode command to MFC H/W, driver can know
that
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
the
I-frame needs to change resolution.
In that case driver can return error at the DQBUF of the buffer.In the sequence 2, application can know the resolution change in
the
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
DQBUF(1).
So the application should re-QBUF the buffer 2, 3 after Sequence1.
Quoted 1 line
Quoted 1 line
Quoted 1 line
It is hard to re-control the buffers which are already queued in
the
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
point
of application.
Because in the reqbufs(0) buffers will be freed.
So application has to copy them to the temporary buffer to re-QBUF
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
after
Sequence 1.How can we solve this case ?
There are two buffer queues - the OUTPUT is the queue for the
compressed
Quoted 5 lines
Quoted 1 line
source. I don't see the need to do anything with this queue when
resolution
Quoted 3 lines
is changed.
There could be 3 src buffers queued for example. Let's say the
first is
Quoted 6 lines
an
Quoted 2 lines
I-frame
with changed resolution. This does not affect the following sourcebuffers.
Quoted 2 lines
I
agree with you that it will have impact on the destination(CAPTURE)
Quoted 2 lines
Quoted 2 lines
buffers.
The problem is how to notify the application that the resolutionhas
Quoted 4 lines
been
Quoted 3 lines
changed.
After the application is notified by the driver that resolution has
been
Quoted 13 lines
Quoted 2 lines
changed it has to do the following:
1. DQBUF all the remaining destination CAPTURE buffers (with oldresolution)
Quoted 10 lines
2. Do stream off on CAPUTRE
3. unmap all the CAPTURE buffers
4. REQBUFS(0) on CAPTURE
5.G_FMTon CAPTURE to get the new resolution
6. REQBUFS(n) on CAPTURE
7. mmap the CAPTURE buffers
8. QBUF all the new CAPTURE buffers
9. Do stream on on CAPTUREAs you can see, the OUTPUT queue has not been modified. All the 3
source
Quoted 7 lines
Quoted 7 lines
buffers
are still queued until after step 9 when the processing restarts.From the driver perspective it looks like this:
a) After it has receivedDISP_STATUS[5:4] != 0 it sends theFRAME_START_REALLOC
command. Then it behave the same as if the stream was finished -running
Quoted 2 lines
Quoted 2 lines
FRAME_START
and returning the remaining buffers. This is the step 1 forapplication
Quoted 2 lines
Quoted 2 lines
described above.
b) When no more buffers are left (DISP_STATUS[2:0]= 3) it has tonotify
Quoted 3 lines
the
Quoted 2 lines
application
that the resolution have changed. I will discuss how to do itbelow.
Quoted 1 line
Quoted 1 line
c) The application was notified and completed steps 2-4, at this
time
Quoted 3 lines
the
Quoted 2 lines
driver has to
reinitialize the stream. Here it will use the source buffer thathad
Quoted 3 lines
Quoted 3 lines
resolution change
again with commandINIT_CODEC.
d) The instance is reinitialized, and new resolution is read fromMFC.
Quoted 4 lines
The
Quoted 3 lines
application now
completes steps 5-9.
e) As destination (CAPTURE) buffers are now queued the drivercontinues
Quoted 2 lines
Quoted 2 lines
decoding.
FRAME_STARTcommand is issued for the source buffer that hadresolution
Quoted 2 lines
Quoted 2 lines
change and it is
decoded. This is the place when this source buffer is marked asdone and
Quoted 5 lines
it
Quoted 4 lines
can be dequeued
by the application.As you can see - there was no need to reinitialize the OUTPUT
queue.
Quoted 5 lines
Only
Quoted 4 lines
CAPTURE, so there
is no need to restrict number of source (OUTPUT) buffers to 1.The question is how to notify the application. I think I could be
done
Quoted 7 lines
same
Quoted 3 lines
as end of stream
notification - by returning a buffer with size equal to 0. If the application knows that source stream has ended, and queued asource
Quoted 2 lines
buffer of size 0
to notify the driver - then a destination buffer of size 0 meansthat
Quoted 2 lines
Quoted 2 lines
decoding is finished.
In case of resolution change the application still has sourcebuffers
Quoted 3 lines
queued
Quoted 2 lines
and it receives
a destination buffer with size=0. Knowing this the application cando
Quoted 11 lines
the
Quoted 10 lines
resolution change
procedure.I welcome your comments.
Best regards,
--
Kamil Debski
Linux Platform Group
Samsung Poland R&D Center
RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driver
Commented as belows.
Quoted 11 lines
-----Original Message-----
From: Kamil Debski [mailto:[email protected]]
Sent: Monday, January 17, 2011 1:59 PM
To: [email protected]; 'Jonghun Han'; [email protected]; [email protected]
Cc: 'Marek Szyprowski'; [email protected]; [email protected]; [email protected]
Subject: RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driverHi,
Quoted 8 lines
I don't see the need to do DQBUF on the source buffer that has the I-frame with changed resolution. I think that one could notify the application by setting size=0 on the CAPTURE buffer. So the OUTPUT buffer would not be dequeued. It would be dequeued after it has been decoded. Do you think anything is wrong with this approach?
I really think that copying the source buffer contents is unnecessary.
I just thought of this based on current driver sequence. Without copy for I frame(resolution changed frame), it could be possible, but we need smart driver
control for this situation(res. change).
So, one time queued, three times should be used
: recognition for res. changed / header parsing / I frame decoding
Quoted 380 lines
Best wishes,
--
Kamil Debski
Linux Platform Group
Samsung Poland R&D CenterQuoted 374 lines
-----Original Message-----
From: Jaeryul Oh [mailto:[email protected]]
Sent: 14 January 2011 19:21
To: 'Jonghun Han'; 'Kamil Debski'; [email protected]; linux- [email protected]
Cc: 'Marek Szyprowski'; [email protected]; [email protected]; [email protected]
Subject: RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driverI added my comments.
I guess that Kamil's way could be possible to run seq. of dynamic resolution
change.Quoted 10 lines
-----Original Message-----
From: Jonghun Han [mailto:[email protected]]
Sent: Friday, January 14, 2011 6:45 PM
To: 'Kamil Debski'; [email protected]; linux-samsung- [email protected]
Cc: 'Marek Szyprowski'; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driverQuoted 6 lines
Hi,
I was confused the source and destination. I agree with you mostly.
In my opinion, the way how to notify the resolution change is return
value
Quoted 4 lines
of the DQBUF.
But if we use DQBUF, there are some problem as below.DQBUF means that the buffer has been operated already and application
will
Quoted 25 lines
have the buffer's right.
Although application new QBUF destination buffers after changing destination(CAPTURE),
driver cannot re-decode the I-frame which has the resolution change information
because the I-frame has been dequeued already.
If application re-QBUF the buffer, the buffer sequence will be out of order
as below.
Original: I -> B -> B .....
Out of order: missed -> B -> B -> I .....How do you think about the following sequence.
1. getting the resolution change from the MFC H/W
2. copy the buffer to driver's internal memory.
3. send the result with DQBUF
4. changing destination buffers by application
5. QBUF for new destination buffers
Quoted 7 lines
6. in the first
vb2_try_schedule
re-decode the driver's internal buffer instead of the B frame.7. in the next
vb2_try_schedule
decode the B frame in order.I also welcome your comments.
In the blocking sequence, blocking will be done in DQBUF.
1. QBUF done for I1 frame with hdr(first buf, res. chd)
: Copy I1 frame in the driver
2. DQBUF done for I1 frame
3. QBUF P2,P3,P4 frame, but it should NOT be DEQUED which means Qbufed p2,p3,p4 is not executed
: P4(third buf) -> P3(second buf) -> P2 frame(first buf)
4. While waiting for DEQUE about P2, copied I1 frame is executed forINIT_CODEC
5. Copied I1 frame is runnedFRAME_STARTafter dst buffer is
reallocated(5~9 in your seq.)6. Queued P2 frame is executed, then DQBUF will be OK
Quoted 27 lines
Best regards,
Quoted 24 lines
-----Original Message-----
From: Kamil Debski [mailto:[email protected]]
Sent: Friday, January 14, 2011 4:24 PM
To: 'Jonghun Han'; [email protected]; linux-samsung- [email protected]
Cc: Marek Szyprowski; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driverHi,
Quoted 13 lines
-----Original Message-----
From: Jonghun Han [mailto:[email protected]]Hi,
Kamil Debski wrote:
<snip>
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 3 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +3
-0+/* Reqeust buffers */ +static int vidioc_reqbufs (struct file *file,void *priv, + struct v4l2_requestbuffers*reqbufs)
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +6
-0+{ +struct s5p_mfc_dev *dev =video_drvdata (file); +struct s5p_mfc_ctx *ctx = priv; +int ret =0 ; +unsigned long flags; +Quoted 8 lines
Quoted 8 lines
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 8 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +8
-0+mfc_debug_enter (); +mfc_debug ("Memory type: %d\n" , reqbufs->memory); +if (reqbufs->memory !=V4L2_MEMORY_MMAP ) { +mfc_err ("Only V4L2_MEMORY_MAP is supported.\n" ); +return -EINVAL ; + } +if (reqbufs->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) { +/* Can only request buffers after an instance has been
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
opened.*/
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 4 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+if (ctx->state ==MFCINST_DEC_GOT_INST ) { +/* Decoding */ +if (ctx->output_state !=QUEUE_FREE ) { + mfc_err("Bufs have already beenrequested.\n");
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 5 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +5
-0+return -EINVAL ; + } + ret =vb2_reqbufs (&ctx->vq_src, reqbufs); +if (ret) { + mfc_err("vb2_reqbufs on outputfailed.\n");
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Review
Quoted 9 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +6
-0+return ret; + } +mfc_debug ("vb2_reqbufs: %d\n" , ret); + ctx->output_state =QUEUE_BUFS_REQUESTED ; + } + } else if (reqbufs->type ==
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {(quoted diff) +2
-0+ if (ctx->capture_state != QUEUE_FREE) { + mfc_err("Bufs have already beenrequested.\n");
Quoted 28 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+return -EINVAL ; + } + ctx->capture_state =QUEUE_BUFS_REQUESTED ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +if (ret) { +mfc_err ("vb2_reqbufs on capture failed.\n" ); +return ret; + } +if (reqbufs->count < ctx->dpb_count) { +mfc_err ("Not enough buffers allocated.\n" );Quoted 8 lines
Quoted 8 lines
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 8 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +8
-0+ reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +return -ENOMEM ; + } + ctx->total_dpb_count = reqbufs->count; + ret =s5p_mfc_alloc_dec_buffers (ctx); +if (ret) { + mfc_err("Failed to allocate decodingbuffers.\n");
Quoted 8 lines
Quoted 8 lines
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 8 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +8
-0+ reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +return -ENOMEM ; + } +if (ctx->dst_bufs_cnt == ctx->total_dpb_count) { + ctx->capture_state =QUEUE_BUFS_MMAPED ; + }else { + mfc_err("Not all buffers passed tobuf_init.\n");
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 9 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +9
-0+ reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +s5p_mfc_release_dec_buffers (ctx); +return -ENOMEM ; + } +if (s5p_mfc_ctx_ready (ctx)) { +spin_lock_irqsave (&dev->condlock, flags); +set_bit (ctx->num, &dev->ctx_work_bits); + spin_unlock_irqrestore(&dev->condlock,flags);
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/media/video/s5p-mfc/s5p_mfc.c line 466
Quoted 9 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+ } +s5p_mfc_try_run (dev); + s5p_mfc_wait_for_done_ctx(ctx, +
S5P_FIMV_R2H_CMD_INIT_BUFFERS_RET, 1);drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+ } +mfc_debug_leave (); +return ret; +}I don't know how to handle the followings.
Quoted 1 line
Quoted 1 line
Quoted 1 line
So I suggest that in
reqbufs->type==V4L2_BUF_TYPE_VIDEO_OUTPUTcase,
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
how about return
-EINVALifreqbufs->countis bigger than 1.Because if
reqbufs->countis bigger than 1, it is hard to handlethe
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
encoded
input stream.For example: Dynamic resolution change
Dynamic resolution change means that resolution can be changed atany
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
I-frame with header on the fly during streaming.
MFC H/W can detect it after getting decoding command from the
driver.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
If the dynamic resolution change is detected by MFC H/W, driver should let application know the fact to do the following Sequence 1
by application.Sequence 1:
streamoff -> munmap -> reqbufs(0) ->S_FMT(changed resolution)-> querybuf
-> mmap -> re-QBUF with the I-frame -> STREAMON -> ...Why it is hard to handle the encoded input stream in multiple
input
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
stream
case is the following Sequence 2.Sequence 2:
QBUF(0) -> QBUF(1: resolution changed I-frame) -> QBUF(2: already changed)
-> QBUF(3: already changed) -> DQBUF(0) -> DQBUF(1): return fail->
...Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Application cannot know the resolution change in the QBUF ioctl. Driver will return 0 at the QBUF because all parameters are fine. But after sending the decode command to MFC H/W, driver can know
that
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
the
I-frame needs to change resolution.
In that case driver can return error at the DQBUF of the buffer.In the sequence 2, application can know the resolution change in
the
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
DQBUF(1).
So the application should re-QBUF the buffer 2, 3 after Sequence1.
Quoted 1 line
Quoted 1 line
Quoted 1 line
It is hard to re-control the buffers which are already queued in
the
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
point
of application.
Because in the reqbufs(0) buffers will be freed.
So application has to copy them to the temporary buffer to re-QBUF
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
after
Sequence 1.How can we solve this case ?
There are two buffer queues - the OUTPUT is the queue for the
compressed
Quoted 5 lines
Quoted 1 line
source. I don't see the need to do anything with this queue when
resolution
Quoted 3 lines
is changed.
There could be 3 src buffers queued for example. Let's say the
first is
Quoted 6 lines
an
Quoted 2 lines
I-frame
with changed resolution. This does not affect the following sourcebuffers.
Quoted 2 lines
I
agree with you that it will have impact on the destination(CAPTURE)
Quoted 2 lines
Quoted 2 lines
buffers.
The problem is how to notify the application that the resolutionhas
Quoted 4 lines
been
Quoted 3 lines
changed.
After the application is notified by the driver that resolution has
been
Quoted 13 lines
Quoted 2 lines
changed it has to do the following:
1. DQBUF all the remaining destination CAPTURE buffers (with oldresolution)
Quoted 10 lines
2. Do stream off on CAPUTRE
3. unmap all the CAPTURE buffers
4. REQBUFS(0) on CAPTURE
5.G_FMTon CAPTURE to get the new resolution
6. REQBUFS(n) on CAPTURE
7. mmap the CAPTURE buffers
8. QBUF all the new CAPTURE buffers
9. Do stream on on CAPTUREAs you can see, the OUTPUT queue has not been modified. All the 3
source
Quoted 7 lines
Quoted 7 lines
buffers
are still queued until after step 9 when the processing restarts.From the driver perspective it looks like this:
a) After it has receivedDISP_STATUS[5:4] != 0 it sends theFRAME_START_REALLOC
command. Then it behave the same as if the stream was finished -running
Quoted 2 lines
Quoted 2 lines
FRAME_START
and returning the remaining buffers. This is the step 1 forapplication
Quoted 2 lines
Quoted 2 lines
described above.
b) When no more buffers are left (DISP_STATUS[2:0]= 3) it has tonotify
Quoted 3 lines
the
Quoted 2 lines
application
that the resolution have changed. I will discuss how to do itbelow.
Quoted 1 line
Quoted 1 line
c) The application was notified and completed steps 2-4, at this
time
Quoted 3 lines
the
Quoted 2 lines
driver has to
reinitialize the stream. Here it will use the source buffer thathad
Quoted 3 lines
Quoted 3 lines
resolution change
again with commandINIT_CODEC.
d) The instance is reinitialized, and new resolution is read fromMFC.
Quoted 4 lines
The
Quoted 3 lines
application now
completes steps 5-9.
e) As destination (CAPTURE) buffers are now queued the drivercontinues
Quoted 2 lines
Quoted 2 lines
decoding.
FRAME_STARTcommand is issued for the source buffer that hadresolution
Quoted 2 lines
Quoted 2 lines
change and it is
decoded. This is the place when this source buffer is marked asdone and
Quoted 5 lines
it
Quoted 4 lines
can be dequeued
by the application.As you can see - there was no need to reinitialize the OUTPUT
queue.
Quoted 5 lines
Only
Quoted 4 lines
CAPTURE, so there
is no need to restrict number of source (OUTPUT) buffers to 1.The question is how to notify the application. I think I could be
done
Quoted 7 lines
same
Quoted 3 lines
as end of stream
notification - by returning a buffer with size equal to 0. If the application knows that source stream has ended, and queued asource
Quoted 2 lines
buffer of size 0
to notify the driver - then a destination buffer of size 0 meansthat
Quoted 2 lines
Quoted 2 lines
decoding is finished.
In case of resolution change the application still has sourcebuffers
Quoted 3 lines
queued
Quoted 2 lines
and it receives
a destination buffer with size=0. Knowing this the application cando
Quoted 11 lines
the
Quoted 10 lines
resolution change
procedure.I welcome your comments.
Best regards,
--
Kamil Debski
Linux Platform Group
Samsung Poland R&D Center
RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driver
In reply to Kamil DebskiHi, Kamil
I have a comment about s5p_mfc_stop_streaming()function.
Quoted 150 lines
-----Original Message-----
From: [email protected] [mailto:linux-media- [email protected]] On Behalf Of Kamil Debski
Sent: Saturday, January 08, 2011 1:26 AM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driverMulti Format Codec 5.1 is capable of handling a range of video codecs and this driver provides V4L2 interface for video decoding.
Signed-off-by Kamil Debski <[email protected]>Signed-off-by Kyungmin Park <[email protected]>--- drivers/media/video/Kconfig | 8 + drivers/media/video/Makefile | 1 + drivers/media/video/s5p-mfc/Makefile | 3 + drivers/media/video/s5p-mfc/regs-mfc5.h | 335 +++++ drivers/media/video/s5p-mfc/s5p_mfc.c | 2072 ++++++++++++++++++++++++++ drivers/media/video/s5p-mfc/s5p_mfc_common.h | 224 +++ drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h | 173 +++ drivers/media/video/s5p-mfc/s5p_mfc_debug.h | 47 + drivers/media/video/s5p-mfc/s5p_mfc_intr.c | 92 ++ drivers/media/video/s5p-mfc/s5p_mfc_intr.h | 26 + drivers/media/video/s5p-mfc/s5p_mfc_memory.h | 43 + drivers/media/video/s5p-mfc/s5p_mfc_opr.c | 885 +++++++++++ drivers/media/video/s5p-mfc/s5p_mfc_opr.h | 160 ++ 13 files changed, 4069 insertions(+), 0 deletions(-) create mode 100644 drivers/media/video/s5p-mfc/Makefile create mode 100644 drivers/media/video/s5p-mfc/regs-mfc5.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_common.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_debug.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_intr.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_intr.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_memory.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_opr.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_opr.hdrivers/media/video/Kconfig +8
-0@@ -1035,4 +1035,12 @@ config VIDEO_SAMSUNG_S5P_FIMC This is a v4l2 driver for the S5P camera interface (video postprocessor) +config VIDEO_SAMSUNG_S5P_MFC + tristate "Samsung S5P MFC 5.1 Video Codec" + depends on VIDEO_V4L2 && CMA + select VIDEOBUF2_CMA + default n + help + MFC 5.1 driver for V4L2. + endif # V4L_MEM2MEM_DRIVERSdrivers/media/video/Makefile +0
-0@@ -172,6 +172,7 @@ obj-$(CONFIG_VIDEO_SH_MOBILE_CSI2) +=sh_mobile_csi2.o
obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o
obj-$(CONFIG_VIDEO_OMAP1) += omap1_camera.o
obj-$(CONFIG_VIDEO_SAMSUNG_S5P_FIMC) += s5p-fimc/drivers/media/video/Makefile +1
-0+obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC) += s5p-mfc/ obj-$(CONFIG_ARCH_DAVINCI) += davinci/drivers/media/video/s5p-mfc/Makefile new file +3
-0@@ -0,0 +1,3 @@ +obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC) := s5p-mfc.o +s5p-mfc-y := s5p_mfc.o s5p_mfc_intr.o s5p_mfc_opr.o +drivers/media/video/s5p-mfc/regs-mfc5.h new file +17
-0@@ -0,0 +1,335 @@ +/* +* +* Register definition file for Samsung MFC V5.1 Interface (FIMV) driver +* +* Kamil Debski, Copyright (c) 2010 Samsung Electronics +* http://www.samsung.com/ +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef _REGS_FIMV_H +#define _REGS_FIMV_H + +#define S5P_FIMV_REG_SIZE (S5P_FIMV_END_ADDR - S5P_FIMV_START_ADDR) +#define S5P_FIMV_REG_COUNT ((S5P_FIMV_END_ADDR -
S5P_FIMV_START_ADDR) / 4)drivers/media/video/s5p-mfc/regs-mfc5.h new file +2
-0+ +/* Number of bits that the buffer address should be shifted for particular
+ * MFC buffers. */drivers/media/video/s5p-mfc/regs-mfc5.h new file +39
-0+#define S5P_FIMV_MEM_OFFSET 11 + +#define S5P_FIMV_START_ADDR 0x0000 +#define S5P_FIMV_END_ADDR 0xe008 + +#define S5P_FIMV_SW_RESET 0x0000 +#define S5P_FIMV_RISC_HOST_INT 0x0008 +/* Command from HOST to RISC */ +#define S5P_FIMV_HOST2RISC_CMD 0x0030 +#define S5P_FIMV_HOST2RISC_ARG1 0x0034 +#define S5P_FIMV_HOST2RISC_ARG2 0x0038 +#define S5P_FIMV_HOST2RISC_ARG3 0x003c +#define S5P_FIMV_HOST2RISC_ARG4 0x0040 +/* Command from RISC to HOST */ +#define S5P_FIMV_RISC2HOST_CMD 0x0044 +#define S5P_FIMV_RISC2HOST_ARG1 0x0048 +#define S5P_FIMV_RISC2HOST_ARG2 0x004c +#define S5P_FIMV_RISC2HOST_ARG3 0x0050 +#define S5P_FIMV_RISC2HOST_ARG4 0x0054 + +#define S5P_FIMV_FW_VERSION 0x0058 +#define S5P_FIMV_FW_Y_SHIFT 16 +#define S5P_FIMV_FW_M_SHIFT 8 +#define S5P_FIMV_FW_D_SHIFT 0 +#define S5P_FIMV_FW_MASK 0xff + +#define S5P_FIMV_SYS_MEM_SZ 0x005c +#define S5P_FIMV_FW_STATUS 0x0080 +/* Memory controller register */ +#define S5P_FIMV_MC_DRAMBASE_ADR_A 0x0508 +#define S5P_FIMV_MC_DRAMBASE_ADR_B 0x050c +#define S5P_FIMV_MC_STATUS 0x0510 + +/* Common register */ +#define S5P_FIMV_SYS_MEM_ADR 0x0600/* firmware buffer */ +#define S5P_FIMV_CPB_BUF_ADR 0x0604/* stream buffer */ +#define S5P_FIMV_DESC_BUF_ADR 0x0608/* descriptor buffer */ +/* H264 decoding */ +#define S5P_FIMV_VERT_NB_MV_ADR 0x068c/* vertical neighbor motion
Quoted 2 lines
vector */
+#defineS5P_FIMV_VERT_NB_IP_ADR0x0690/* neighbor pixels for intra
pred
drivers/media/video/s5p-mfc/regs-mfc5.h
Quoted 4 lines
*/
drivers/media/video/s5p-mfc/regs-mfc5.h new file +3
-0+#define S5P_FIMV_H264_LUMA_ADR 0x0700/* Luma0 ~ Luma18 */ +#define S5P_FIMV_H264_CHROMA_ADR 0x0600/* Chroma0 ~ Chroma18 */ +#define S5P_FIMV_MV_ADR 0x0780/* H264 motion vector 660
780 */
Quoted 4 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +2
-0+/* H263/MPEG4/MPEG2/VC-1/ decoding */ +#define S5P_FIMV_NB_DCAC_ADR 0x068c/* neighbor AC/DC coeff. buffer */
+#defineS5P_FIMV_UP_NB_MV_ADR0x0690/* upper neighbor motion
vector
drivers/media/video/s5p-mfc/regs-mfc5.h
Quoted 13 lines
buffer */
+#defineS5P_FIMV_SA_MV_ADR0x0694/* subseq. anchor motion vector
buffer */
+#defineS5P_FIMV_OT_LINE_ADR0x0698/* overlap transform line buffer
*/drivers/media/video/s5p-mfc/regs-mfc5.h new file +8
-0+#define S5P_FIMV_BITPLANE3_ADR 0x069C/* bitplane3 addr */ +#define S5P_FIMV_BITPLANE2_ADR 0x06A0/* bitplane2 addr */ +#define S5P_FIMV_BITPLANE1_ADR 0x06A4/* bitplane1 addr */ +#define S5P_FIMV_SP_ADR 0x06A8/* syntax parser addr */ +#define S5P_FIMV_LUMA_ADR 0x0700/* Luma0 ~ Luma5 */ +#define S5P_FIMV_CHROMA_ADR 0x0600/* Chroma0 ~ Chroma5 */ +/* Encoder register */ +#define S5P_FIMV_ENC_UP_MV_ADR 0x0600/* upper motion
vector addr
drivers/media/video/s5p-mfc/regs-mfc5.h
Quoted 5 lines
*/
+#defineS5P_FIMV_ENC_COZERO_FLAG_ADR0x0610/* direct cozero flag addr
*/drivers/media/video/s5p-mfc/regs-mfc5.h new file +2
-0+#define S5P_FIMV_ENC_UP_INTRA_MD_ADR 0x0608/* upper intra MD addr */ +#define S5P_FIMV_ENC_UP_INTRA_PRED_ADR 0x0740/* upper intra PRED
addr */
Quoted 8 lines
+#define
S5P_FIMV_ENC_NB_DCAC_ADR0x0604/* entropy engine's
neighbordrivers/media/video/s5p-mfc/regs-mfc5.h new file +6
-0+inform and AC/DC coeff. */ + +#define S5P_FIMV_ENC_CUR_LUMA_ADR 0x0718/* current Luma addr */ +#define S5P_FIMV_ENC_CUR_CHROMA_ADR 0x071C/* current Chroma addr */ + +#define S5P_FIMV_ENC_REF0_LUMA_ADR 0x061c/* ref0 Luma addr */
drivers/media/video/s5p-mfc/regs-mfc5.h
Quoted 10 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +10
-0+#define S5P_FIMV_ENC_REF0_CHROMA_ADR 0x0700/* ref0 Chroma addr */ +#define S5P_FIMV_ENC_REF1_LUMA_ADR 0x0620/* ref1 Luma addr */ +#define S5P_FIMV_ENC_REF1_CHROMA_ADR 0x0704/* ref1 Chroma addr */ +#define S5P_FIMV_ENC_REF2_LUMA_ADR 0x0710/* ref2 Luma addr */ +#define S5P_FIMV_ENC_REF2_CHROMA_ADR 0x0708/* ref2 Chroma addr */ +#define S5P_FIMV_ENC_REF3_LUMA_ADR 0x0714/* ref3 Luma addr */ +#define S5P_FIMV_ENC_REF3_CHROMA_ADR 0x070c/* ref3 Chroma addr */ + +/* Codec common register */ +#define S5P_FIMV_ENC_HSIZE_PX 0x0818/* frame width at
encoder
Quoted 2 lines
*/
+#defineS5P_FIMV_ENC_VSIZE_PX0x081c/* frame height at
encoder
drivers/media/video/s5p-mfc/regs-mfc5.h
Quoted 3 lines
*/
drivers/media/video/s5p-mfc/regs-mfc5.h new file +2
-0+#define S5P_FIMV_ENC_PROFILE 0x0830/* profile register */ +#define S5P_FIMV_ENC_PIC_STRUCT 0x083c/* picture
field/frame flag
drivers/media/video/s5p-mfc/regs-mfc5.h
Quoted 3 lines
*/
drivers/media/video/s5p-mfc/regs-mfc5.h new file +2
-0+#define S5P_FIMV_ENC_LF_CTRL 0x0848/* loop filter control */ +#define S5P_FIMV_ENC_ALPHA_OFF 0x084c/* loop filter alpha
offset
Quoted 2 lines
*/
+#defineS5P_FIMV_ENC_BETA_OFF0x0850/* loop filter beta
offset
Quoted 2 lines
*/
+#defineS5P_FIMV_MR_BUSIF_CTRL0x0854/* hidden, bus
interface
Quoted 21 lines
ctrl */
drivers/media/video/s5p-mfc/regs-mfc5.h new file +4
-0+#define S5P_FIMV_ENC_PXL_CACHE_CTRL 0x0a00/* pixel cache control */ + +/* Channel & stream interface register */ +#define S5P_FIMV_SI_RTN_CHID 0x2000/* Return CH instance ID register */
drivers/media/video/s5p-mfc/regs-mfc5.h new file +4
-0+#define S5P_FIMV_SI_CH0_INST_ID 0x2040/* codec instance ID */ +#define S5P_FIMV_SI_CH1_INST_ID 0x2080/* codec instance ID */ +/* Decoder */ +#define S5P_FIMV_SI_VRESOL 0x2004/* vertical resolution of decoder */
+#defineS5P_FIMV_SI_HRESOL0x2008/* horizontal resolution of
decoder */
+#defineS5P_FIMV_SI_BUF_NUMBER0x200c/* number of frames in the
decoded pic */
+#defineS5P_FIMV_SI_DISPLAY_Y_ADR0x2010/* luma address of displayed pic */
+#defineS5P_FIMV_SI_DISPLAY_C_ADR0x2014/* chroma address of displayed pic */
+#defineS5P_FIMV_SI_CONSUMED_BYTES0x2018/* Consumed number of bytes to decode
drivers/media/video/s5p-mfc/regs-mfc5.h
Quoted 3 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +3
-0+a frame */ +#define S5P_FIMV_SI_DISPLAY_STATUS 0x201c/* status of decoded picture */ +#define S5P_FIMV_SI_FRAME_TYPE 0x2020/* frame type such as
skip/I/P/B
Quoted 88 lines
*/
drivers/media/video/s5p-mfc/regs-mfc5.h new file +2
-0+ +#define S5P_FIMV_SI_CH0_SB_ST_ADR 0x2044/* start addr of stream buf */
drivers/media/video/s5p-mfc/regs-mfc5.h new file +2
-0+#define S5P_FIMV_SI_CH0_SB_FRM_SIZE 0x2048/* size of stream buf */ +#define S5P_FIMV_SI_CH0_DESC_ADR 0x204c/* addr of descriptor buf */
+#defineS5P_FIMV_SI_CH0_CPB_SIZE0x2058/* max size of coded pic.
buf */
+#defineS5P_FIMV_SI_CH0_DESC_SIZE0x205c/* max size of descriptor
buf */drivers/media/video/s5p-mfc/regs-mfc5.h new file +2
-0+ +#define S5P_FIMV_SI_CH1_SB_ST_ADR 0x2084/* start addr of stream buf */
drivers/media/video/s5p-mfc/regs-mfc5.h new file +2
-0+#define S5P_FIMV_SI_CH1_SB_FRM_SIZE 0x2088/* size of stream buf */ +#define S5P_FIMV_SI_CH1_DESC_ADR 0x208c/* addr of descriptor buf */
+#defineS5P_FIMV_SI_CH1_CPB_SIZE0x2098/* max size of coded pic.
buf */
+#defineS5P_FIMV_SI_CH1_DESC_SIZE0x209c/* max size of descriptor
buf */drivers/media/video/s5p-mfc/regs-mfc5.h new file +4
-0+ +#define S5P_FIMV_SI_DIVX311_HRESOL 0x2054/* horizontal resolution */ +#define S5P_FIMV_SI_DIVX311_VRESOL 0x2050/* vertical resolution */ +#define S5P_FIMV_CRC_LUMA0 0x2030/* luma crc data per frame(top field)*/
+#defineS5P_FIMV_CRC_CHROMA00x2034/* chroma crc data per frame(top
field)*/
+#defineS5P_FIMV_CRC_LUMA10x2038/* luma crc data per bottom field
*/
+#defineS5P_FIMV_CRC_CHROMA10x203c/* chroma crc data per bottom
field */drivers/media/video/s5p-mfc/regs-mfc5.h new file +53
-0+ +/* Display status */ +#define S5P_FIMV_DEC_STATUS_DECODING_ONLY 0 +#define S5P_FIMV_DEC_STATUS_DECODING_DISPLAY 1 +#define S5P_FIMV_DEC_STATUS_DISPLAY_ONLY 2 +#define S5P_FIMV_DEC_STATUS_DECODING_EMPTY 3 +#define S5P_FIMV_DEC_STATUS_DECODING_STATUS_MASK 7 +#define S5P_FIMV_DEC_STATUS_PROGRESSIVE (0 << 3) +#define S5P_FIMV_DEC_STATUS_INTERLACE (1 << 3) +#define S5P_FIMV_DEC_STATUS_INTERLACE_MASK (1 << 3) +#define S5P_FIMV_DEC_STATUS_CRC_NUMBER_TWO (0 << 4) +#define S5P_FIMV_DEC_STATUS_CRC_NUMBER_FOUR (1 << 4) +#define S5P_FIMV_DEC_STATUS_CRC_NUMBER_MASK (1 << 4) +#define S5P_FIMV_DEC_STATUS_CRC_GENERATED (1 << 5) +#define S5P_FIMV_DEC_STATUS_CRC_NOT_GENERATED (0 << 5) +#define S5P_FIMV_DEC_STATUS_CRC_MASK (1 << 5) + +/* Decode frame address */ +#define S5P_FIMV_DECODE_Y_ADR 0x2024 +#define S5P_FIMV_DECODE_C_ADR 0x2028 + +/* Decoded frame tpe */ +#define S5P_FIMV_DECODE_FRAME_TYPE 0x2020 +#define S5P_FIMV_DECODE_FRAME_MASK 7 + +#define S5P_FIMV_DECODE_FRAME_SKIPPED 0 +#define S5P_FIMV_DECODE_FRAME_I_FRAME 1 +#define S5P_FIMV_DECODE_FRAME_P_FRAME 2 +#define S5P_FIMV_DECODE_FRAME_202_FRAME 3 +#define S5P_FIMV_DECODE_FRAME_OTHER_FRAME 4 + +/* Sizes of buffers required for decoding */ +#define S5P_FIMV_DEC_NB_IP_SIZE (32 * 1024) +#define S5P_FIMV_DEC_VERT_NB_MV_SIZE (16 * 1024) +#define S5P_FIMV_DEC_NB_DCAC_SIZE (16 * 1024) +#define S5P_FIMV_DEC_UPNB_MV_SIZE (68 * 1024) +#define S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE (136 * 1024) +#define S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE (32 * 1024) +#define S5P_FIMV_DEC_VC1_BITPLANE_SIZE (2 * 1024) +#define S5P_FIMV_DEC_STX_PARSER_SIZE (68 * 1024) + +#define S5P_FIMV_DEC_BUF_ALIGN (8 * 1024) +#define S5P_FIMV_NV12T_VALIGN 128 +#define S5P_FIMV_NV12T_HALIGN 32 + + +/* Encoder */ +#define S5P_FIMV_ENC_SI_STRM_SIZE 0x2004/* stream size */ +#define S5P_FIMV_ENC_SI_PIC_CNT 0x2008/* picture count */ +#define S5P_FIMV_ENC_SI_WRITE_PTR 0x200c/* write pointer */ +#define S5P_FIMV_ENC_SI_SLICE_TYPE 0x2010/* slice type(I/P/B/IDR) */ + +#define S5P_FIMV_ENC_SI_CH0_SB_U_ADR 0x2044/* addr of upper stream buf */
+#defineS5P_FIMV_ENC_SI_CH0_SB_L_ADR0x2048/* addr of lower stream buf
*/
drivers/media/video/s5p-mfc/regs-mfc5.h
Quoted 2 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +2
-0+#define S5P_FIMV_ENC_SI_CH0_SB_SIZE 0x204c/* size of stream buf */ +#define S5P_FIMV_ENC_SI_CH0_CUR_Y_ADR 0x2050/* current Luma addr
*/
Quoted 1 line
+#define
S5P_FIMV_ENC_SI_CH0_CUR_C_ADR0x2054/* current Chroma
addr */
drivers/media/video/s5p-mfc/regs-mfc5.h
Quoted 9 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +4
-0+#define S5P_FIMV_ENC_SI_CH0_FRAME_QP 0x2058/* frame QP */ +#define S5P_FIMV_ENC_SI_CH0_SLICE_ARG 0x205c/* slice argument */ + +#define S5P_FIMV_ENC_SI_CH1_SB_U_ADR 0x2084/* addr of upper stream buf */
+#defineS5P_FIMV_ENC_SI_CH1_SB_L_ADR0x2088/* addr of lower stream buf
*/drivers/media/video/s5p-mfc/regs-mfc5.h new file +2
-0+#define S5P_FIMV_ENC_SI_CH1_SB_SIZE 0x208c/* size of stream buf */ +#define S5P_FIMV_ENC_SI_CH1_CUR_Y_ADR 0x2090/* current Luma addr
*/
Quoted 1 line
+#define
S5P_FIMV_ENC_SI_CH1_CUR_C_ADR0x2094/* current Chroma
addr */
Quoted 10 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +5
-0+#define S5P_FIMV_ENC_SI_CH1_FRAME_QP 0x2098/* frame QP */ +#define S5P_FIMV_ENC_SI_CH1_SLICE_ARG 0x209c/* slice argument */ + +#define S5P_FIMV_ENC_STR_BF_U_FULL 0xc004/* upper stream buf full */ +#define S5P_FIMV_ENC_STR_BF_U_EMPTY 0xc008/* upper stream buf empty */
drivers/media/video/s5p-mfc/regs-mfc5.h new file +2
-0+#define S5P_FIMV_ENC_STR_BF_L_FULL 0xc00c/* lower stream buf full */ +#define S5P_FIMV_ENC_STR_BF_L_EMPTY 0xc010/* lower stream buf empty */
+#defineS5P_FIMV_ENC_STR_STATUS0xc018/* stream buf
interrupt
Quoted 8 lines
status */
drivers/media/video/s5p-mfc/regs-mfc5.h new file +5
-0+#define S5P_FIMV_ENC_SF_EPB_ON_CTRL 0xc054/* stream control */ +#define S5P_FIMV_ENC_SF_BUF_CTRL 0xc058/* buffer control */ +#define S5P_FIMV_ENC_BF_MODE_CTRL 0xc05c/* fifo level control */ + +#define S5P_FIMV_ENC_PIC_TYPE_CTRL 0xc504/* pic type level control */
+#defineS5P_FIMV_ENC_B_RECON_WRITE_ON0xc508/* B frame recon
write ctrl
drivers/media/video/s5p-mfc/regs-mfc5.h
Quoted 3 lines
*/
drivers/media/video/s5p-mfc/regs-mfc5.h new file +2
-0+#define S5P_FIMV_ENC_MSLICE_CTRL 0xc50c/* multi slice control */ +#define S5P_FIMV_ENC_MSLICE_MB 0xc510/* MB number in the
one
Quoted 4 lines
slice */
+#defineS5P_FIMV_ENC_MSLICE_BYTE0xc514/* byte number for one
slice */
+#defineS5P_FIMV_ENC_CIR_CTRL0xc518/* number of intra
refresh
drivers/media/video/s5p-mfc/regs-mfc5.h
Quoted 11 lines
MB */
+#defineS5P_FIMV_ENC_MAP_FOR_CUR0xc51c/* linear or 64x32 tiled
mode */drivers/media/video/s5p-mfc/regs-mfc5.h new file +8
-0+#define S5P_FIMV_ENC_PADDING_CTRL 0xc520/* padding control */ +#define S5P_FIMV_ENC_INT_MASK 0xc528/* interrupt mask */ + +#define S5P_FIMV_ENC_RC_CONFIG 0xc5a0/* RC config */ +#define S5P_FIMV_ENC_RC_FRAME_RATE 0xc5a4/* frame rate */ +#define S5P_FIMV_ENC_RC_BIT_RATE 0xc5a8/* bit rate */ +#define S5P_FIMV_ENC_RC_QBOUND 0xc5ac/* max/min QP */ +#define S5P_FIMV_ENC_RC_RPARA 0xc5b0/* rate control
reaction
Quoted 2 lines
coeff */
+#defineS5P_FIMV_ENC_RC_MB_CTRL0xc5b4/* MB adaptive
scaling */
Quoted 10 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +4
-0+ +/* Encoder for H264 */ +#define S5P_FIMV_ENC_ENTRP_MODE 0xd004/* CAVLC or CABAC */ +#define S5P_FIMV_ENC_H264_ALPHA_OFF 0xd008/* loop filter alpha offset */
+#defineS5P_FIMV_ENC_H264_BETA_OFF0xd00c/* loop filter beta offset
*/
+#defineS5P_FIMV_ENC_H264_NUM_OF_REF0xd010/* number of reference for
P/B */
+#defineS5P_FIMV_ENC_H264_MDINTER_WGT0xd01c/* inter weighted
parameter
Quoted 2 lines
*/
+#defineS5P_FIMV_ENC_H264_MDINTRA_WGT0xd020/* intra weighted
parameter
drivers/media/video/s5p-mfc/regs-mfc5.h
Quoted 4 lines
*/
+#defineS5P_FIMV_ENC_H264_TRANS_FLAG0xd034/* 8x8 transform flag in
PPS &drivers/media/video/s5p-mfc/regs-mfc5.h new file +1
-0+ high
profile */
Quoted 27 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +2
-0+/* Encoder for MPEG4 */ +#define S5P_FIMV_ENC_MPEG4_QUART_PXL 0xe008/* qpel interpolation ctrl */
drivers/media/video/s5p-mfc/regs-mfc5.h new file +3
-0+ +/* Additional */ +#define S5P_FIMV_SI_CH0_DPB_CONF_CTRL 0x2068/* DPB Config Control Register */
drivers/media/video/s5p-mfc/regs-mfc5.h new file +8
-0+#define S5P_FIMV_SLICE_INT_MASK 1 +#define S5P_FIMV_SLICE_INT_SHIFT 31 +#define S5P_FIMV_DDELAY_ENA_SHIFT 30 +#define S5P_FIMV_DDELAY_VAL_MASK 0xff +#define S5P_FIMV_DDELAY_VAL_SHIFT 16 +#define S5P_FIMV_DPB_COUNT_MASK 0xffff + +#define S5P_FIMV_SI_CH0_RELEASE_BUF 0x2060/* DPB release buffer register */
+#defineS5P_FIMV_SI_CH0_HOST_WR_ADR0x2064/* address of shared memory
*/
+#defineS5P_FIMV_ENC_B_RECON_WRITE_ON0xc508/* B frame recon write
ctrl */drivers/media/video/s5p-mfc/regs-mfc5.h new file +3
-0+#define S5P_FIMV_ENC_REF_B_LUMA_ADR 0x062c/* ref B Luma addr */ +#define S5P_FIMV_ENC_REF_B_CHROMA_ADR 0x0630/* ref B Chroma addr */ +#define S5P_FIMV_ENCODED_Y_ADDR 0x2014/* the address of the encoded
drivers/media/video/s5p-mfc/regs-mfc5.h new file +2
-0+luminance picture */ +#define S5P_FIMV_ENCODED_C_ADDR 0x2018/* the address of the encoded
drivers/media/video/s5p-mfc/regs-mfc5.h
Quoted 1 line
drivers/media/video/s5p-mfc/regs-mfc5.h new file +1
-0+ chrominance
picture*/
Quoted 127 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +73
-0+ +/* Codec numbers */ +#define S5P_FIMV_CODEC_H264_DEC 0 +#define S5P_FIMV_CODEC_VC1_DEC 1 +#define S5P_FIMV_CODEC_MPEG4_DEC 2 +#define S5P_FIMV_CODEC_MPEG2_DEC 3 +#define S5P_FIMV_CODEC_H263_DEC 4 +#define S5P_FIMV_CODEC_VC1RCV_DEC 5 +#define S5P_FIMV_CODEC_DIVX311_DEC 6 +#define S5P_FIMV_CODEC_DIVX412_DEC 7 +#define S5P_FIMV_CODEC_DIVX502_DEC 8 +#define S5P_FIMV_CODEC_DIVX503_DEC 9 + +#define S5P_FIMV_CODEC_H264_ENC 16 +#define S5P_FIMV_CODEC_MPEG4_ENC 17 +#define S5P_FIMV_CODEC_H263_ENC 18 + +/* Channel Control Register */ +#define S5P_FIMV_CH_SEQ_HEADER 1 +#define S5P_FIMV_CH_FRAME_START 2 +#define S5P_FIMV_CH_LAST_FRAME 3 +#define S5P_FIMV_CH_INIT_BUFS 4 +#define S5P_FIMV_CH_FRAME_START_REALLOC 5 + +#define S5P_FIMV_CH_MASK 7 +#define S5P_FIMV_CH_SHIFT 16 + + +/* Host to RISC command */ +#define S5P_FIMV_H2R_CMD_EMPTY 0 +#define S5P_FIMV_H2R_CMD_OPEN_INSTANCE 1 +#define S5P_FIMV_H2R_CMD_CLOSE_INSTANCE 2 +#define S5P_FIMV_H2R_CMD_SYS_INIT 3 + +#define S5P_FIMV_R2H_CMD_EMPTY 0 +#define S5P_FIMV_R2H_CMD_OPEN_INSTANCE_RET 1 +#define S5P_FIMV_R2H_CMD_CLOSE_INSTANCE_RET 2 +#define S5P_FIMV_R2H_CMD_ERROR_RET 3 +#define S5P_FIMV_R2H_CMD_SEQ_DONE_RET 4 +#define S5P_FIMV_R2H_CMD_FRAME_DONE_RET 5 +#define S5P_FIMV_R2H_CMD_SLICE_DONE_RET 6 +#define S5P_FIMV_R2H_CMD_ENC_COMPLETE_RET 7 +#define S5P_FIMV_R2H_CMD_SYS_INIT_RET 8 +#define S5P_FIMV_R2H_CMD_FW_STATUS_RET 9 +#define S5P_FIMV_R2H_CMD_INIT_BUFFERS_RET 15 +#define S5P_FIMV_R2H_CMD_EDFU_INIT_RET 16 +#define S5P_FIMV_R2H_CMD_DECODE_ERR_RET 32 + +/* Error handling defines */ +#define S5P_FIMV_ERR_WARNINGS_START 145 + +/* Shared memory registers' offsets */ + +/* An offset of the start position in the stream when +* the start position is not aligned */ +#define S5P_FIMV_SHARED_CROP_INFO_H 0x0020 +#define S5P_FIMV_SHARED_CROP_LEFT_MASK 0xFFFF +#define S5P_FIMV_SHARED_CROP_LEFT_SHIFT 0 +#define S5P_FIMV_SHARED_CROP_RIGHT_MASK 0xFFFF0000 +#define S5P_FIMV_SHARED_CROP_RIGHT_SHIFT 16 +#define S5P_FIMV_SHARED_CROP_INFO_V 0x0024 +#define S5P_FIMV_SHARED_CROP_TOP_MASK 0xFFFF +#define S5P_FIMV_SHARED_CROP_TOP_SHIFT 0 +#define S5P_FIMV_SHARED_CROP_BOTTOM_MASK 0xFFFF0000 +#define S5P_FIMV_SHARED_CROP_BOTTOM_SHIFT 16 +#define S5P_FIMV_SHARED_START_BYTE_NUM 0x0018 +#define S5P_FIMV_SHARED_LUMA_DPB_SIZE 0x0064 +#define S5P_FIMV_SHARED_CHROMA_DPB_SIZE 0x0068 +#define S5P_FIMV_SHARED_MV_SIZE 0x006C +#define S5P_FIMV_SHARED_PIC_TIME_TOP 0x0010 +#define S5P_FIMV_SHARED_PIC_TIME_BOTTOM 0x0014 + +#endif /* _REGS_FIMV_H */ drivers/media/video/s5p-mfc/s5p_mfc.c new file +8
-0@@ -0,0 +1,2072 @@ +/* +* Samsung S5P Multi Format Codec v 5.0 +* +* Copyright (c) 2010 Samsung Electronics Co., Ltd. +* Kamil Debski, <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version
+ */drivers/media/video/s5p-mfc/s5p_mfc.c new file +34
-0+ +#define DEBUG + +#include <linux/io.h> +#include <linux/sched.h> +#include <linux/clk.h> +#include <linux/module.h> +#include <linux/interrupt.h> +#include <linux/platform_device.h> +#include <linux/version.h> +#include <linux/workqueue.h> +#include <linux/videodev2.h> +#include <media/videobuf2-cma.h> +#include <media/videobuf2-core.h> +#include "regs-mfc5.h" + +#include "s5p_mfc_opr.h" +#include "s5p_mfc_intr.h" +#include "s5p_mfc_memory.h" +#include "s5p_mfc_ctrls.h" +#include "s5p_mfc_debug.h" + +#define S5P_MFC_NAME "s5p-mfc" + +/* Offset base used to differentiate between CAPTURE and OUTPUT +* while mmaping */ +#define DST_QUEUE_OFF_BASE (TASK_SIZE / 2) + +int debug =0 ; +module_param (debug, int,S_IRUGO |S_IWUSR ); + +//struct s5p_mfc_dev *dev; +/* Order must be as defined in s5p_mfc_memory.h */ +static const char *s5p_mem_types[] = {MFC_CMA_BANK2 ,MFC_CMA_BANK1 ,
MFC_CMA_FW};
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 2 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +2
-0+static unsigned long s5p_mem_alignments[] = {MFC_CMA_BANK2_ALIGN , +MFC_CMA_BANK1_ALIGN ,
MFC_CMA_FW_ALIGN};
Quoted 62 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +31
-0+ + +/* Function prototypes */ +static void s5p_mfc_try_run (struct s5p_mfc_dev *dev); + +/* Helper functions for interrupt processing */ +/* Remove from hw execution round robin */ +static inline void clear_work_bit (struct s5p_mfc_ctx *ctx) +{ +struct s5p_mfc_dev *dev = ctx->dev; + +spin_lock (&dev->condlock); +clear_bit (ctx->num, &dev->ctx_work_bits); +spin_unlock (&dev->condlock); +} + +/* Wake up context wait_queue */ +static inline void wake_up_ctx (struct s5p_mfc_ctx *ctx, +unsigned int reason,unsigned int err) +{ + ctx->int_cond =1 ; + ctx->int_type = reason; + ctx->int_err = err; +if (ctx->state !=MFCINST_DEC_ABORT ) +wake_up_interruptible (&ctx->queue); +else +wake_up (&ctx->queue); +} + +/* Wake up device wait_queue */ +static inline void wake_up_dev(struct s5p_mfc_dev *dev, unsigned intreason,
drivers/media/video/s5p-mfc/s5p_mfc.c new file +29
-0+ unsigned int err) +{ + dev->int_cond =1 ; + dev->int_type = reason; + dev->int_err = err; +wake_up_interruptible (&dev->queue); +} + +void s5p_mfc_error_cleanup_queue (struct list_head *lh, +struct vb2_queue *vq) +{ +struct s5p_mfc_buf *b; +int i; + +while (!list_empty (lh)) { + b = list_entry(lh->next, struct s5p_mfc_buf, list); +for (i =0 ; i < b->b->num_planes; i++) +vb2_set_plane_payload (b->b, i,0 ); +vb2_buffer_done (b->b,VB2_BUF_STATE_ERROR ); +list_del (&b->list); + } +} + +void s5p_mfc_watchdog (unsigned long arg) +{ +struct s5p_mfc_dev *dev = (struct s5p_mfc_dev *)arg; + +if (test_bit (0 , &dev->hw_lock)) +atomic_inc (&dev->watchdog_cnt);
drivers/media/video/s5p-mfc/s5p_mfc.c line 117
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+if (atomic_read (&dev->watchdog_cnt) >=MFC_WATCHDOG_CNT ) { +/* This means that hw is busy and no interrupts were +* generated by hw for the Nth time of running this +* watchdog timer. This usually means a serious hw +* error. Now it is time to kill all instances and +* reset the MFC. */ +mfc_err ("Time out during waiting for HW.\n" ); +queue_work (dev->watchdog_workqueue, &dev->watchdog_work); + } + dev->watchdog_timer.expires = jiffies +
+ msecs_to_jiffies(MFC_WATCHDOG_INTERV
AL);
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +9
-0+add_timer (&dev->watchdog_timer); +} + +static void s5p_mfc_watchdog_worker (struct work_struct *work) +{ +struct s5p_mfc_dev *dev; +struct s5p_mfc_ctx *ctx; +int i, ret; +int mutex_locked;
drivers/media/video/s5p-mfc/s5p_mfc.c line 137
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+unsigned long flags; + + dev = container_of(work, struct s5p_mfc_dev, watchdog_work); + +mfc_err ("Driver timeout error handling.\n" ); +/* Lock the mutex that protects open and release. +* This is necessary as they may load and unload firmware. */ + mutex_locked =mutex_trylock (&dev->mfc_mutex); +if (!mutex_locked) + mfc_err("This is not good. Some instance may be "
+ "closing/opening.\n"
);
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 13 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +13
-0+spin_lock_irqsave (&dev->irqlock, flags); +clk_disable (dev->clock1); +clk_disable (dev->clock2); +for (i =0 ; i <MFC_NUM_CONTEXTS ; i++) { + ctx = dev->ctx[i]; +if (ctx) { + ctx->state =MFCINST_DEC_ERROR ; +s5p_mfc_error_cleanup_queue (&ctx->dst_queue, + &ctx->vq_dst); +s5p_mfc_error_cleanup_queue (&ctx->src_queue, + &ctx->vq_src); +clear_work_bit (ctx); + wake_up_ctx(ctx, S5P_FIMV_R2H_CMD_DECODE_ERR_RET,
0);
Quoted 105 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +6
-0+ } + } +clear_bit (0 , &dev->hw_lock); +spin_unlock_irqrestore (&dev->irqlock, flags); +/* Double check if there is at least one instance running. +* If no instance is in memory than no firmware should be present */
drivers/media/video/s5p-mfc/s5p_mfc.c new file +29
-0+if (dev->num_inst >0 ) { + ret =s5p_mfc_load_firmware (dev); +if (ret !=0 ) { +mfc_err ("Failed to reload FW.\n" ); +if (mutex_locked) +mutex_unlock (&dev->mfc_mutex); +return ; + } +clk_enable (dev->clock1); +clk_enable (dev->clock2); + ret =s5p_mfc_init_hw (dev); +if (ret !=0 ) { +mfc_err ("Failed to reinit FW.\n" ); +if (mutex_locked) +mutex_unlock (&dev->mfc_mutex); +return ; + } + } +if (mutex_locked) +mutex_unlock (&dev->mfc_mutex); +} + +/* Check whether a context should be run on hardware */ +int s5p_mfc_ctx_ready (struct s5p_mfc_ctx *ctx) +{ +struct s5p_mfc_dev *dev = ctx->dev; + + mfc_debug("s5p_mfc_ctx_ready: src=%d, dst=%d, " + "state=%d capstat=%d\n", ctx->src_queue_cnt, ctx-Quoted 1 line
dst_queue_cnt,drivers/media/video/s5p-mfc/s5p_mfc.c new file +7
-0+ ctx->state, ctx->capture_state); +/* Context is to parse header */ +if (ctx->src_queue_cnt >=1 && ctx->state ==MFCINST_DEC_GOT_INST ) +return 1 ; +/* Context is to decode a frame */ +if (ctx->src_queue_cnt >=1 && ctx->state ==MFCINST_DEC_RUNNING && + ctx->dst_queue_cnt >= ctx-
dpb_count)drivers/media/video/s5p-mfc/s5p_mfc.c new file +60
-0+return 1 ; +/* Context is to return last frame */ +if (ctx->state ==MFCINST_DEC_FINISHING && + ctx->dst_queue_cnt >= ctx->dpb_count) +return 1 ; +/* Context is to set buffers */ +if (ctx->src_queue_cnt >=1 && + ctx->state ==MFCINST_DEC_HEAD_PARSED && + ctx->capture_state ==QUEUE_BUFS_MMAPED ) +return 1 ; +mfc_debug ("s5p_mfc_ctx_ready: ctx is not ready.\n" ); +return 0 ; +} + +/* Query control */ +static struct v4l2_queryctrl *get_ctrl (int id) +{ +int i; + +for (i =0 ; i <NUM_CTRLS ; ++i) +if (id == s5p_mfc_ctrls[i].id) +return &s5p_mfc_ctrls[i]; +return NULL ; +} + +/* Query capabilities of the device */ +static int vidioc_querycap (struct file *file,void *priv, +struct v4l2_capability *cap) +{ +struct s5p_mfc_dev *dev =video_drvdata (file); + +strncpy (cap->driver, dev->plat_dev->name,sizeof (cap->driver) -1 ); +strncpy (cap->card, dev->plat_dev->name,sizeof (cap->card) -1 ); + cap->bus_info[0 ] =0 ; + cap->version =KERNEL_VERSION (1 ,0 ,0 ); + cap->capabilities =V4L2_CAP_VIDEO_CAPTURE |V4L2_CAP_VIDEO_OUTPUT + |V4L2_CAP_STREAMING ; +return 0 ; +} + +/* Enumerate format */ +static int vidioc_enum_fmt (struct v4l2_fmtdesc *f,bool mplane,bool out) +{ +struct s5p_mfc_fmt *fmt; +int i, j =0 ; + +for (i =0 ; i <ARRAY_SIZE (formats); ++i) { +if (mplane && formats[i].num_planes ==1 ) +continue ; +else if (!mplane && formats[i].num_planes >1 ) +continue ; +if (out && formats[i].type !=MFC_FMT_RAW ) +continue ; +else if (!out && formats[i].type !=MFC_FMT_DEC ) +continue ; + +if (j == f->index) +break ; + ++j; + }
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+if (i ==ARRAY_SIZE (formats)) +return -EINVAL ; + fmt = &formats[i]; +strlcpy (f->description, fmt->name,sizeof (f->description)); + f->pixelformat = fmt->fourcc; +return 0 ; +} + +static int vidioc_enum_fmt_vid_cap (struct file *file,void *pirv, + struct v4l2_fmtdesc
*f)
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 6 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +6
-0+{ +return vidioc_enum_fmt (f, false, false); +} + +static int vidioc_enum_fmt_vid_cap_mplane (struct file *file,void *pirv, + struct v4l2_fmtdesc
*f)
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 6 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +6
-0+{ +return vidioc_enum_fmt (f, true, false); +} + +static int vidioc_enum_fmt_vid_out (struct file *file,void *prov, + struct v4l2_fmtdesc
*f)
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 6 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +6
-0+{ +return vidioc_enum_fmt (f, false, true); +} + +static int vidioc_enum_fmt_vid_out_mplane (struct file *file,void *prov, + struct v4l2_fmtdesc
*f)
Quoted 11 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +6
-0+{ +return vidioc_enum_fmt (f, true, true); +} + +/* Get format */ +static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format*f)
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+{ +struct s5p_mfc_dev *dev =video_drvdata (file); +struct s5p_mfc_ctx *ctx = priv; +struct v4l2_pix_format_mplane *pix_mp;
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+ +mfc_debug_enter (); + pix_mp = &f->fmt.pix_mp; +mfc_debug ("f->type = %d ctx->state = %d\n" , f->type, ctx->state); +if (f->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE && + ctx->state ==MFCINST_DEC_GOT_INST ) { +/* If the MFC is parsing the header, +* so wait until it is finished */ +s5p_mfc_clean_ctx_int_flags (ctx); + s5p_mfc_wait_for_done_ctx(ctx,
S5P_FIMV_R2H_CMD_SEQ_DONE_RET,
Quoted 161 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +59
-0+ 1); + } +if (f->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE && + ctx->state >=MFCINST_DEC_HEAD_PARSED && + ctx->state <MFCINST_ENC_INIT ) { +/* This is run on CAPTURE (deocde output) */ +/* Width and height are set to the dimensions +of the movie, the buffer is bigger and +further processing stages should crop to this +rectangle. */ + pix_mp->width = ctx->buf_width; + pix_mp->height = ctx->buf_height; + pix_mp->field =V4L2_FIELD_NONE ; + pix_mp->num_planes =2 ; +/* Set pixelformat to the format in which MFC +outputs the decoded frame */ + pix_mp->pixelformat =V4L2_PIX_FMT_NV12MT ; + pix_mp->plane_fmt[0 ].bytesperline = ctx->buf_width; + pix_mp->plane_fmt[0 ].sizeimage = ctx->luma_size; + pix_mp->plane_fmt[1 ].bytesperline = ctx->buf_width; + pix_mp->plane_fmt[1 ].sizeimage = ctx->chroma_size; + }else if (f->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) { +/* This is run on OUTPUT +The buffer contains compressed image +so width and height have no meaning */ + pix_mp->width =0 ; + pix_mp->height =0 ; + pix_mp->field =V4L2_FIELD_NONE ; + pix_mp->plane_fmt[0 ].bytesperline = ctx->dec_src_buf_size; + pix_mp->plane_fmt[0 ].sizeimage = ctx->dec_src_buf_size; + pix_mp->pixelformat = ctx->fmt->fourcc; + pix_mp->num_planes = ctx->fmt->num_planes; + }else { +mfc_err ("Format could not be read\n" ); +mfc_debug ("%s-- with error\n" , __func__); +return -EINVAL ; + } +mfc_debug_leave (); +return 0 ; +} + +/* Find selected format description */ +static struct s5p_mfc_fmt *find_format (struct v4l2_format *f) +{ +struct s5p_mfc_fmt *fmt; +unsigned int i; + +for (i =0 ; i <NUM_FORMATS ; ++i) { + fmt = &formats[i]; +if (fmt->fourcc == f->fmt.pix_mp.pixelformat) +break ; + } +if (i ==NUM_FORMATS ) +return NULL ; +return fmt; +} + +/* Try format */ +static int vidioc_try_fmt(struct file *file, void *priv, struct
v4l2_format*f)drivers/media/video/s5p-mfc/s5p_mfc.c new file +35
-0+{ +struct s5p_mfc_dev *dev =video_drvdata (file); +struct s5p_mfc_fmt *fmt; +struct v4l2_pix_format_mplane *pix_mp; + +mfc_debug ("Type is %d\n" , f->type); +if (f->type !=V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) { +mfc_err ("Currently only decoding is supported.\n" ); +return -EINVAL ; + } + fmt =find_format (f); +if (!fmt) { +mfc_err ("Unsupported format.\n" ); +return -EINVAL ; + } +if (fmt->type !=MFC_FMT_DEC ) { +mfc_err ("\n" ); +return -EINVAL ; + } + pix_mp = &f->fmt.pix_mp; +if (pix_mp->plane_fmt[0 ].sizeimage ==0 ) { +mfc_err ("Application is required to " +"specify input buffer size (via sizeimage)\n" ); +return -EINVAL ; + } +/* As this buffer will contain compressed data, the size is set +* to the maximum size. +* Width and height are left intact as they may be relevant for +* DivX 3.11 decoding. */ + pix_mp->plane_fmt[0 ].bytesperline = pix_mp->plane_fmt[0 ].sizeimage; +return 0 ; +} + +/* Set format */ +static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format*f)
drivers/media/video/s5p-mfc/s5p_mfc.c new file +65
-0+{ +struct s5p_mfc_dev *dev =video_drvdata (file); +struct s5p_mfc_ctx *ctx = priv; +unsigned long flags; +int ret =0 ; +struct s5p_mfc_fmt *fmt; +struct v4l2_pix_format_mplane *pix_mp; + +mfc_debug_enter (); + ret =vidioc_try_fmt (file, priv, f); + pix_mp = &f->fmt.pix_mp; +if (ret) +return ret; +if (ctx->vq_src.streaming || ctx->vq_dst.streaming) { +v4l2_err (&dev->v4l2_dev,"%s queue busy\n" , __func__); + ret = -EBUSY ; + goto out; + } + fmt =find_format (f); +if (!fmt || fmt->codec_mode ==MFC_FORMATS_NO_CODEC ) { +mfc_err ("Unknown codec.\n" ); + ret = -EINVAL ; + goto out; + } +if (fmt->type !=MFC_FMT_DEC ) { +mfc_err ("Wrong format selected, you should choose " +"format for decoding.\n" ); + ret = -EINVAL ; + goto out; + } + ctx->fmt = fmt; + ctx->codec_mode = fmt->codec_mode; +mfc_debug ("The codec number is: %d\n" , ctx->codec_mode); + ctx->pix_format = pix_mp->pixelformat; +if (pix_mp->pixelformat !=V4L2_PIX_FMT_DIVX3 ) { + pix_mp->height =0 ; + pix_mp->width =0 ; + }else { + ctx->img_height = pix_mp->height; + ctx->img_width = pix_mp->width; + } +mfc_debug ("s_fmt w/h: %dx%d, ctx: %dx%d\n" , pix_mp->width, + pix_mp->height, ctx->img_width, ctx->img_height); + ctx->dec_src_buf_size = pix_mp->plane_fmt[0 ].sizeimage; + pix_mp->plane_fmt[0 ].bytesperline =0 ; + ctx->state =MFCINST_DEC_INIT ; + ctx->dst_bufs_cnt =0 ; + ctx->src_bufs_cnt =0 ; + ctx->capture_state =QUEUE_FREE ; + ctx->output_state =QUEUE_FREE ; +s5p_mfc_alloc_instance_buffer (ctx); +s5p_mfc_alloc_dec_temp_buffers (ctx); +spin_lock_irqsave (&dev->condlock, flags); +set_bit (ctx->num, &dev->ctx_work_bits); +spin_unlock_irqrestore (&dev->condlock, flags); +s5p_mfc_clean_ctx_int_flags (ctx); +s5p_mfc_try_run (dev); +if (s5p_mfc_wait_for_done_ctx (ctx, +S5P_FIMV_R2H_CMD_OPEN_INSTANCE_RET ,1 )) { +/* Error or timeout */ +mfc_err ("Error getting instance from hardware.\n" ); +s5p_mfc_release_instance_buffer (ctx); +s5p_mfc_release_dec_buffers (ctx); + ret = -EIO ; + goto out;
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+ } +mfc_debug ("Got instance number: %d\n" , ctx->inst_no); +out: +mfc_debug_leave (); +return ret; +} + +/* Reqeust buffers */ +static int vidioc_reqbufs (struct file *file,void *priv, + struct v4l2_requestbuffers
*reqbufs)
Quoted 15 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +14
-0+{ +struct s5p_mfc_dev *dev =video_drvdata (file); +struct s5p_mfc_ctx *ctx = priv; +int ret =0 ; +unsigned long flags; + +mfc_debug_enter (); +mfc_debug ("Memory type: %d\n" , reqbufs->memory); +if (reqbufs->memory !=V4L2_MEMORY_MMAP ) { +mfc_err ("Only V4L2_MEMORY_MAP is supported.\n" ); +return -EINVAL ; + } +if (reqbufs->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) { +/* Can only request buffers after an instance has been opened.*/
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 4 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+if (ctx->state ==MFCINST_DEC_GOT_INST ) { +/* Decoding */ +if (ctx->output_state !=QUEUE_FREE ) { + mfc_err("Bufs have already been
requested.\n");
Quoted 42 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +42
-0+return -EINVAL ; + } + ret =vb2_reqbufs (&ctx->vq_src, reqbufs); +if (ret) { +mfc_err ("vb2_reqbufs on output failed.\n" ); +return ret; + } +mfc_debug ("vb2_reqbufs: %d\n" , ret); + ctx->output_state =QUEUE_BUFS_REQUESTED ; + } + }else if (reqbufs->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ) { +if (ctx->capture_state !=QUEUE_FREE ) { +mfc_err ("Bufs have already been requested.\n" ); +return -EINVAL ; + } + ctx->capture_state =QUEUE_BUFS_REQUESTED ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +if (ret) { +mfc_err ("vb2_reqbufs on capture failed.\n" ); +return ret; + } +if (reqbufs->count < ctx->dpb_count) { +mfc_err ("Not enough buffers allocated.\n" ); + reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +return -ENOMEM ; + } + ctx->total_dpb_count = reqbufs->count; + ret =s5p_mfc_alloc_dec_buffers (ctx); +if (ret) { +mfc_err ("Failed to allocate decoding buffers.\n" ); + reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +return -ENOMEM ; + } +if (ctx->dst_bufs_cnt == ctx->total_dpb_count) { + ctx->capture_state =QUEUE_BUFS_MMAPED ; + }else { +mfc_err ("Not all buffers passed to buf_init.\n" ); + reqbufs->count =0 ; + ret =vb2_reqbufs (&ctx->vq_dst, reqbufs); +s5p_mfc_release_dec_buffers (ctx);
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+return -ENOMEM ; + } +if (s5p_mfc_ctx_ready (ctx)) { +spin_lock_irqsave (&dev->condlock, flags); +set_bit (ctx->num, &dev->ctx_work_bits); +spin_unlock_irqrestore (&dev->condlock, flags); + } +s5p_mfc_try_run (dev); + s5p_mfc_wait_for_done_ctx(ctx, + S5P_FIMV_R2H_CMD_INIT_BUFFERS_RET,
1);
Quoted 253 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +30
-0+ } +mfc_debug_leave (); +return ret; +} + +/* Query buffer */ +static int vidioc_querybuf (struct file *file,void *priv, +struct v4l2_buffer *buf) +{ +struct s5p_mfc_dev *dev =video_drvdata (file); +struct s5p_mfc_ctx *ctx = priv; +int ret; +int i; + +mfc_debug_enter (); +if (buf->memory !=V4L2_MEMORY_MMAP ) { +mfc_err ("Only mmaped buffers can be used.\n" ); +return -EINVAL ; + } +mfc_debug ("State: %d, buf->type: %d\n" , ctx->state, buf->type); +if (ctx->state ==MFCINST_DEC_GOT_INST && + buf->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) { + ret =vb2_querybuf (&ctx->vq_src, buf); + }else if (ctx->state ==MFCINST_DEC_RUNNING && + buf->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ) { + ret =vb2_querybuf (&ctx->vq_dst, buf); +for (i =0 ; i < buf->length; i++) + buf->m.planes[i].m.mem_offset +=DST_QUEUE_OFF_BASE ; + }else { + mfc_err("vidioc_querybuf called in an inappropriatestate.\n");
drivers/media/video/s5p-mfc/s5p_mfc.c new file +8
-0+ ret = -EINVAL ; + } +mfc_debug_leave (); +return ret; +} + +/* Queue a buffer */ +static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer*buf)
drivers/media/video/s5p-mfc/s5p_mfc.c new file +20
-0+{ +struct s5p_mfc_dev *dev =video_drvdata (file); +struct s5p_mfc_ctx *ctx = priv; + +mfc_debug_enter (); +mfc_debug ("Enqueued buf: %d (type = %d)\n" , buf->index, buf->type); +if (ctx->state ==MFCINST_DEC_ERROR ) { +mfc_err ("Call on QBUF after unrecoverable error.\n" ); +return -EIO ; + } +if (buf->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) +return vb2_qbuf (&ctx->vq_src, buf); +else +return vb2_qbuf (&ctx->vq_dst, buf); +mfc_debug_leave (); +return -EINVAL ; +} + +/* Dequeue a buffer */ +static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer*buf)
drivers/media/video/s5p-mfc/s5p_mfc.c new file +7
-0+{ +struct s5p_mfc_dev *dev =video_drvdata (file); +struct s5p_mfc_ctx *ctx = priv; +int ret; + +mfc_debug_enter (); + mfc_debug("Addr: %p %p %p Type: %d\n", &ctx->vq_src, buf, buf-Quoted 1 line
m.planes,
drivers/media/video/s5p-mfc/s5p_mfc.c new file +7
-0+ buf->type); +if (ctx->state ==MFCINST_DEC_ERROR ) { +mfc_err ("Call on DQBUF after unrecoverable error.\n" ); +return -EIO ; + } +if (buf->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) + ret = vb2_dqbuf(&ctx->vq_src, buf, file->f_flags &
O_NONBLOCK);drivers/media/video/s5p-mfc/s5p_mfc.c new file +2
-0+else + ret = vb2_dqbuf(&ctx->vq_dst, buf, file->f_flags &
O_NONBLOCK);drivers/media/video/s5p-mfc/s5p_mfc.c new file +78
-0+mfc_debug_leave (); +return ret; +} + +/* Stream on */ +static int vidioc_streamon (struct file *file,void *priv, +enum v4l2_buf_type type) +{ +struct s5p_mfc_dev *dev =video_drvdata (file); +struct s5p_mfc_ctx *ctx = priv; +int ret = -EINVAL ; + +mfc_debug_enter (); +if (type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) + ret =vb2_streamon (&ctx->vq_src, type); +else + ret =vb2_streamon (&ctx->vq_dst, type); +mfc_debug ("ctx->src_queue_cnt = %d ctx->state = %d " +"ctx->dst_queue_cnt = %d ctx->dpb_count = %d\n" , + ctx->src_queue_cnt, ctx->state, ctx->dst_queue_cnt, + ctx->dpb_count); +mfc_debug_leave (); +return ret; +} + +/* Stream off, which equals to a pause */ +static int vidioc_streamoff (struct file *file,void *priv, +enum v4l2_buf_type type) +{ +struct s5p_mfc_dev *dev =video_drvdata (file); +struct s5p_mfc_ctx *ctx = priv; +int ret; + +mfc_debug_enter (); + ret = -EINVAL ; +if (type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) + ret =vb2_streamoff (&ctx->vq_src, type); +else + ret =vb2_streamoff (&ctx->vq_dst, type); +mfc_debug_leave (); +return ret; +} + +/* Query a ctrl */ +static int vidioc_queryctrl (struct file *file,void *priv, +struct v4l2_queryctrl *qc) +{ +struct v4l2_queryctrl *c; + + c =get_ctrl (qc->id); +if (!c) +return -EINVAL ; + *qc = *c; +return 0 ; +} + +/* Get ctrl */ +static int vidioc_g_ctrl (struct file *file,void *priv, +struct v4l2_control *ctrl) +{ +struct s5p_mfc_dev *dev =video_drvdata (file); +struct s5p_mfc_ctx *ctx = priv; + +mfc_debug_enter (); +switch (ctrl->id) { +case V4L2_CID_CODEC_LOOP_FILTER_MPEG4_ENABLE : + ctrl->value = ctx->loop_filter_mpeg4; +break ; +case V4L2_CID_CODEC_DISPLAY_DELAY : + ctrl->value = ctx->display_delay; +break ; +case V4L2_CID_CODEC_REQ_NUM_BUFS : +if (ctx->state >=MFCINST_DEC_HEAD_PARSED && + ctx->state <MFCINST_ENC_INIT ) { + ctrl->value = ctx->dpb_count; +break ; + }else if (ctx->state !=MFCINST_DEC_INIT ) { + v4l2_err(&dev->v4l2_dev, "Decoding notinitialised.\n");
drivers/media/video/s5p-mfc/s5p_mfc.c new file +29
-0+return -EINVAL ; + } + +/* Should wait for the header to be parsed */ +s5p_mfc_clean_ctx_int_flags (ctx); +s5p_mfc_wait_for_done_ctx (ctx, +S5P_FIMV_R2H_CMD_SEQ_DONE_RET ,1 ); +if (ctx->state >=MFCINST_DEC_HEAD_PARSED && + ctx->state <MFCINST_ENC_INIT ) { + ctrl->value = ctx->dpb_count; + }else { +v4l2_err (&dev->v4l2_dev, +"Decoding not initialised.\n" ); +return -EINVAL ; + } +break ; +case V4L2_CID_CODEC_SLICE_INTERFACE : + ctrl->value = ctx->slice_interface; +break ; +default : +v4l2_err (&dev->v4l2_dev,"Invalid control\n" ); +return -EINVAL ; + } +mfc_debug_leave (); +return 0 ; +} + +/* Check whether a ctrl value if correct */ +static int check_ctrl_val(struct s5p_mfc_ctx *ctx, struct v4l2_control*ctrl)
drivers/media/video/s5p-mfc/s5p_mfc.c new file +63
-0+{ +struct s5p_mfc_dev *dev = ctx->dev; +struct v4l2_queryctrl *c; + + c =get_ctrl (ctrl->id); +if (!c) +return -EINVAL ; +if (ctrl->value < c->minimum || ctrl->value > c->maximum + || (c->step !=0 && ctrl->value % c->step !=0 )) { +v4l2_err (&dev->v4l2_dev,"Invalid control value\n" ); +return -ERANGE ; + } +return 0 ; +} + +/* Set a ctrl */ +static int vidioc_s_ctrl (struct file *file,void *priv, +struct v4l2_control *ctrl) +{ +struct s5p_mfc_dev *dev =video_drvdata (file); +struct s5p_mfc_ctx *ctx = priv; +int ret =0 ; +int stream_on; + +mfc_debug_enter (); + stream_on = ctx->vq_src.streaming || ctx->vq_dst.streaming; + ret =check_ctrl_val (ctx, ctrl); +if (ret !=0 ) +return ret; +switch (ctrl->id) { +case V4L2_CID_CODEC_LOOP_FILTER_MPEG4_ENABLE : +if (stream_on) +return -EBUSY ; + ctx->loop_filter_mpeg4 = ctrl->value; +break ; +case V4L2_CID_CODEC_DISPLAY_DELAY : +if (stream_on) +return -EBUSY ; + ctx->display_delay = ctrl->value; +break ; +case V4L2_CID_CODEC_SLICE_INTERFACE : +if (stream_on) +return -EBUSY ; + ctx->slice_interface = ctrl->value; +break ; +default : +v4l2_err (&dev->v4l2_dev,"Invalid control\n" ); +return -EINVAL ; + } +mfc_debug_leave (); +return 0 ; +} +/* Get cropping information */ +static int vidioc_g_crop(struct file *file, void *priv, + struct v4l2_crop *cr) +{ + struct s5p_mfc_dev *dev = video_drvdata(file); + struct s5p_mfc_ctx *ctx = priv; + u32 left, right, top, bottom; + + mfc_debug_enter(); + if (ctx->state != MFCINST_DEC_HEAD_PARSED && + ctx->state != MFCINST_DEC_RUNNING && ctx->state !=
MFCINST_DEC_FINISHING
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 1 line
drivers/media/video/s5p-mfc/s5p_mfc.c new file +1
-0+ && ctx->state !=
MFCINST_DEC_FINISHED) {
Quoted 60 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +25
-0+mfc_debug ("%s-- with error\n" , __func__); +return -EINVAL ; + } +if (ctx->fmt->fourcc ==V4L2_PIX_FMT_H264 ) { + left =s5p_mfc_get_h_crop (ctx); + right = left >>S5P_FIMV_SHARED_CROP_RIGHT_SHIFT ; + left = left &S5P_FIMV_SHARED_CROP_LEFT_MASK ; + top =s5p_mfc_get_v_crop (ctx); + bottom = top >>S5P_FIMV_SHARED_CROP_BOTTOM_SHIFT ; + top = top &S5P_FIMV_SHARED_CROP_TOP_MASK ; + cr->c.left = left; + cr->c.top = top; + cr->c.width = ctx->img_width - left - right; + cr->c.height = ctx->img_height - top - bottom; +mfc_debug ("Cropping info [h264]: l=%d t=%d " +"w=%d h=%d (r=%d b=%d fw=%d fh=%d\n" , left, top, + cr->c.width, cr->c.height, right, bottom, + ctx->buf_width, ctx->buf_height); + }else { + cr->c.left =0 ; + cr->c.top =0 ; + cr->c.width = ctx->img_width; + cr->c.height = ctx->img_height; + mfc_debug("Cropping info: w=%d h=%d fw=%d " + "fh=%d\n", cr->c.width, cr->c.height, ctx-Quoted 1 line
buf_width,drivers/media/video/s5p-mfc/s5p_mfc.c new file +33
-0+ ctx->buf_height); + } +mfc_debug_leave (); +return 0 ; +} + +/* v4l2_ioctl_ops */ +static const struct v4l2_ioctl_ops s5p_mfc_ioctl_ops = { + .vidioc_querycap = vidioc_querycap, + .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, + .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap_mplane, + .vidioc_enum_fmt_vid_out = vidioc_enum_fmt_vid_out, + .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out_mplane, + .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt, + .vidioc_g_fmt_vid_out_mplane = vidioc_g_fmt, + .vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt, + .vidioc_try_fmt_vid_out_mplane = vidioc_try_fmt, + .vidioc_s_fmt_vid_cap_mplane = vidioc_s_fmt, + .vidioc_s_fmt_vid_out_mplane = vidioc_s_fmt, + .vidioc_reqbufs = vidioc_reqbufs, + .vidioc_querybuf = vidioc_querybuf, + .vidioc_qbuf = vidioc_qbuf, + .vidioc_dqbuf = vidioc_dqbuf, + .vidioc_streamon = vidioc_streamon, + .vidioc_streamoff = vidioc_streamoff, + .vidioc_queryctrl = vidioc_queryctrl, + .vidioc_g_ctrl = vidioc_g_ctrl, + .vidioc_s_ctrl = vidioc_s_ctrl, + .vidioc_g_crop = vidioc_g_crop, +}; + +/* Negotiate buffers */ +static int s5p_mfc_queue_setup(struct vb2_queue *vq, unsigned int
*buf_count,
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 1 line
drivers/media/video/s5p-mfc/s5p_mfc.c new file +1
-0+ unsigned int *plane_count, unsigned long
psize[],
Quoted 79 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +34
-0+ void *allocators[]) +{ +struct s5p_mfc_ctx *ctx = vq->drv_priv; +struct s5p_mfc_dev *dev = ctx->dev; + +mfc_debug_enter (); +/* Video output for decoding (source) +* this can be set after getting an instance */ +if (ctx->state ==MFCINST_DEC_GOT_INST && + vq->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) { +mfc_debug ("setting for VIDEO output\n" ); +/* A single plane is required for input */ + *plane_count =1 ; +if (*buf_count <1 ) + *buf_count =1 ; +if (*buf_count >MFC_MAX_BUFFERS ) + *buf_count =MFC_MAX_BUFFERS ; +/* Video capture for decoding (destination) +* this can be set after the header was parsed */ + }else if (ctx->state ==MFCINST_DEC_HEAD_PARSED && + vq->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ) { +mfc_debug ("setting for VIDEO capture\n" ); +/* Output plane count is 2 - one for Y and one for CbCr */ + *plane_count =2 ; +/* Setup buffer count */ +if (*buf_count < ctx->dpb_count) + *buf_count = ctx->dpb_count; +if (*buf_count > ctx->dpb_count +MFC_MAX_EXTRA_DPB ) + *buf_count = ctx->dpb_count +MFC_MAX_EXTRA_DPB ; +if (*buf_count >MFC_MAX_BUFFERS ) + *buf_count =MFC_MAX_BUFFERS ; + }else { + mfc_err("State seems invalid. State = %d, vq->type = %d\n", + ctx->state, vq-type);
drivers/media/video/s5p-mfc/s5p_mfc.c new file +3
-0+return -EINVAL ; + } + mfc_debug("%s, buffer count=%d, plane count=%d type=0x%x\n",
__func__,drivers/media/video/s5p-mfc/s5p_mfc.c new file +14
-0+ *buf_count, *plane_count, vq->type); + +if (ctx->state ==MFCINST_DEC_HEAD_PARSED && + vq->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ) { + psize[0 ] = ctx->luma_size; + psize[1 ] = ctx->chroma_size; + allocators[0 ] = ctx->dev->alloc_ctx[0 ]; + allocators[1 ] = ctx->dev->alloc_ctx[1 ]; + }else if (vq->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE && + ctx->state ==MFCINST_DEC_GOT_INST ) { + psize[0 ] = ctx->dec_src_buf_size; + allocators[0 ] = ctx->dev->alloc_ctx[1 ]; + }else { + mfc_err("Currently only decoding is supported. Decoding notinitalised.\n");
drivers/media/video/s5p-mfc/s5p_mfc.c new file +25
-0+return -EINVAL ; + } + +mfc_debug ("%s, plane=0, size=%lu\n" , __func__, psize[0 ]); +mfc_debug ("%s, plane=1, size=%lu\n" , __func__, psize[1 ]); +mfc_debug ("%s--\n" , __func__); +return 0 ; +} + +static int s5p_mfc_buf_init (struct vb2_buffer *vb) +{ +struct vb2_queue *vq = vb->vb2_queue; +struct s5p_mfc_ctx *ctx = vq->drv_priv; +struct s5p_mfc_dev *dev = ctx->dev; +unsigned int i; + +mfc_debug_enter (); +if (vq->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ) { +if (ctx->capture_state ==QUEUE_BUFS_MMAPED ) { +mfc_debug_leave (); +return 0 ; + } +for (i =0 ; i <= ctx->fmt->num_planes ; i++) { +if (vb2_cma_plane_paddr (vb, i) ==0 ) { +mfc_err ("Plane mem not allocated.\n" );
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+return -EINVAL ; + } + } +if (vb2_plane_size (vb,0 ) < ctx->luma_size || +vb2_plane_size (vb,1 ) < ctx->chroma_size) { +mfc_err ("Plane buffer (CAPTURE) is too small.\n" ); +return -EINVAL ; + } + mfc_debug("Size: 0=%lu 2=%lu\n", vb2_plane_size(vb, 0), + vb2_plane_size(vb,
1));
Quoted 145 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +3
-0+ i = vb->v4l2_buf.index; + ctx->dst_bufs[i].b = vb; + ctx->dst_bufs[i].cookie.raw.luma = vb2_cma_plane_paddr(vb,0);
drivers/media/video/s5p-mfc/s5p_mfc.c new file +1
-0+ ctx->dst_bufs[i].cookie.raw.chroma = vb2_cma_plane_paddr(vb,1);
drivers/media/video/s5p-mfc/s5p_mfc.c new file +9
-0+ ctx->dst_bufs_cnt++; + + }else if (vq->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) { +if (vb2_cma_plane_paddr (vb,0 ) ==0 ) { +mfc_err ("Plane memory not allocated.\n" ); +return -EINVAL ; + } + mfc_debug("Plane size: %ld, ctx->dec_src_buf_size: %d\n", + vb2_plane_size(vb, 0), ctx-
dec_src_buf_size);drivers/media/video/s5p-mfc/s5p_mfc.c new file +68
-0+if (vb2_plane_size (vb,0 ) < ctx->dec_src_buf_size) { +mfc_err ("Plane buffer (OUTPUT) is too small.\n" ); +return -EINVAL ; + } + i = vb->v4l2_buf.index; + ctx->src_bufs[i].b = vb; + ctx->src_bufs[i].cookie.stream =vb2_cma_plane_paddr (vb,0 ); + ctx->src_bufs_cnt++; + }else { +mfc_err ("s5p_mfc_buf_init: unknown queue type.\n" ); +return -EINVAL ; + } +mfc_debug_leave (); +return 0 ; +} + +static inline int s5p_mfc_get_new_ctx (struct s5p_mfc_dev *dev) +{ +unsigned long flags; +int new_ctx; +int cnt; +spin_lock_irqsave (&dev->condlock, flags); +mfc_debug ("Previos context: %d (bits %08lx)\n" , dev->curr_ctx, + dev->ctx_work_bits); + new_ctx = (dev->curr_ctx +1 ) %MFC_NUM_CONTEXTS ; + cnt =0 ; +while (!test_bit (new_ctx, &dev->ctx_work_bits)) { + new_ctx = (new_ctx +1 ) %MFC_NUM_CONTEXTS ; + cnt++; +if (cnt >MFC_NUM_CONTEXTS ) { +/* No contexts to run */ +spin_unlock_irqrestore (&dev->condlock, flags); +return -EAGAIN ; + } + } +spin_unlock_irqrestore (&dev->condlock, flags); +return new_ctx; +} + +static inline void s5p_mfc_run_dec_last_frames (struct s5p_mfc_ctx *ctx) +{ +struct s5p_mfc_dev *dev = ctx->dev; + +s5p_mfc_set_dec_stream_buffer (ctx,0 ,0 ,0 ); + dev->curr_ctx = ctx->num; +s5p_mfc_clean_ctx_int_flags (ctx); +s5p_mfc_decode_one_frame (ctx,1 ); +} + +static inline int s5p_mfc_run_dec_frame (struct s5p_mfc_ctx *ctx) +{ +struct s5p_mfc_dev *dev = ctx->dev; +struct s5p_mfc_buf *temp_vb; +unsigned long flags; + +spin_lock_irqsave (&dev->irqlock, flags); + +/* Frames are being decoded */ +if (list_empty (&ctx->src_queue)) { +mfc_debug ("No src buffers.\n" ); +spin_unlock_irqrestore (&dev->irqlock, flags); +return -EAGAIN ; + } +/* Get the next source buffer */ + temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); +mfc_debug ("Temp vb: %p\n" , temp_vb); +mfc_debug ("Src Addr: %08lx\n" ,vb2_cma_plane_paddr (temp_vb->b,0 )); + s5p_mfc_set_dec_stream_buffer(ctx, vb2_cma_plane_paddr(temp_vb->b,0),
drivers/media/video/s5p-mfc/s5p_mfc.c new file +57
-0+ 0, temp_vb->b->v4l2_planes[0].bytesused); +spin_unlock_irqrestore (&dev->irqlock, flags); + dev->curr_ctx = ctx->num; +s5p_mfc_clean_ctx_int_flags (ctx); +s5p_mfc_decode_one_frame (ctx, + temp_vb->b->v4l2_planes[0 ].bytesused ==0 ); + +return 0 ; +} + +static inline int s5p_mfc_run_get_inst_no (struct s5p_mfc_ctx *ctx) +{ +struct s5p_mfc_dev *dev = ctx->dev; +int ret; + +/* Preparing decoding - getting instance number */ +mfc_debug ("Getting instance number\n" ); + dev->curr_ctx = ctx->num; +s5p_mfc_clean_ctx_int_flags (ctx); + ret =s5p_mfc_open_inst (ctx); +if (ret) { +mfc_err ("Failed to create a new instance.\n" ); + ctx->state =MFCINST_DEC_ERROR ; + } +return ret; +} + +static inline int s5p_mfc_run_return_inst (struct s5p_mfc_ctx *ctx) +{ +struct s5p_mfc_dev *dev = ctx->dev; +int ret; + +/* Closing decoding instance */ +mfc_debug ("Returning instance number\n" ); + dev->curr_ctx = ctx->num; +s5p_mfc_clean_ctx_int_flags (ctx); + ret =s5p_mfc_return_inst_no (ctx); +if (ret) { +mfc_err ("Failed to return an instance.\n" ); + ctx->state =MFCINST_DEC_ERROR ; +return ret; + } +return ret; +} + +static inline void s5p_mfc_run_init_dec (struct s5p_mfc_ctx *ctx) +{ +struct s5p_mfc_dev *dev = ctx->dev; +unsigned long flags; +struct s5p_mfc_buf *temp_vb; + +/* Initializing decoding - parsing header */ +spin_lock_irqsave (&dev->irqlock, flags); +mfc_debug ("Preparing to init decoding.\n" ); + temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); +s5p_mfc_set_dec_desc_buffer (ctx); + mfc_debug("Header size: %d\n", temp_vb->b-Quoted 1 line
v4l2_planes[0].bytesused);
drivers/media/video/s5p-mfc/s5p_mfc.c new file +1
-0+ s5p_mfc_set_dec_stream_buffer(ctx, vb2_cma_plane_paddr(temp_vb->b,0),
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 5 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +5
-0+ 0, temp_vb->b->v4l2_planes[0].bytesused); +spin_unlock_irqrestore (&dev->irqlock, flags); + dev->curr_ctx = ctx->num; +mfc_debug ("paddr: %08x\n" , + (int)phys_to_virt(vb2_cma_plane_paddr(temp_vb->b,
0)));
Quoted 7 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +7
-0+s5p_mfc_clean_ctx_int_flags (ctx); +s5p_mfc_init_decode (ctx); +} + +static inline int s5p_mfc_run_init_dec_buffers (struct s5p_mfc_ctx *ctx) +{ +struct s5p_mfc_dev *dev = ctx->dev;
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+unsigned long flags; +struct s5p_mfc_buf *temp_vb; +int ret; +/* Header was parsed now starting processing +* First set the output frame buffers +* s5p_mfc_alloc_dec_buffers(ctx); */ + + if (ctx->capture_state != QUEUE_BUFS_MMAPED) { + mfc_err("It seems that not all destionation buffers were " + "mmaped.\nMFC requires that all destination are
mmaped
drivers/media/video/s5p-mfc/s5p_mfc.c line 1099
Quoted 10 lines
"
drivers/media/video/s5p-mfc/s5p_mfc.c new file +8
-0+ "before starting processing.\n"); +return -EAGAIN ; + } + +spin_lock_irqsave (&dev->irqlock, flags); + +if (list_empty (&ctx->src_queue)) { + mfc_err("Header has been deallocated in the middle of "
+ "initialization.\n")
;
Quoted 103 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +6
-0+spin_unlock_irqrestore (&dev->irqlock, flags); +return -EIO ; + } + + temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); + mfc_debug("Header size: %d\n", temp_vb->b-Quoted 1 line
v4l2_planes[0].bytesused);
drivers/media/video/s5p-mfc/s5p_mfc.c new file +1
-0+ s5p_mfc_set_dec_stream_buffer(ctx, vb2_cma_plane_paddr(temp_vb->b,0),
drivers/media/video/s5p-mfc/s5p_mfc.c new file +41
-0+ 0, temp_vb->b->v4l2_planes[0].bytesused); +spin_unlock_irqrestore (&dev->irqlock, flags); + dev->curr_ctx = ctx->num; +s5p_mfc_clean_ctx_int_flags (ctx); + ret =s5p_mfc_set_dec_frame_buffer (ctx); +if (ret) { +mfc_err ("Failed to alloc frame mem.\n" ); + ctx->state =MFCINST_DEC_ERROR ; + } +return ret; +} +/* Try running an operation on hardware */ +static void s5p_mfc_try_run (struct s5p_mfc_dev *dev) +{ +struct s5p_mfc_ctx *ctx; +int new_ctx; +unsigned int ret; + +mfc_debug ("Try run dev: %p\n" , dev); +/* Check whether hardware is not running */ +if (test_and_set_bit (0 , &dev->hw_lock) !=0 ) { +/* This is perfectly ok, the scheduled ctx should wait */ +mfc_debug ("Couldn't lock HW.\n" ); +return ; + } +/* Choose the context to run */ + new_ctx =s5p_mfc_get_new_ctx (dev); +if (new_ctx <0 ) { +/* No contexts to run */ +if (test_and_clear_bit (0 , &dev->hw_lock) ==0 ) { +mfc_err ("Failed to unlock hardware.\n" ); +return ; + } +mfc_debug ("No ctx is scheduled to be run.\n" ); +return ; + } +mfc_debug ("New context: %d\n" , new_ctx); + ctx = dev->ctx[new_ctx]; +mfc_debug ("Seting new context to %p\n" , ctx); +/* Got context to run in ctx */ + mfc_debug("ctx->dst_queue_cnt=%d ctx->dpb_count=%d ctx-Quoted 1 line
src_queue_cnt=%d\n",
drivers/media/video/s5p-mfc/s5p_mfc.c new file +51
-0+ ctx->dst_queue_cnt, ctx->dpb_count, ctx->src_queue_cnt); +mfc_debug ("ctx->state=%d\n" , ctx->state); +/* Last frame has already been sent to MFC +* Now obtaining frames from MFC buffer */ + ret =0 ; +switch (ctx->state) { +case MFCINST_DEC_FINISHING : +s5p_mfc_run_dec_last_frames (ctx); +break ; +case MFCINST_DEC_RUNNING : + ret =s5p_mfc_run_dec_frame (ctx); +break ; +case MFCINST_DEC_INIT : + ret =s5p_mfc_run_get_inst_no (ctx); +break ; +case MFCINST_DEC_RETURN_INST : + ret =s5p_mfc_run_return_inst (ctx); +break ; +case MFCINST_DEC_GOT_INST : +s5p_mfc_run_init_dec (ctx); +break ; +case MFCINST_DEC_HEAD_PARSED : + ret =s5p_mfc_run_init_dec_buffers (ctx); +break ; +default : + ret = -EAGAIN ; + } +if (ret) { +/* Free hardware lock */ +if (test_and_clear_bit (0 , &dev->hw_lock) ==0 ) { +mfc_err ("Failed to unlock hardware.\n" ); + } + } +} + +/* Queue buffer */ +static void s5p_mfc_buf_queue (struct vb2_buffer *vb) +{ +struct vb2_queue *vq = vb->vb2_queue; +struct s5p_mfc_ctx *ctx = vq->drv_priv; +struct s5p_mfc_dev *dev = ctx->dev; +unsigned long flags; +struct s5p_mfc_buf *mfc_buf; + +mfc_debug_enter (); +if (vq->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) { + mfc_buf = &ctx->src_bufs[vb->v4l2_buf.index]; +mfc_debug ("Src queue: %p\n" , &ctx->src_queue); + mfc_debug("Adding to src: %p (%08lx, %08x)\n", vb, + vb2_cma_plane_paddr(vb, 0), + ctx->src_bufs[vb-Quoted 1 line
v4l2_buf.index].cookie.stream);
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 9 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +9
-0+spin_lock_irqsave (&dev->irqlock, flags); +list_add_tail (&mfc_buf->list, &ctx->src_queue); + ctx->src_queue_cnt++; +spin_unlock_irqrestore (&dev->irqlock, flags); + }else if (vq->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ) { + mfc_buf = &ctx->dst_bufs[vb->v4l2_buf.index]; +mfc_debug ("Dst queue: %p\n" , &ctx->dst_queue); + mfc_debug("Adding to dst: %p (%lx)\n", vb, + vb2_cma_plane_paddr(vb,
0));
Quoted 58 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +2
-0+ mfc_debug("ADDING Flag before: %lx (%d)\n", + ctx->dec_dst_flag, vb-v4l2_buf.index);
drivers/media/video/s5p-mfc/s5p_mfc.c new file +49
-0+/* Mark destination as available for use by MFC */ +spin_lock_irqsave (&dev->irqlock, flags); +set_bit (vb->v4l2_buf.index, &ctx->dec_dst_flag); +mfc_debug ("ADDING Flag after: %lx\n" , ctx->dec_dst_flag); +list_add_tail (&mfc_buf->list, &ctx->dst_queue); + ctx->dst_queue_cnt++; +spin_unlock_irqrestore (&dev->irqlock, flags); + }else { +mfc_err ("Unsupported buffer type (%d)\n" , vq->type); + } +if (s5p_mfc_ctx_ready (ctx)) { +spin_lock_irqsave (&dev->condlock, flags); +set_bit (ctx->num, &dev->ctx_work_bits); +spin_unlock_irqrestore (&dev->condlock, flags); + } +s5p_mfc_try_run (dev); +mfc_debug_leave (); +} + +/* Let the streaming begin. */ +static int s5p_mfc_start_streaming (struct vb2_queue *q) +{ +struct s5p_mfc_ctx *ctx = q->drv_priv; +struct s5p_mfc_dev *dev = ctx->dev; + +unsigned long flags; +/* If context is ready then dev = work->data;schedule it to run */ +if (s5p_mfc_ctx_ready (ctx)) { +spin_lock_irqsave (&dev->condlock, flags); +set_bit (ctx->num, &dev->ctx_work_bits); +spin_unlock_irqrestore (&dev->condlock, flags); + } + +s5p_mfc_try_run (dev); +return 0 ; +} + +/* Thou shalt stream no more. */ +static int s5p_mfc_stop_streaming (struct vb2_queue *q) +{ +unsigned long flags; +struct s5p_mfc_ctx *ctx = q->drv_priv; +struct s5p_mfc_dev *dev = ctx->dev; + +if ((ctx->state ==MFCINST_DEC_FINISHING || + ctx->state ==MFCINST_DEC_RUNNING ) && + dev->curr_ctx == ctx->num && dev->hw_lock) { + ctx->state =MFCINST_DEC_ABORT ; + s5p_mfc_wait_for_done_ctx(ctx,
S5P_FIMV_R2H_CMD_FRAME_DONE_RET,drivers/media/video/s5p-mfc/s5p_mfc.c new file +5
-0+ 0); + } + ctx->state =MFCINST_DEC_FINISHED ; +spin_lock_irqsave (&dev->irqlock, flags); + s5p_mfc_error_cleanup_queue(&ctx->dst_queue,
drivers/media/video/s5p-mfc/s5p_mfc.c line 1274
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+ &ctx->vq_dst); +s5p_mfc_error_cleanup_queue (&ctx->src_queue, + &ctx->vq_src); +if (q->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ) +INIT_LIST_HEAD (&ctx->dst_queue); +if (q->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) +INIT_LIST_HEAD (&ctx->src_queue); +spin_unlock_irqrestore (&dev->irqlock, flags); +return 0 ; +}
This function is called by __vb2_queue_cancel().and __vb2_queue_cancel() can be
called by vb2_queue_release() or vb2_streamoff().
But, in this s5p_mfc_stop_streaming(),s5p_mfc_error_cleanup_queue() for src/dst
is runned regardless of q->type. Is that right ?
and in case of streamoff, queued bufs should be removed, then qbuf is needed before streamon again, so ctx->dst_queue_cnt = 0; ctx->src_queue_cnt = 0; is required
what do you think about this ?
Quoted 71 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +59
-0+ +void s5p_mfc_lock (struct vb2_queue *q) +{ +struct s5p_mfc_ctx *ctx = q->drv_priv; +struct s5p_mfc_dev *dev = ctx->dev; +mutex_lock (&dev->mfc_mutex); +} + +void s5p_mfc_unlock (struct vb2_queue *q) +{ +struct s5p_mfc_ctx *ctx = q->drv_priv; +struct s5p_mfc_dev *dev = ctx->dev; +mutex_unlock (&dev->mfc_mutex); +} + +/* Videobuf opts */ +static struct vb2_ops s5p_mfc_qops = { + .buf_queue = s5p_mfc_buf_queue, + .queue_setup = s5p_mfc_queue_setup, + .start_streaming = s5p_mfc_start_streaming, + .buf_init = s5p_mfc_buf_init, + .stop_streaming = s5p_mfc_stop_streaming, + .wait_prepare = s5p_mfc_unlock, + .wait_finish = s5p_mfc_lock, +}; + +static void s5p_mfc_handle_frame_all_extracted (struct s5p_mfc_ctx *ctx) +{ +struct s5p_mfc_dev *dev = ctx->dev; +struct s5p_mfc_buf *dst_buf; + + ctx->state =MFCINST_DEC_FINISHED ; +mfc_debug ("Decided to finish\n" ); + ctx->sequence++; +while (!list_empty (&ctx->dst_queue)) { + dst_buf =list_entry (ctx->dst_queue.next, + struct s5p_mfc_buf, list); +mfc_debug ("Cleaning up buffer: %d\n" , + dst_buf->b->v4l2_buf.index); +vb2_set_plane_payload (dst_buf->b,0 ,0 ); +vb2_set_plane_payload (dst_buf->b,1 ,0 ); +list_del (&dst_buf->list); + ctx->dst_queue_cnt--; + dst_buf->b->v4l2_buf.sequence = (ctx->sequence++); +if (s5p_mfc_get_pic_time_top (ctx) == +s5p_mfc_get_pic_time_bottom (ctx)) + dst_buf->b->v4l2_buf.field =V4L2_FIELD_NONE ; +else + dst_buf->b->v4l2_buf.field = +V4L2_FIELD_INTERLACED ; + ctx->dec_dst_flag &= ~(1 << dst_buf->b->v4l2_buf.index); +vb2_buffer_done (dst_buf->b,VB2_BUF_STATE_DONE ); +mfc_debug ("Cleaned up buffer: %d\n" , + dst_buf->b->v4l2_buf.index); + } +mfc_debug ("After cleanup\n" ); +} + +static void s5p_mfc_handle_frame_new(struct s5p_mfc_ctx *ctx, unsignedint err)
drivers/media/video/s5p-mfc/s5p_mfc.c new file +11
-0+{ +struct s5p_mfc_dev *dev = ctx->dev; +struct s5p_mfc_buf *dst_buf; +size_t dspl_y_addr =s5p_mfc_get_dspl_y_adr (); + + ctx->sequence++; +/* If frame is same as previous then skip and do not dequeue */ +if (s5p_mfc_get_frame_type () ==S5P_FIMV_DECODE_FRAME_SKIPPED ) +return ; +/* The MFC returns address of the buffer, now we have to +* check which videobuf does it correspond to */
drivers/media/video/s5p-mfc/s5p_mfc.c line 1356
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+list_for_each_entry (dst_buf, &ctx->dst_queue, list) { +mfc_debug ("Listing: %d\n" , dst_buf->b->v4l2_buf.index); +/* Check if this is the buffer we're looking for */ +if (vb2_cma_plane_paddr (dst_buf->b,0 ) == dspl_y_addr) { +list_del (&dst_buf->list); + ctx->dst_queue_cnt--; + dst_buf->b->v4l2_buf.sequence = ctx->sequence; +if (s5p_mfc_get_pic_time_top (ctx) == +s5p_mfc_get_pic_time_bottom (ctx)) + dst_buf->b->v4l2_buf.field =
V4L2_FIELD_NONE;
Quoted 7 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+else + dst_buf->b->v4l2_buf.field = +V4L2_FIELD_INTERLACED ; + vb2_set_plane_payload(dst_buf->b, 0, ctx-
luma_size);drivers/media/video/s5p-mfc/s5p_mfc.c new file +1
-0+ vb2_set_plane_payload(dst_buf->b, 1, ctx-
chroma_size);
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 7 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +7
-0+clear_bit (dst_buf->b->v4l2_buf.index, + &ctx->dec_dst_flag); +if (err) { +vb2_buffer_done (dst_buf->b, +VB2_BUF_STATE_ERROR ); + }else { + vb2_buffer_done(dst_buf->b,
VB2_BUF_STATE_DONE);
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 9 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +9
-0+ } +break ; + } + } +} + +/* Handle frame decoding interrupt */ +static void s5p_mfc_handle_frame (struct s5p_mfc_ctx *ctx, + unsigned int reason, unsigned int
err)
Quoted 16 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +16
-0+{ +struct s5p_mfc_dev *dev = ctx->dev; +unsigned int dst_frame_status; +struct s5p_mfc_buf *src_buf; +unsigned long flags; + + dst_frame_status =s5p_mfc_get_dspl_status () + &S5P_FIMV_DEC_STATUS_DECODING_STATUS_MASK ; +mfc_debug ("Frame Status: %x\n" , dst_frame_status); +spin_lock_irqsave (&dev->irqlock, flags); +/* All frames remaining in the buffer have been extracted */ +if (dst_frame_status ==S5P_FIMV_DEC_STATUS_DECODING_EMPTY ) { +s5p_mfc_handle_frame_all_extracted (ctx); + } + +/* A frame has been decoded and is in the buffer */
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+if (dst_frame_status ==S5P_FIMV_DEC_STATUS_DISPLAY_ONLY || + dst_frame_status ==S5P_FIMV_DEC_STATUS_DECODING_DISPLAY ) { +s5p_mfc_handle_frame_new (ctx, err); + }else { +mfc_debug ("No frame decode.\n" ); + } +/* Mark source buffer as complete */ +if (dst_frame_status !=S5P_FIMV_DEC_STATUS_DISPLAY_ONLY + && !list_empty (&ctx->src_queue)) { + src_buf = list_entry(ctx->src_queue.next, struct
s5p_mfc_buf,
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 5 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +2
-0+ list); + mfc_debug("Packed PB test. Size:%d, prev offset: %ld, thisrun:"
drivers/media/video/s5p-mfc/s5p_mfc.c new file +2
-0+" %d\n" , src_buf->b->v4l2_planes[0 ].bytesused, + ctx->consumed_stream,
s5p_mfc_get_consumed_stream());
Quoted 16 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +2
-0+ ctx->consumed_stream +=s5p_mfc_get_consumed_stream (); + if (s5p_mfc_get_frame_type() ==
S5P_FIMV_DECODE_FRAME_P_FRAMEdrivers/media/video/s5p-mfc/s5p_mfc.c new file +2
-0+ && ctx->consumed_stream < + src_buf->b-v4l2_planes[0].bytesused) {
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+/* Run MFC again on the same buffer */ +mfc_debug ("Running again the same buffer.\n" ); + s5p_mfc_set_dec_stream_buffer(ctx, + src_buf->cookie.stream, ctx-
consumed_stream,drivers/media/video/s5p-mfc/s5p_mfc.c new file +2
-0+ src_buf->b->v4l2_planes[0 ].bytesused - + ctx-
consumed_stream);drivers/media/video/s5p-mfc/s5p_mfc.c new file +2
-0+ dev->curr_ctx = ctx->num; +s5p_mfc_clean_ctx_int_flags (ctx);
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+spin_unlock_irqrestore (&dev->irqlock, flags); +s5p_mfc_clear_int_flags (); +wake_up_ctx (ctx, reason, err); +s5p_mfc_decode_one_frame (ctx,0 ); +return ; + }else { +mfc_debug ("MFC needs next buffer.\n" ); +/* Advance to next buffer */ +if (src_buf->b->v4l2_planes[0 ].bytesused ==0 ) { + mfc_debug("Setting ctx->state to
FINISHING\n");
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 12 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +12
-0+ ctx->state =MFCINST_DEC_FINISHING ; + } + ctx->consumed_stream =0 ; +list_del (&src_buf->list); + ctx->src_queue_cnt--; +vb2_buffer_done (src_buf->b,VB2_BUF_STATE_DONE ); + } + } +spin_unlock_irqrestore (&dev->irqlock, flags); +mfc_debug ("Assesing whether this context should be run again.\n" ); +if ((ctx->src_queue_cnt ==0 && ctx->state !=MFCINST_DEC_FINISHING ) + || ctx->dst_queue_cnt < ctx->dpb_count)
{
Quoted 106 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+mfc_debug ("No need to run again.\n" ); +clear_work_bit (ctx); + } + mfc_debug("After assesing whether this context should be runagain.\n");
drivers/media/video/s5p-mfc/s5p_mfc.c new file +54
-0+s5p_mfc_clear_int_flags (); +wake_up_ctx (ctx, reason, err); +if (test_and_clear_bit (0 , &dev->hw_lock) ==0 ) +BUG (); +s5p_mfc_try_run (dev); +} + +/* Error handling for interrupt */ +static inline void s5p_mfc_handle_error (struct s5p_mfc_ctx *ctx, +unsigned int reason,unsigned int err) +{ +struct s5p_mfc_dev *dev = ctx->dev; +unsigned long flags; + +mfc_err ("Interrupt Error: %08x\n" , err); +s5p_mfc_clear_int_flags (); +wake_up_dev (dev, reason, err); +/* If no context is available then all necessary +* processing has been done. */ +if (ctx ==0 ) +return ; +/* Error recovery is dependent on the state of context */ +switch (ctx->state) { +case MFCINST_DEC_INIT : +/* This error had to happen while acquireing instance */ +case MFCINST_DEC_GOT_INST : +/* This error had to happen while parsing the header */ +case MFCINST_DEC_HEAD_PARSED : +/* This error had to happen while setting dst buffers */ +case MFCINST_DEC_RETURN_INST : +/* This error had to happen while releasing instance */ +clear_work_bit (ctx); +wake_up_ctx (ctx, reason, err); +if (test_and_clear_bit (0 , &dev->hw_lock) ==0 ) +BUG (); +break ; +case MFCINST_DEC_FINISHING : +case MFCINST_DEC_FINISHED : +case MFCINST_DEC_RUNNING : +/* It is higly probable that an error occured +* while decoding a frame */ +clear_work_bit (ctx); + ctx->state =MFCINST_DEC_ERROR ; +/* Mark all dst buffers as having an error */ +spin_lock_irqsave (&dev->irqlock, flags); +s5p_mfc_error_cleanup_queue (&ctx->dst_queue, &ctx->vq_dst); +/* Mark all src buffers as having an error */ +s5p_mfc_error_cleanup_queue (&ctx->src_queue, &ctx->vq_src); +spin_unlock_irqrestore (&dev->irqlock, flags); +if (test_and_clear_bit (0 , &dev->hw_lock) ==0 ) +BUG (); +break ; +default : + mfc_err("Encountered an error interrupt which had not beenhandled.\n");
drivers/media/video/s5p-mfc/s5p_mfc.c new file +42
-0+break ; + } +return ; +} + +/* Interrupt processing */ +static irqreturn_t s5p_mfc_irq (int irq,void *priv) +{ +struct s5p_mfc_dev *dev = priv; +struct s5p_mfc_buf *src_buf; +struct s5p_mfc_ctx *ctx; +unsigned int reason; +unsigned int err; +unsigned long flags; + +mfc_debug_enter (); +/* Reset the timeout watchdog */ +atomic_set (&dev->watchdog_cnt,0 ); + ctx = dev->ctx[dev->curr_ctx]; +/* Get the reason of interrupt and the error code */ + reason =s5p_mfc_get_int_reason (); + err =s5p_mfc_get_int_err (); +mfc_debug ("Int reason: %d (err: %08x)\n" , reason, err); +switch (reason) { +case S5P_FIMV_R2H_CMD_DECODE_ERR_RET : +/* An error has occured */ +if (ctx->state ==MFCINST_DEC_RUNNING && + err >=S5P_FIMV_ERR_WARNINGS_START ) +s5p_mfc_handle_frame (ctx, reason, err); +else +s5p_mfc_handle_error (ctx, reason, err); +break ; +case S5P_FIMV_R2H_CMD_SLICE_DONE_RET : +case S5P_FIMV_R2H_CMD_FRAME_DONE_RET : +s5p_mfc_handle_frame (ctx, reason, err); +break ; +case S5P_FIMV_R2H_CMD_SEQ_DONE_RET : +if (ctx->fmt->fourcc !=V4L2_PIX_FMT_DIVX3 ) { + ctx->img_width =s5p_mfc_get_img_width (); + ctx->img_height =s5p_mfc_get_img_height (); + } + ctx->buf_width = ALIGN(ctx->img_width,
S5P_FIMV_NV12T_VALIGN);drivers/media/video/s5p-mfc/s5p_mfc.c new file +1
-0+ ctx->buf_height = ALIGN(ctx->img_height,
S5P_FIMV_NV12T_HALIGN);
drivers/media/video/s5p-mfc/s5p_mfc.c line 1544
Quoted 4 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+mfc_debug ("SEQ Done: Movie dimensions %dx%d, " +"buffer dimensions: %dx%d\n" , ctx->img_width, + ctx->img_height, ctx->buf_width, ctx->buf_height); + ctx->luma_size = ALIGN(ctx->buf_width * ctx->buf_height,
+ S5P_FIMV_DEC_BUF_ALI
GN);
Quoted 55 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +55
-0+ ctx->chroma_size =ALIGN (ctx->buf_width * +ALIGN (ctx->img_height /2 , +S5P_FIMV_NV12T_HALIGN ), +S5P_FIMV_DEC_BUF_ALIGN ); +if (ctx->codec_mode ==S5P_FIMV_CODEC_H264_DEC ) + ctx->mv_size =ALIGN (ctx->buf_width * +ALIGN (ctx->buf_height /4 , +S5P_FIMV_NV12T_HALIGN ), +S5P_FIMV_DEC_BUF_ALIGN ); +else + ctx->mv_size =0 ; + ctx->dpb_count =s5p_mfc_get_dpb_count (); +if (ctx->img_width !=0 && ctx->img_width !=0 ) + { + ctx->state =MFCINST_DEC_HEAD_PARSED ; +s5p_mfc_clear_int_flags (); +clear_work_bit (ctx); + }else { + ctx->state =MFCINST_DEC_ERROR ; +s5p_mfc_clear_int_flags (); +clear_work_bit (ctx); + } +if (test_and_clear_bit (0 , &dev->hw_lock) ==0 ) +BUG (); +s5p_mfc_try_run (dev); +wake_up_ctx (ctx, reason, err); +break ; +case S5P_FIMV_R2H_CMD_OPEN_INSTANCE_RET : + ctx->inst_no =s5p_mfc_get_inst_no (); + ctx->state =MFCINST_DEC_GOT_INST ; +clear_work_bit (ctx); +wake_up_interruptible (&ctx->queue); + goto irq_cleanup_hw; +break ; +case S5P_FIMV_R2H_CMD_CLOSE_INSTANCE_RET : +clear_work_bit (ctx); + ctx->state =MFCINST_FREE ; +wake_up (&ctx->queue); + goto irq_cleanup_hw; +break ; +case S5P_FIMV_R2H_CMD_SYS_INIT_RET : +case S5P_FIMV_R2H_CMD_FW_STATUS_RET : +if (ctx) +clear_work_bit (ctx); +s5p_mfc_clear_int_flags (); +wake_up_dev (dev, reason, err); +clear_bit (0 , &dev->hw_lock); +break ; +case S5P_FIMV_R2H_CMD_INIT_BUFFERS_RET : +s5p_mfc_clear_int_flags (); + ctx->int_type = reason; + ctx->int_err = err; + ctx->int_cond =1 ; +spin_lock (&dev->condlock); +clear_bit (ctx->num, &dev->ctx_work_bits);
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+spin_unlock (&dev->condlock); +if (err ==0 ) { + ctx->state =MFCINST_DEC_RUNNING ; +spin_lock_irqsave (&dev->irqlock, flags); +if (!list_empty (&ctx->src_queue)) { + src_buf =list_entry (ctx->src_queue.next, + struct s5p_mfc_buf, list); +list_del (&src_buf->list); + ctx->src_queue_cnt--; + vb2_buffer_done(src_buf->b,
VB2_BUF_STATE_DONE);
Quoted 66 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +65
-0+ } +spin_unlock_irqrestore (&dev->irqlock, flags); +if (test_and_clear_bit (0 , &dev->hw_lock) ==0 ) +BUG (); +wake_up_interruptible (&ctx->queue); +s5p_mfc_try_run (dev); + }else { +if (test_and_clear_bit (0 , &dev->hw_lock) ==0 ) +BUG (); +wake_up_interruptible (&ctx->queue); + } +break ; +default : +mfc_debug ("Unknown int reason.\n" ); +s5p_mfc_clear_int_flags (); + } +mfc_debug_leave (); +return IRQ_HANDLED ; +irq_cleanup_hw: +s5p_mfc_clear_int_flags (); + ctx->int_type = reason; + ctx->int_err = err; + ctx->int_cond =1 ; +if (test_and_clear_bit (0 , &dev->hw_lock) ==0 ) +mfc_err ("Failed to unlock hw.\n" ); +s5p_mfc_try_run (dev); +mfc_debug ("%s-- (via irq_cleanup_hw)\n" , __func__); +return IRQ_HANDLED ; +} + +/* Open an MFC node */ +static int s5p_mfc_open (struct file *file) +{ +struct s5p_mfc_ctx *ctx =NULL ; +struct s5p_mfc_dev *dev =video_drvdata (file); +struct vb2_queue *q; +unsigned long flags; +int ret =0 ; + +mfc_debug_enter (); + dev->num_inst++;/* It is guarded by mfc_mutex in vfd */ +/* Allocate memory for context */ + ctx =kzalloc (sizeof *ctx,GFP_KERNEL ); +if (!ctx) { +mfc_err ("Not enough memory.\n" ); + ret = -ENOMEM ; + goto out_open; + } + file->private_data = ctx; + ctx->dev = dev; +INIT_LIST_HEAD (&ctx->src_queue); +INIT_LIST_HEAD (&ctx->dst_queue); + ctx->src_queue_cnt =0 ; + ctx->dst_queue_cnt =0 ; +/* Get context number */ + ctx->num =0 ; +while (dev->ctx[ctx->num]) { + ctx->num++; +if (ctx->num >=MFC_NUM_CONTEXTS ) { +mfc_err ("Too many open contexts.\n" ); + ret = -EBUSY ; + goto out_open; + } + } +/* Mark context as idle */
drivers/media/video/s5p-mfc/s5p_mfc.c line 1685
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+spin_lock_irqsave (&dev->condlock, flags); +clear_bit (ctx->num, &dev->ctx_work_bits); +spin_unlock_irqrestore (&dev->condlock, flags); + dev->ctx[ctx->num] = ctx; +/* Default format */ + ctx->fmt = &formats[0 ]; + ctx->inst_no =-1 ; +/* Load firmware if this is the first instance */ +if (dev->num_inst ==1 ) { + dev->watchdog_timer.expires = jiffies +
+ msecs_to_jiffies(MFC_WATCHDOG_INTERV
AL);
Quoted 222 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +204
-0+add_timer (&dev->watchdog_timer); + +/* Load the FW */ + ret =s5p_mfc_alloc_firmware (dev); +if (ret !=0 ) + goto out_open_2a; + ret =s5p_mfc_load_firmware (dev); +if (ret !=0 ) + goto out_open_2; +mfc_debug ("Enabling clocks.\n" ); +clk_enable (dev->clock1); +clk_enable (dev->clock2); +/* Init the FW */ + ret =s5p_mfc_init_hw (dev); +if (ret !=0 ) + goto out_open_3; + } + +/* Init videobuf2 queue for CAPTURE */ + q = &ctx->vq_dst; + q->type =V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ; + q->io_modes =VB2_MMAP ; + q->drv_priv = ctx; + q->ops = &s5p_mfc_qops; + q->mem_ops = &vb2_cma_memops; + ret =vb2_queue_init (q); +if (ret) { +mfc_err ("Failed to initialize videobuf2 queue(capture)\n" ); + goto out_open_3; + } + +/* Init videobuf2 queue for OUTPUT */ + q = &ctx->vq_src; + q->type =V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ; + q->io_modes =VB2_MMAP ; + q->drv_priv = ctx; + q->ops = &s5p_mfc_qops; + q->mem_ops = &vb2_cma_memops; + ret =vb2_queue_init (q); +if (ret) { +mfc_err ("Failed to initialize videobuf2 queue(output)\n" ); + goto out_open_3; + } +init_waitqueue_head (&ctx->queue); +mfc_debug ("%s-- (via irq_cleanup_hw)\n" , __func__); +return ret; +/* Deinit when failure occured */ +out_open_3: +if (dev->num_inst ==1 ) { +clk_disable (dev->clock1); +clk_disable (dev->clock2); +s5p_mfc_release_firmware (dev); + } +out_open_2: +s5p_mfc_release_firmware (dev); +out_open_2a: + dev->ctx[ctx->num] =0 ; +kfree (ctx); +del_timer_sync (&dev->watchdog_timer); +out_open: + dev->num_inst--; +mfc_debug_leave (); +return ret; +} + +/* Release MFC context */ +static int s5p_mfc_release (struct file *file) +{ +struct s5p_mfc_ctx *ctx = file->private_data; +struct s5p_mfc_dev *dev = ctx->dev; +unsigned long flags; + +mfc_debug_enter (); + +vb2_queue_release (&ctx->vq_src); +vb2_queue_release (&ctx->vq_dst); + +/* Mark context as idle */ +spin_lock_irqsave (&dev->condlock, flags); +clear_bit (ctx->num, &dev->ctx_work_bits); +spin_unlock_irqrestore (&dev->condlock, flags); +/* If instance was initialised then +* return instance and free reosurces */ +if (ctx->inst_no !=MFC_NO_INSTANCE_SET ) { + ctx->state =MFCINST_DEC_RETURN_INST ; +spin_lock_irqsave (&dev->condlock, flags); +set_bit (ctx->num, &dev->ctx_work_bits); +spin_unlock_irqrestore (&dev->condlock, flags); +s5p_mfc_clean_ctx_int_flags (ctx); +s5p_mfc_try_run (dev); +/* Wait until instance is returned or timeout occured */ +if (s5p_mfc_wait_for_done_ctx + (ctx,S5P_FIMV_R2H_CMD_CLOSE_INSTANCE_RET ,0 )) { +mfc_err ("Err returning instance.\n" ); + } +/* Free resources */ +s5p_mfc_release_dec_buffers (ctx); +s5p_mfc_release_instance_buffer (ctx); +s5p_mfc_release_dec_desc_buffer (ctx); + ctx->inst_no =-1 ; + } +/* hardware locking scheme */ +if (dev->curr_ctx == ctx->num) +clear_bit (0 , &dev->hw_lock); + dev->num_inst--; +if (dev->num_inst ==0 ) { +s5p_mfc_deinit_hw (dev); +mfc_debug ("Disabling clocks...\n" ); +clk_disable (dev->clock1); +clk_disable (dev->clock2); +s5p_mfc_release_firmware (dev); +del_timer_sync (&dev->watchdog_timer); + } + + dev->ctx[ctx->num] =0 ; +kfree (ctx); +mfc_debug_leave (); +return 0 ; +} + +/* Poll */ +static unsigned int s5p_mfc_poll (struct file *file, +struct poll_table_struct *wait) +{ +struct s5p_mfc_ctx *ctx = file->private_data; + +return vb2_poll (&ctx->vq_dst, file, wait); +} + +/* Mmap */ +static int s5p_mfc_mmap (struct file *file,struct vm_area_struct *vma) +{ +struct s5p_mfc_ctx *ctx = file->private_data; +struct s5p_mfc_dev *dev = ctx->dev; +unsigned long offset = vma->vm_pgoff <<PAGE_SHIFT ; +int ret; + +mfc_debug_enter (); +if (offset <DST_QUEUE_OFF_BASE ) { +mfc_debug ("mmaping source.\n" ); + ret =vb2_mmap (&ctx->vq_src, vma); + }else {/* capture */ +mfc_debug ("mmaping destination.\n" ); + vma->vm_pgoff -= (DST_QUEUE_OFF_BASE >>PAGE_SHIFT ); + ret =vb2_mmap (&ctx->vq_dst, vma); + } +mfc_debug_leave (); +return ret; +} + +/* v4l2 ops */ +static const struct v4l2_file_operations s5p_mfc_fops = { + .owner =THIS_MODULE , + .open = s5p_mfc_open, + .release = s5p_mfc_release, + .poll = s5p_mfc_poll, + .unlocked_ioctl = video_ioctl2, + .mmap = s5p_mfc_mmap, +}; + +/* videodec structure */ +static struct video_device s5p_mfc_videodev = { + .name =S5P_MFC_NAME , + .fops = &s5p_mfc_fops, + .ioctl_ops = &s5p_mfc_ioctl_ops, + .minor =-1 , + .release = video_device_release, +}; + +/* MFC probe function */ +static int s5p_mfc_probe (struct platform_device *pdev) +{ +struct s5p_mfc_dev *dev; +struct video_device *vfd; +struct resource *res; +int ret = -ENOENT ; +size_t size; + +pr_debug ("%s++\n" , __func__); + dev =kzalloc (sizeof *dev,GFP_KERNEL ); +if (!dev) { +dev_err (&pdev->dev,"Not enough memory for MFC device.\n" ); +return -ENOMEM ; + } + +spin_lock_init (&dev->irqlock); +spin_lock_init (&dev->condlock); +dev_dbg (&pdev->dev,"Initialised spin lock\n" ); + dev->plat_dev = pdev; +if (!dev->plat_dev) { +dev_err (&pdev->dev,"No platform data specified\n" ); + ret = -ENODEV ; + goto free_dev; + } +dev_dbg (&pdev->dev,"Getting clocks\n" ); + dev->clock1 =clk_get (&pdev->dev,"sclk_mfc" ); + dev->clock2 =clk_get (&pdev->dev,"mfc" ); +if (IS_ERR (dev->clock1) ||IS_ERR (dev->clock2)) { +dev_err (&pdev->dev,"failed to get mfc clock source\n" ); + goto free_clk; + } + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (res ==NULL ) { + dev_err(&pdev->dev, "failed to get memory regionresource.\n");
drivers/media/video/s5p-mfc/s5p_mfc.c new file +16
-0+ ret = -ENOENT ; + goto probe_out1; + } + size = (res->end - res->start) +1 ; + dev->mfc_mem =request_mem_region (res->start, size, pdev->name); +if (dev->mfc_mem ==NULL ) { +dev_err (&pdev->dev,"failed to get memory region.\n" ); + ret = -ENOENT ; + goto probe_out2; + } + dev->regs_base =ioremap (dev->mfc_mem->start, + dev->mfc_mem->end - dev->mfc_mem->start +1 ); +if (dev->regs_base ==NULL ) { +dev_err (&pdev->dev,"failed to ioremap address region.\n" ); + ret = -ENOENT ; + goto probe_out3;
drivers/media/video/s5p-mfc/s5p_mfc.c line 1916
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+ } + dev->regs_base = dev->regs_base; + res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); +if (res ==NULL ) { +dev_err (&pdev->dev,"failed to get irq resource.\n" ); + ret = -ENOENT ; + goto probe_out4; + } + dev->irq = res->start; + ret = request_irq(dev->irq, s5p_mfc_irq, IRQF_DISABLED, pdev->name,
+ dev)
;
Quoted 127 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +12
-0+if (ret !=0 ) { +dev_err (&pdev->dev,"Failed to install irq (%d)\n" , ret); + goto probe_out5; + } +mutex_init (&dev->mfc_mutex); + ret =v4l2_device_register (&pdev->dev, &dev->v4l2_dev); +if (ret) + goto probe_out6; +init_waitqueue_head (&dev->queue); + vfd =video_device_alloc (); +if (!vfd) { + v4l2_err(&dev->v4l2_dev, "Failed to allocate videodevice\n");
drivers/media/video/s5p-mfc/s5p_mfc.c new file +20
-0+ ret = -ENOMEM ; + goto unreg_dev; + } + *vfd = s5p_mfc_videodev; + vfd->lock = &dev->mfc_mutex; + +video_set_drvdata (vfd, dev); +snprintf (vfd->name,sizeof (vfd->name),"%s" , s5p_mfc_videodev.name); + dev->vfd = vfd; + +platform_set_drvdata (pdev, dev); + dev->hw_lock =0 ; + dev->watchdog_workqueue =create_singlethread_workqueue ("s5p-mfc" ); +INIT_WORK (&dev->watchdog_work, s5p_mfc_watchdog_worker); +atomic_set (&dev->watchdog_cnt,0 ); +init_timer (&dev->watchdog_timer); + dev->watchdog_timer.data = (unsigned long )dev; + dev->watchdog_timer.function = s5p_mfc_watchdog; + + dev->alloc_ctx = vb2_cma_init_multi(&pdev->dev,
MFC_CMA_ALLOC_CTX_NUM,drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+ s5p_mem_types, s5p_mem_alignments); +if (IS_ERR (dev->alloc_ctx)) { +mfc_err ("Couldn't prepare allocator ctx.\n" ); + ret =PTR_ERR (dev->alloc_ctx); + goto alloc_ctx_fail; + } + + ret =video_register_device (vfd,VFL_TYPE_GRABBER ,0 ); +if (ret) { + v4l2_err(&dev->v4l2_dev, "Failed to register videodevice\n");
drivers/media/video/s5p-mfc/s5p_mfc.c new file +82
-0+video_device_release (vfd); + goto rel_vdev; + } +v4l2_info (&dev->v4l2_dev,"Device registered as /dev/video%d\n" , + vfd->num); +pr_debug ("%s--\n" , __func__); +return 0 ; + +/* Deinit MFC if probe had failed */ +rel_vdev: +vb2_cma_cleanup_multi (dev->alloc_ctx); +alloc_ctx_fail: +unreg_dev: +v4l2_device_unregister (&dev->v4l2_dev); + +probe_out6: +free_irq (dev->irq, dev); +probe_out5: +probe_out4: +iounmap (dev->regs_base); + dev->regs_base =NULL ; +probe_out3: +release_resource (dev->mfc_mem); +kfree (dev->mfc_mem); +probe_out2: +probe_out1: +clk_put (dev->clock1); +clk_put (dev->clock2); +free_clk: + +free_dev: +kfree (dev); +pr_debug ("%s-- with error\n" , __func__); +return ret; +} + +/* Remove the driver */ +static int s5p_mfc_remove (struct platform_device *pdev) +{ +struct s5p_mfc_dev *dev =platform_get_drvdata (pdev); + +dev_dbg (&pdev->dev,"%s++\n" , __func__); +v4l2_info (&dev->v4l2_dev,"Removing %s\n" , pdev->name); +del_timer_sync (&dev->watchdog_timer); +flush_workqueue (dev->watchdog_workqueue); +destroy_workqueue (dev->watchdog_workqueue); +video_unregister_device (dev->vfd); +v4l2_device_unregister (&dev->v4l2_dev); +vb2_cma_cleanup_multi (dev->alloc_ctx); +mfc_debug ("Will now deinit HW\n" ); +s5p_mfc_deinit_hw (dev); +free_irq (dev->irq, dev); +iounmap (dev->regs_base); +if (dev->mfc_mem !=NULL ) { +release_resource (dev->mfc_mem); +kfree (dev->mfc_mem); + dev->mfc_mem =NULL ; + } +clk_put (dev->clock1); +clk_put (dev->clock2); +kfree (dev); +dev_dbg (&pdev->dev,"%s--\n" , __func__); +return 0 ; +} + +static int s5p_mfc_suspend (struct device *dev) +{ +return 0 ; +} + +static int s5p_mfc_resume (struct device *dev) +{ +return 0 ; +} + +/* Power management */ +static const struct dev_pm_ops s5p_mfc_pm_ops = { + .suspend = s5p_mfc_suspend, + .resume = s5p_mfc_resume, +}; + +static struct platform_driver s5p_mfc_pdrv = {
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+ .probe = s5p_mfc_probe, + .remove = __devexit_p(s5p_mfc_remove), + .driver = { + .name = S5P_MFC_NAME, + .owner = THIS_MODULE, + .pm = &s5p_mfc_pm_ops}, +}; + +static char banner[]__initdata = + "S5P MFC V4L2 Driver, (c) 2010 Samsung
Electronics\n";
Quoted 457 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +21
-0+ +static int __init s5p_mfc_init (void ) +{ +pr_info ("%s" , banner); +if (platform_driver_register (&s5p_mfc_pdrv) !=0 ) { +pr_err ("Platform device registration failed..\n" ); +return -1 ; + } +return 0 ; +} + +static void __devexit s5p_mfc_exit(void) +{ +platform_driver_unregister (&s5p_mfc_pdrv); +} + +module_init (s5p_mfc_init); +module_exit (s5p_mfc_exit); + +MODULE_LICENSE ("GPL" ); +MODULE_AUTHOR ("Kamil Debski <[email protected]>" );drivers/media/video/s5p-mfc/s5p_mfc_common.h new file +11
-0@@ -0,0 +1,224 @@ +/* +* Samsung S5P Multi Format Codec v 5.0 +* +* This file contains definitions of enums and structs used by the codec +* driver. +* +* Copyright (c) 2010 Samsung Electronics Co., Ltd. +* Kamil Debski, <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version
+ */drivers/media/video/s5p-mfc/s5p_mfc_common.h new file +210
-0+ +#ifndef S5P_MFC_COMMON_H_ +#define S5P_MFC_COMMON_H_ + +#include "regs-mfc5.h" +#include <linux/videodev2.h> + +#include <media/v4l2-device.h> +#include <media/v4l2-ioctl.h> + +#include <media/videobuf2-core.h> + +#define MFC_MAX_EXTRA_DPB 5 +#define MFC_MAX_BUFFERS 32 +#define MFC_FRAME_PLANES 2 + +#define MFC_NUM_CONTEXTS 4 +/* Interrupt timeout */ +#define MFC_INT_TIMEOUT 2000 +/* Busy wait timeout */ +#define MFC_BW_TIMEOUT 500 +/* Watchdog interval */ +#define MFC_WATCHDOG_INTERVAL 1000 +/* After how many executions watchdog should assume lock up */ +#define MFC_WATCHDOG_CNT 10 + +#define MFC_NO_INSTANCE_SET -1 + +/** +* enum s5p_mfc_inst_state - The state of an MFC instance. +*/ +enum s5p_mfc_inst_state { +MFCINST_FREE =0 , +MFCINST_DEC_INIT =100 , +MFCINST_DEC_GOT_INST , +MFCINST_DEC_HEAD_PARSED , +MFCINST_DEC_BUFS_SET , +MFCINST_DEC_RUNNING , +MFCINST_DEC_FINISHING , +MFCINST_DEC_FINISHED , +MFCINST_DEC_RETURN_INST , +MFCINST_DEC_ERROR , +MFCINST_DEC_ABORT , +MFCINST_ENC_INIT =200 , +}; + +/** +* enum s5p_mfc_queue_state - The state of buffer queue. +*/ +enum s5p_mfc_queue_state { +QUEUE_FREE =0 , +QUEUE_BUFS_REQUESTED , +QUEUE_BUFS_QUERIED , +QUEUE_BUFS_MMAPED , +}; + +struct s5p_mfc_ctx ; + +/** +* struct s5p_mfc_buf - MFC buffer +* +*/ +struct s5p_mfc_buf { +struct list_head list; +struct vb2_buffer *b; +union { +struct { +size_t luma; +size_t chroma; + } raw; +size_t stream; + } cookie; +}; + +/** +* struct s5p_mfc_dev - The struct containing driver internal parameters. +*/ +struct s5p_mfc_dev { +struct v4l2_device v4l2_dev; +struct video_device *vfd; +struct platform_device *plat_dev; + +int num_inst; +spinlock_t irqlock; +spinlock_t condlock; + +void __iomem *regs_base; +int irq; + +struct resource *mfc_mem; + +struct mutex mfc_mutex; + +int int_cond; +int int_type; +unsigned int int_err; +wait_queue_head_t queue; + +size_t port_a; +size_t port_b; + +unsigned long hw_lock; + +struct clk *clock1; +struct clk *clock2; + +struct s5p_mfc_ctx *ctx[MFC_NUM_CONTEXTS ]; +int curr_ctx; +unsigned long ctx_work_bits; + +atomic_t watchdog_cnt; +struct timer_list watchdog_timer; +struct workqueue_struct *watchdog_workqueue; +struct work_struct watchdog_work; + +struct vb2_alloc_ctx **alloc_ctx; +}; + +/** +* struct s5p_mfc_ctx - This struct contains the instance context +*/ +struct s5p_mfc_ctx { +struct s5p_mfc_dev *dev; +int num; + +int int_cond; +int int_type; +unsigned int int_err; +wait_queue_head_t queue; + +struct s5p_mfc_fmt *fmt; + +struct vb2_queue vq_src; +struct vb2_queue vq_dst; + +struct list_head src_queue; +struct list_head dst_queue; + +unsigned int src_queue_cnt; +unsigned int dst_queue_cnt; + +enum s5p_mfc_inst_state state; +int inst_no; + +/* Decoder parameters */ +int img_width; +int img_height; +int buf_width; +int buf_height; +int dpb_count; +int total_dpb_count; + +int luma_size; +int chroma_size; +int mv_size; + +unsigned long consumed_stream; +int slice_interface; + +/* Buffers */ +void *port_a_buf; +size_t port_a_phys; +size_t port_a_size; + +void *port_b_buf; +size_t port_b_phys; +size_t port_b_size; + + +enum s5p_mfc_queue_state capture_state; +enum s5p_mfc_queue_state output_state; + +// size_t dec_dst_buf_luma[MFC_MAX_BUFFERS]; +// size_t dec_dst_buf_chroma[MFC_MAX_BUFFERS]; + +struct s5p_mfc_buf src_bufs[MFC_MAX_BUFFERS ]; +int src_bufs_cnt; +struct s5p_mfc_buf dst_bufs[MFC_MAX_BUFFERS ]; +int dst_bufs_cnt; + +// int dec_dst_buf_cnt; +unsigned int sequence; +unsigned long dec_dst_flag; +size_t dec_src_buf_size; + +/* Control values */ +int codec_mode; +__u32 pix_format; +int loop_filter_mpeg4; +int display_delay; + +/* Buffers */ + +void *instance_buf; +size_t instance_phys; +size_t instance_size; +dma_addr_t instance_dma; + +void *desc_buf; +size_t desc_phys; +dma_addr_t desc_dma; + +void *shared_buf; +size_t shared_phys; +void *shared_virt; +dma_addr_t shared_dma; + +}; + +#endif /* S5P_MFC_COMMON_H_ */ drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h new file +11
-0@@ -0,0 +1,173 @@ +/* +* Samsung S5P Multi Format Codec v 5.0 +* +* This file contains description of formats used by MFC and cotrols +* used by the driver. +* +* Copyright (c) 2010 Samsung Electronics Co., Ltd. +* Kamil Debski, <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version
+ */drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h new file +159
-0+ +#ifndef S5P_MFC_CTRLS_H_ +#define S5P_MFC_CTRLS_H_ + +#include <media/v4l2-ioctl.h> +#include "regs-mfc5.h" + +#define MFC_FMT_DEC 0 +#define MFC_FMT_ENC 1 +#define MFC_FMT_RAW 2 + +struct s5p_mfc_fmt { +char *name; +u32 fourcc; +u32 codec_mode; +u32 type; +u32 num_planes; +}; + +#define MFC_FORMATS_NO_CODEC -1 + +static struct s5p_mfc_fmt formats[] = { + { + .name ="4:2:0 2 Planes 64x32 Tiles" , + .fourcc =V4L2_PIX_FMT_NV12MT , + .codec_mode =MFC_FORMATS_NO_CODEC , + .type =MFC_FMT_RAW , + .num_planes =2 , + }, + { + .name ="4:2:0 2 Planes" , + .fourcc =V4L2_PIX_FMT_NV12 , + .codec_mode =MFC_FORMATS_NO_CODEC , + .type =MFC_FMT_RAW , + .num_planes =2 , + }, + { + .name ="H264 Encoded Stream" , + .fourcc =V4L2_PIX_FMT_H264 , + .codec_mode =S5P_FIMV_CODEC_H264_DEC , + .type =MFC_FMT_DEC , + .num_planes =1 , + }, + { + .name ="H263 Encoded Stream" , + .fourcc =V4L2_PIX_FMT_H263 , + .codec_mode =S5P_FIMV_CODEC_H263_DEC , + .type =MFC_FMT_DEC , + .num_planes =1 , + }, + { + .name ="MPEG1/MPEG2 Encoded Stream" , + .fourcc =V4L2_PIX_FMT_MPEG12 , + .codec_mode =S5P_FIMV_CODEC_MPEG2_DEC , + .type =MFC_FMT_DEC , + .num_planes =1 , + }, + { + .name ="MPEG4 Encoded Stream" , + .fourcc =V4L2_PIX_FMT_MPEG4 , + .codec_mode =S5P_FIMV_CODEC_MPEG4_DEC , + .type =MFC_FMT_DEC , + .num_planes =1 , + }, + { + .name ="DivX Encoded Stream" , + .fourcc =V4L2_PIX_FMT_DIVX , + .codec_mode =S5P_FIMV_CODEC_MPEG4_DEC , + .type =MFC_FMT_DEC , + .num_planes =1 , + }, + { + .name ="DivX 3.11 Encoded Stream" , + .fourcc =V4L2_PIX_FMT_DIVX3 , + .codec_mode =S5P_FIMV_CODEC_DIVX311_DEC , + .type =MFC_FMT_DEC , + .num_planes =1 , + }, + { + .name ="DivX 4.12 Encoded Stream" , + .fourcc =V4L2_PIX_FMT_DIVX4 , + .codec_mode =S5P_FIMV_CODEC_DIVX412_DEC , + .type =MFC_FMT_DEC , + .num_planes =1 , + }, + { + .name ="DivX 5 Encoded Stream" , + .fourcc =V4L2_PIX_FMT_DIVX5 , + .codec_mode =S5P_FIMV_CODEC_DIVX502_DEC , + .type =MFC_FMT_DEC , + .num_planes =1 , + }, +/* { +.name = "DivX 5.03 Encoded Stream", +.fourcc = V4L2_PIX_FMT_DIVX503, +.codec_mode = S5P_FIMV_CODEC_DIVX503_DEC, +.type = MFC_FMT_DEC, +.num_planes = 1, +},*/ + { + .name ="XviD Encoded Stream" , + .fourcc =V4L2_PIX_FMT_XVID , + .codec_mode =S5P_FIMV_CODEC_MPEG4_DEC , + .type =MFC_FMT_DEC , + .num_planes =1 , + }, + { + .name ="VC1 Encoded Stream" , + .fourcc =V4L2_PIX_FMT_VC1 , + .codec_mode =S5P_FIMV_CODEC_VC1_DEC , + .type =MFC_FMT_DEC , + .num_planes =1 , + }, + { + .name ="VC1 RCV Encoded Stream" , + .fourcc =V4L2_PIX_FMT_VC1_RCV , + .codec_mode =S5P_FIMV_CODEC_VC1RCV_DEC , + .type =MFC_FMT_DEC , + .num_planes =1 , + }, +}; + +#define NUM_FORMATS ARRAY_SIZE(formats) + +static struct v4l2_queryctrl s5p_mfc_ctrls[] = { +/* For decoding */ + { + .id =V4L2_CID_CODEC_DISPLAY_DELAY , + .type =V4L2_CTRL_TYPE_INTEGER , + .name ="" , + .minimum =0 , + .maximum =16383 , + .step =1 , + .default_value =0 , + }, + { + .id =V4L2_CID_CODEC_LOOP_FILTER_MPEG4_ENABLE , + .type =V4L2_CTRL_TYPE_BOOLEAN , + .name ="Mpeg4 Loop Filter Enable" , + .minimum =0 , + .maximum =1 , + .step =1 , + .default_value =0 , + }, + { + .id =V4L2_CID_CODEC_SLICE_INTERFACE , + .type =V4L2_CTRL_TYPE_BOOLEAN , + .name ="Slice Interface Enable" , + .minimum =0 , + .maximum =1 , + .step =1 , + .default_value =0 , + }, +}; + +#define NUM_CTRLS ARRAY_SIZE(s5p_mfc_ctrls) + +#endif /* S5P_MFC_CTRLS_H_ */ +drivers/media/video/s5p-mfc/s5p_mfc_debug.h new file +16
-0@@ -0,0 +1,47 @@ +/* +* drivers/media/video/samsung/mfc5/s5p_mfc_debug.h +* +* Header file for Samsung MFC (Multi Function Codec - FIMV) driver +* This file contains debug macros +* +* Kamil Debski, Copyright (c) 2010 Samsung Electronics +* http://www.samsung.com/ +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef S5P_MFC_DEBUG_H_ +#define S5P_MFC_DEBUG_H_
drivers/media/video/s5p-mfc/s5p_mfc_debug.h line 26
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc_debug.h new file +10
-0+ +#define DEBUG + +#ifdef DEBUG +extern int debug; +/* Debug macro */ +#define mfc_debug (fmt, ...) \ + do { \ + if (debug) \ + dev_dbg(dev->v4l2_dev.dev, "%s:%s:%d:" fmt,
__FILE__,
drivers/media/video/s5p-mfc/s5p_mfc_debug.h
Quoted 12 lines
__func__,__LINE__, ##__VA_ARGS__); \drivers/media/video/s5p-mfc/s5p_mfc_debug.h new file +11
-0+ }while (0) +#else +#define mfc_debug (fmt, ...) +#endif + +#define mfc_debug_enter () mfc_debug("enter") +#define mfc_debug_leave () mfc_debug("leave") + +#define mfc_err (fmt, ...) \ + do { \ + dev_err(dev->v4l2_dev.dev, "%s:%s:%d:" fmt,
__FILE__,
drivers/media/video/s5p-mfc/s5p_mfc_debug.h
Quoted 6 lines
__func__,__LINE__, ##__VA_ARGS__); \drivers/media/video/s5p-mfc/s5p_mfc_debug.h new file +5
-0+ }while (0) + +#define mfc_info (fmt, ...) \ + do { \ + dev_info(dev->v4l2_dev.dev, "%s:%s:%d:" fmt,
__FILE__,
Quoted 48 lines
__func__,__LINE__, ##__VA_ARGS__);\drivers/media/video/s5p-mfc/s5p_mfc_debug.h new file +5
-0+ }while (0) + + +#endif /* S5P_MFC_DEBUG_H_ */ +drivers/media/video/s5p-mfc/s5p_mfc_intr.c new file +34
-0@@ -0,0 +1,92 @@ +/* +* drivers/media/video/samsung/mfc5/s5p_mfc_intr.c +* +* C file for Samsung MFC (Multi Function Codec - FIMV) driver +* This file contains functions used to wait for command completion. +* +* Kamil Debski, Copyright (c) 2010 Samsung Electronics +* http://www.samsung.com/ +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include <linux/delay.h> +#include <linux/errno.h> +#include <linux/wait.h> +#include <linux/sched.h> +#include <linux/io.h> +#include "regs-mfc5.h" +#include "s5p_mfc_intr.h" +#include "s5p_mfc_common.h" +#include "s5p_mfc_debug.h" + +int s5p_mfc_wait_for_done_dev (struct s5p_mfc_dev *dev,int command) +{ +int ret; + + ret =wait_event_interruptible_timeout (dev->queue, + (dev->int_cond && (dev->int_type == command + || dev->int_type ==S5P_FIMV_R2H_CMD_DECODE_ERR_RET )), +msecs_to_jiffies (MFC_INT_TIMEOUT )); +if (ret ==0 ) { + mfc_err("Interrupt (dev->int_type:%d, command:%d) timedout.\n",
drivers/media/video/s5p-mfc/s5p_mfc_intr.c
Quoted 1 line
drivers/media/video/s5p-mfc/s5p_mfc_intr.c new file +1
-0+ dev->int_type,
command);
drivers/media/video/s5p-mfc/s5p_mfc_intr.c
Quoted 7 lines
drivers/media/video/s5p-mfc/s5p_mfc_intr.c new file +7
-0+return 1 ; + }else if (ret == -ERESTARTSYS ) { +mfc_err ("Interrupted by a signal.\n" ); +return 1 ; + } + mfc_debug("Finished waiting (dev->int_type:%d, command: %d).\n", + dev->int_type,
command);
Quoted 12 lines
drivers/media/video/s5p-mfc/s5p_mfc_intr.c new file +12
-0+if (dev->int_type ==S5P_FIMV_R2H_CMD_ERROR_RET ) +return 1 ; +return 0 ; +} + +void s5p_mfc_clean_dev_int_flags (struct s5p_mfc_dev *dev) +{ + dev->int_cond =0 ; + dev->int_type =0 ; + dev->int_err =0 ; +} +
drivers/media/video/s5p-mfc/s5p_mfc_intr.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc_intr.c new file +10
-0+int s5p_mfc_wait_for_done_ctx(struct s5p_mfc_ctx *ctx, + int command, int interrupt) +{ + struct s5p_mfc_dev *dev = ctx->dev; + int ret; + + if (interrupt) { + ret = wait_event_interruptible_timeout(ctx->queue, + (ctx->int_cond && (ctx->int_type == command + || ctx->int_type ==
S5P_FIMV_R2H_CMD_DECODE_ERR_RET)),
drivers/media/video/s5p-mfc/s5p_mfc_intr.c
Quoted 5 lines
drivers/media/video/s5p-mfc/s5p_mfc_intr.c new file +5
-0+ msecs_to_jiffies(MFC_INT_TIMEOUT)); + } else { + ret = wait_event_timeout(ctx->queue, + (ctx->int_cond && (ctx->int_type == command + || ctx->int_type ==
S5P_FIMV_R2H_CMD_DECODE_ERR_RET)),
drivers/media/video/s5p-mfc/s5p_mfc_intr.c
Quoted 6 lines
drivers/media/video/s5p-mfc/s5p_mfc_intr.c new file +4
-0+ msecs_to_jiffies(MFC_INT_TIMEOUT)); + } +if (ret ==0 ) { + mfc_err("Interrupt (ctx->int_type:%d, command:%d) timedout.\n",
drivers/media/video/s5p-mfc/s5p_mfc_intr.c new file +1
-0+ ctx->int_type,
command);
drivers/media/video/s5p-mfc/s5p_mfc_intr.c
Quoted 7 lines
drivers/media/video/s5p-mfc/s5p_mfc_intr.c new file +7
-0+return 1 ; + }else if (ret == -ERESTARTSYS ) { +mfc_err ("Interrupted by a signal.\n" ); +return 1 ; + } + mfc_debug("Finished waiting (ctx->int_type:%d, command: %d).\n", + ctx->int_type,
command);
Quoted 72 lines
drivers/media/video/s5p-mfc/s5p_mfc_intr.c new file +11
-0+if (ctx->int_type ==S5P_FIMV_R2H_CMD_ERROR_RET ) +return 1 ; +return 0 ; +} + +void s5p_mfc_clean_ctx_int_flags (struct s5p_mfc_ctx *ctx) +{ + ctx->int_cond =0 ; + ctx->int_type =0 ; + ctx->int_err =0 ; +}drivers/media/video/s5p-mfc/s5p_mfc_intr.h new file +26
-0@@ -0,0 +1,26 @@ +/* +* drivers/media/video/samsung/mfc5/s5p_mfc_intr.h +* +* Header file for Samsung MFC (Multi Function Codec - FIMV) driver +* It contains waiting functions declarations. +* +* Kamil Debski, Copyright (c) 2010 Samsung Electronics +* http://www.samsung.com/ +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef _S5P_MFC_INTR_H_ +#define _S5P_MFC_INTR_H_ + +#include "s5p_mfc_common.h" + +int s5p_mfc_wait_for_done_ctx (struct s5p_mfc_ctx *ctx, +int command,int interrupt); +int s5p_mfc_wait_for_done_dev (struct s5p_mfc_dev *dev,int command); +void s5p_mfc_clean_ctx_int_flags (struct s5p_mfc_ctx *ctx); +void s5p_mfc_clean_dev_int_flags (struct s5p_mfc_dev *dev); + +#endif /* _S5P_MFC_INTR_H_ */ drivers/media/video/s5p-mfc/s5p_mfc_memory.h new file +21
-0@@ -0,0 +1,43 @@ +/* +* drivers/media/video/samsung/mfc5/s5p_mfc_memory.h +* +* Header file for Samsung MFC (Multi Function Codec - FIMV) driver +* Contains memory related defines. +* +* Kamil Debski, Copyright (c) 2010 Samsung Electronics +* http://www.samsung.com/ +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef S5P_MFC_MEMORY_H_ +#define S5P_MFC_MEMORY_H_ + +#include "s5p_mfc_common.h" + +#define FIRMWARE_CODE_SIZE 0x60000/* 384KB */ +#define MFC_H264_INSTANCE_BUF_SIZE 0x96000/* 600KB per H264
Quoted 2 lines
instance */
+#defineMFC_INSTANCE_BUF_SIZE0x2800/* 10KB per
instance */
drivers/media/video/s5p-mfc/s5p_mfc_opr.c
Quoted 325 lines
+#define
DESC_BUF_SIZE0x20000/* 128KB for DESC
buffer */
+#defineSHARED_BUF_SIZE0x01000/* 4KB for shared
buffer */drivers/media/video/s5p-mfc/s5p_mfc_memory.h new file +19
-0+#define CPB_BUF_SIZE 0x400000/* 4MB fr decoder */ + +/* Define names for CMA memory kinds used by MFC */ +#define MFC_CMA_ALLOC_CTX_NUM 3 + +#define MFC_CMA_BANK1 "a" +#define MFC_CMA_BANK2 "b" +#define MFC_CMA_FW "f" + +#define MFC_CMA_BANK1_ALLOC_CTX 1 +#define MFC_CMA_BANK2_ALLOC_CTX 0 +#define MFC_CMA_FW_ALLOC_CTX 2 + +#define MFC_CMA_BANK1_ALIGN 0x2000/* 8KB */ +#define MFC_CMA_BANK2_ALIGN 0x2000/* 8KB */ +#define MFC_CMA_FW_ALIGN 0x20000/* 128KB */ + + +#endif /* S5P_MFC_MEMORY_H_ */ drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +85
-0@@ -0,0 +1,885 @@ +/* +* drivers/media/video/samsung/mfc5/s5p_mfc_opr.c +* +* Samsung MFC (Multi Function Codec - FIMV) driver +* This file contains hw related functions. +* +* Kamil Debski, Copyright (c) 2010 Samsung Electronics +* http://www.samsung.com/ +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#define DEBUG + +#include <linux/delay.h> +#include <linux/mm.h> +#include <linux/io.h> +#include <linux/jiffies.h> +#include "regs-mfc5.h" + +#include "s5p_mfc_opr.h" +#include "s5p_mfc_common.h" +#include "s5p_mfc_memory.h" +#include "s5p_mfc_intr.h" +#include "s5p_mfc_debug.h" Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
*/
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +25
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
*/
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +47
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
DESC_BUF_SIZE);drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +7
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 1 line
desc_buf);drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +2
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 1 line
desc_buf);drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +3
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 1 line
desc_buf);drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +8
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
DESC_BUF_SIZE,DMA_TO_DEVICE);drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +9
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
DESC_BUF_SIZE,DMA_TO_DEVICE);drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
alloc_ctx[MFC_CMA_BANK1_ALLOC_CTX],
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
desc_buf);drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +17
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
bufs: %d\n",
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +9
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
without
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +69
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
B).\n");
drivers/media/video/s5p-mfc/s5p_mfc_opr.c
Quoted 99 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +15
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
alloc_ctx[MFC_CMA_BANK1_ALLOC_CTX],
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +7
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
alloc_ctx[MFC_CMA_BANK2_ALLOC_CTX],
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +21
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
instance_size);drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +53
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
DMA_BIDIRECTIONAL);
drivers/media/video/s5p-mfc/s5p_mfc_opr.c
Quoted 83 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +81
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
buf_size1,drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
buf_size2);
Quoted 86 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +3
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
~S5P_FIMV_DPB_COUNT_MASK;
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +82
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 2 lines
frame_size_ch,
+ frame_size_m
v);
drivers/media/video/s5p-mfc/s5p_mfc_opr.c
Quoted 13 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +3
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 1 line
dst_bufs[i].cookie.raw.luma);
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +9
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
buf_size2);
drivers/media/video/s5p-mfc/s5p_mfc_opr.c
Quoted 42 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +20
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
S5P_FIMV_CH_SHIFT)drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +14
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
it is already loaded.\n");
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
mem_info_f.upper_bound,
Quoted 1 line
+ mem_info_f.total_siz
e);
drivers/media/video/s5p-mfc/s5p_mfc_opr.c
Quoted 39 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +38
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
+ s5p_mfc_bitproc_buf)
;
drivers/media/video/s5p-mfc/s5p_mfc_opr.c
Quoted 8 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +8
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
s5p_mfc_bitproc_phys,
drivers/media/video/s5p-mfc/s5p_mfc_opr.c
Quoted 9 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +8
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
+ s5p_mfc_bitproc_buf)
;
drivers/media/video/s5p-mfc/s5p_mfc_opr.c
Quoted 59 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +21
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 1 line
size);
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +2
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
directory nor compiled in kernel.\n");
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +9
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
correctly.\n");
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +23
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
+ s5p_mfc_bitproc_buf)
;
drivers/media/video/s5p-mfc/s5p_mfc_opr.c
Quoted 52 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +28
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
*/
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
*/
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +10
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
{
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +9
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
+ fw_buf_size)
;
drivers/media/video/s5p-mfc/s5p_mfc_opr.c
Quoted 13 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
{
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
+ S5P_FIMV_R2H_CMD_SYS_INIT_RE
T) {
drivers/media/video/s5p-mfc/s5p_mfc_opr.c
Quoted 69 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +62
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 1 line
loop_filter_mpeg4);drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
0)
drivers/media/video/s5p-mfc/s5p_mfc_opr.h
Quoted 88 lines
<<
drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +31
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
S5P_FIMV_SI_CH0_INST_ID);drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +3
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
S5P_FIMV_SI_CH0_INST_ID);drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +10
-0Lines of this file are not shown. View the raw message.
drivers/media/video/s5p-mfc/s5p_mfc_opr.h new file +34
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
start_num_byte,
drivers/media/video/s5p-mfc/s5p_mfc_opr.h
Quoted 28 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.h new file +28
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
DMA_BIDIRECTIONAL);
drivers/media/video/s5p-mfc/s5p_mfc_opr.h
Quoted 11 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.h new file +11
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
DMA_BIDIRECTIONAL);
drivers/media/video/s5p-mfc/s5p_mfc_opr.h
Quoted 9 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.h new file +9
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
\
drivers/media/video/s5p-mfc/s5p_mfc_opr.h
Quoted 24 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.h new file +24
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
DMA_BIDIRECTIONAL);
drivers/media/video/s5p-mfc/s5p_mfc_opr.h
Quoted 11 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.h new file +11
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
DMA_BIDIRECTIONAL);
drivers/media/video/s5p-mfc/s5p_mfc_opr.h
Quoted 6 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.h new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
DMA_BIDIRECTIONAL); \
drivers/media/video/s5p-mfc/s5p_mfc_opr.h
Quoted 3 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.h new file +3
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
DMA_BIDIRECTIONAL);
drivers/media/video/s5p-mfc/s5p_mfc_opr.h
Quoted 6 lines
\
drivers/media/video/s5p-mfc/s5p_mfc_opr.h new file +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
DMA_BIDIRECTIONAL); \
drivers/media/video/s5p-mfc/s5p_mfc_opr.h
Quoted 3 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.h new file +3
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
DMA_BIDIRECTIONAL);
drivers/media/video/s5p-mfc/s5p_mfc_opr.h
Quoted 6 lines
\
drivers/media/video/s5p-mfc/s5p_mfc_opr.h new file +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
DMA_BIDIRECTIONAL); \
drivers/media/video/s5p-mfc/s5p_mfc_opr.h
Quoted 3 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.h new file +3
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
DMA_BIDIRECTIONAL);
drivers/media/video/s5p-mfc/s5p_mfc_opr.h
Quoted 6 lines
\
drivers/media/video/s5p-mfc/s5p_mfc_opr.h new file +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
DMA_BIDIRECTIONAL); \
drivers/media/video/s5p-mfc/s5p_mfc_opr.h
Quoted 3 lines
drivers/media/video/s5p-mfc/s5p_mfc_opr.h new file +3
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
DMA_BIDIRECTIONAL);
Quoted 18 lines
\
drivers/media/video/s5p-mfc/s5p_mfc_opr.h new file +10
-1Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
1.6.3.3
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Part of the diff is not shown here. View the raw message.
RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driver
Hi,
Quoted 20 lines
From: Jaeryul Oh [mailto:[email protected]]
Hi, Kamil
I have a comment about s5p_mfc_stop_streaming()function.Quoted 6 lines
-----Original Message-----
From: [email protected] [mailto:linux-media- [email protected]] On Behalf Of Kamil Debski
Sent: Saturday, January 08, 2011 1:26 AM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected];Quoted 8 lines
[email protected]; [email protected]; [email protected]
Subject: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driverMulti Format Codec 5.1 is capable of handling a range of video codecs and this driver provides V4L2 interface for video decoding.
Signed-off-by Kamil Debski <[email protected]>Signed-off-by Kyungmin Park <[email protected]>
<snip>
Quoted 34 lines
Quoted 19 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +13
-0+ +/* Thou shalt stream no more. */ +static int s5p_mfc_stop_streaming (struct vb2_queue *q) +{ +unsigned long flags; +struct s5p_mfc_ctx *ctx = q->drv_priv; +struct s5p_mfc_dev *dev = ctx->dev; + +if ((ctx->state ==MFCINST_DEC_FINISHING || + ctx->state ==MFCINST_DEC_RUNNING ) && + dev->curr_ctx == ctx->num && dev->hw_lock) { + ctx->state =MFCINST_DEC_ABORT ; + s5p_mfc_wait_for_done_ctx(ctx,
S5P_FIMV_R2H_CMD_FRAME_DONE_RET,drivers/media/video/s5p-mfc/s5p_mfc.c new file +5
-0+ 0); + } + ctx->state =MFCINST_DEC_FINISHED ; +spin_lock_irqsave (&dev->irqlock, flags); + s5p_mfc_error_cleanup_queue(&ctx->dst_queue,drivers/media/video/s5p-mfc/s5p_mfc.c line 1274
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+ &ctx->vq_dst); +s5p_mfc_error_cleanup_queue (&ctx->src_queue, + &ctx->vq_src); +if (q->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ) +INIT_LIST_HEAD (&ctx->dst_queue); +if (q->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) +INIT_LIST_HEAD (&ctx->src_queue); +spin_unlock_irqrestore (&dev->irqlock, flags); +return 0 ; +}This function is called by __vb2_queue_cancel().and
__vb2_queue_cancel()
can be
called byvb2_queue_release()orvb2_streamoff().
But, in this s5p_mfc_stop_streaming(),s5p_mfc_error_cleanup_queue() for
Quoted 9 lines
src/dst
is runned regardless ofq->type. Is that right ?
and in case of streamoff, queued bufs should be removed, then qbuf is needed
before streamon again, soctx->dst_queue_cnt= 0;ctx->src_queue_cnt= 0;
is required
what do you think about this ?
It has to be changed to support pause and dynamic resolution change.
Best wishes,
--
Kamil Debski
Linux Platform Group
Samsung Poland R&D Center
RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driver
In reply to Kamil DebskiKamil, I have a question about MFC state FINISHING & FINISHED as below.
Quoted 42 lines
-----Original Message-----
From: [email protected] [mailto:linux-media- [email protected]] On Behalf Of Kamil Debski
Sent: Saturday, January 08, 2011 1:26 AM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driverMulti Format Codec 5.1 is capable of handling a range of video codecs and this driver provides V4L2 interface for video decoding.
Signed-off-by Kamil Debski <[email protected]>Signed-off-by Kyungmin Park <[email protected]>--- drivers/media/video/Kconfig | 8 + drivers/media/video/Makefile | 1 + drivers/media/video/s5p-mfc/Makefile | 3 + drivers/media/video/s5p-mfc/regs-mfc5.h | 335 +++++ drivers/media/video/s5p-mfc/s5p_mfc.c | 2072 ++++++++++++++++++++++++++ drivers/media/video/s5p-mfc/s5p_mfc_common.h | 224 +++ drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h | 173 +++ drivers/media/video/s5p-mfc/s5p_mfc_debug.h | 47 + drivers/media/video/s5p-mfc/s5p_mfc_intr.c | 92 ++ drivers/media/video/s5p-mfc/s5p_mfc_intr.h | 26 + drivers/media/video/s5p-mfc/s5p_mfc_memory.h | 43 + drivers/media/video/s5p-mfc/s5p_mfc_opr.c | 885 +++++++++++ drivers/media/video/s5p-mfc/s5p_mfc_opr.h | 160 ++ 13 files changed, 4069 insertions(+), 0 deletions(-) create mode 100644 drivers/media/video/s5p-mfc/Makefile create mode 100644 drivers/media/video/s5p-mfc/regs-mfc5.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_common.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_debug.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_intr.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_intr.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_memory.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_opr.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_opr.h
Snipped...
Quoted 56 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +44
-0+/* Videobuf opts */ +static struct vb2_ops s5p_mfc_qops = { + .buf_queue = s5p_mfc_buf_queue, + .queue_setup = s5p_mfc_queue_setup, + .start_streaming = s5p_mfc_start_streaming, + .buf_init = s5p_mfc_buf_init, + .stop_streaming = s5p_mfc_stop_streaming, + .wait_prepare = s5p_mfc_unlock, + .wait_finish = s5p_mfc_lock, +}; + +static void s5p_mfc_handle_frame_all_extracted (struct s5p_mfc_ctx *ctx) +{ +struct s5p_mfc_dev *dev = ctx->dev; +struct s5p_mfc_buf *dst_buf; + + ctx->state =MFCINST_DEC_FINISHED ; +mfc_debug ("Decided to finish\n" ); + ctx->sequence++; +while (!list_empty (&ctx->dst_queue)) { + dst_buf =list_entry (ctx->dst_queue.next, + struct s5p_mfc_buf, list); +mfc_debug ("Cleaning up buffer: %d\n" , + dst_buf->b->v4l2_buf.index); +vb2_set_plane_payload (dst_buf->b,0 ,0 ); +vb2_set_plane_payload (dst_buf->b,1 ,0 ); +list_del (&dst_buf->list); + ctx->dst_queue_cnt--; + dst_buf->b->v4l2_buf.sequence = (ctx->sequence++); +if (s5p_mfc_get_pic_time_top (ctx) == +s5p_mfc_get_pic_time_bottom (ctx)) + dst_buf->b->v4l2_buf.field =V4L2_FIELD_NONE ; +else + dst_buf->b->v4l2_buf.field = +V4L2_FIELD_INTERLACED ; + ctx->dec_dst_flag &= ~(1 << dst_buf->b->v4l2_buf.index); +vb2_buffer_done (dst_buf->b,VB2_BUF_STATE_DONE ); +mfc_debug ("Cleaned up buffer: %d\n" , + dst_buf->b->v4l2_buf.index); + } +mfc_debug ("After cleanup\n" ); +} + +static void s5p_mfc_handle_frame_new(struct s5p_mfc_ctx *ctx, unsignedint err)
drivers/media/video/s5p-mfc/s5p_mfc.c new file +11
-0+{ +struct s5p_mfc_dev *dev = ctx->dev; +struct s5p_mfc_buf *dst_buf; +size_t dspl_y_addr =s5p_mfc_get_dspl_y_adr (); + + ctx->sequence++; +/* If frame is same as previous then skip and do not dequeue */ +if (s5p_mfc_get_frame_type () ==S5P_FIMV_DECODE_FRAME_SKIPPED ) +return ; +/* The MFC returns address of the buffer, now we have to +* check which videobuf does it correspond to */
drivers/media/video/s5p-mfc/s5p_mfc.c line 1356
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+list_for_each_entry (dst_buf, &ctx->dst_queue, list) { +mfc_debug ("Listing: %d\n" , dst_buf->b->v4l2_buf.index); +/* Check if this is the buffer we're looking for */ +if (vb2_cma_plane_paddr (dst_buf->b,0 ) == dspl_y_addr) { +list_del (&dst_buf->list); + ctx->dst_queue_cnt--; + dst_buf->b->v4l2_buf.sequence = ctx->sequence; +if (s5p_mfc_get_pic_time_top (ctx) == +s5p_mfc_get_pic_time_bottom (ctx)) + dst_buf->b->v4l2_buf.field =
V4L2_FIELD_NONE;
Quoted 7 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+else + dst_buf->b->v4l2_buf.field = +V4L2_FIELD_INTERLACED ; + vb2_set_plane_payload(dst_buf->b, 0, ctx-
luma_size);(quoted diff) +1
-0+ vb2_set_plane_payload(dst_buf->b, 1, ctx-
chroma_size);
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 7 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +7
-0+clear_bit (dst_buf->b->v4l2_buf.index, + &ctx->dec_dst_flag); +if (err) { +vb2_buffer_done (dst_buf->b, +VB2_BUF_STATE_ERROR ); + }else { + vb2_buffer_done(dst_buf->b,
VB2_BUF_STATE_DONE);
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 9 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +9
-0+ } +break ; + } + } +} + +/* Handle frame decoding interrupt */ +static void s5p_mfc_handle_frame (struct s5p_mfc_ctx *ctx, + unsigned int reason, unsigned int
err)
Quoted 16 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +16
-0+{ +struct s5p_mfc_dev *dev = ctx->dev; +unsigned int dst_frame_status; +struct s5p_mfc_buf *src_buf; +unsigned long flags; + + dst_frame_status =s5p_mfc_get_dspl_status () + &S5P_FIMV_DEC_STATUS_DECODING_STATUS_MASK ; +mfc_debug ("Frame Status: %x\n" , dst_frame_status); +spin_lock_irqsave (&dev->irqlock, flags); +/* All frames remaining in the buffer have been extracted */ +if (dst_frame_status ==S5P_FIMV_DEC_STATUS_DECODING_EMPTY ) { +s5p_mfc_handle_frame_all_extracted (ctx); + } + +/* A frame has been decoded and is in the buffer */
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+if (dst_frame_status ==S5P_FIMV_DEC_STATUS_DISPLAY_ONLY || + dst_frame_status ==S5P_FIMV_DEC_STATUS_DECODING_DISPLAY ) { +s5p_mfc_handle_frame_new (ctx, err); + }else { +mfc_debug ("No frame decode.\n" ); + } +/* Mark source buffer as complete */ +if (dst_frame_status !=S5P_FIMV_DEC_STATUS_DISPLAY_ONLY + && !list_empty (&ctx->src_queue)) { + src_buf = list_entry(ctx->src_queue.next, struct
s5p_mfc_buf,
Review
Quoted 5 lines
(quoted diff) +2
-0+ list); + mfc_debug("Packed PB test. Size:%d, prev offset: %ld, thisrun:"
(quoted diff) +2
-0+ " %d\n", src_buf->b->v4l2_planes[0].bytesused, + ctx->consumed_stream,
s5p_mfc_get_consumed_stream());
Quoted 16 lines
(quoted diff) +2
-0+ ctx->consumed_stream += s5p_mfc_get_consumed_stream(); + if (s5p_mfc_get_frame_type() ==
S5P_FIMV_DECODE_FRAME_P_FRAME(quoted diff) +2
-0+ && ctx->consumed_stream < + src_buf->b-v4l2_planes[0].bytesused) {
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+/* Run MFC again on the same buffer */ +mfc_debug ("Running again the same buffer.\n" ); + s5p_mfc_set_dec_stream_buffer(ctx, + src_buf->cookie.stream, ctx-
consumed_stream,(quoted diff) +2
-0+ src_buf->b->v4l2_planes[0].bytesused - + ctx-
consumed_stream);drivers/media/video/s5p-mfc/s5p_mfc.c new file +2
-0+ dev->curr_ctx = ctx->num; +s5p_mfc_clean_ctx_int_flags (ctx);
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+spin_unlock_irqrestore (&dev->irqlock, flags); +s5p_mfc_clear_int_flags (); +wake_up_ctx (ctx, reason, err); +s5p_mfc_decode_one_frame (ctx,0 ); +return ; + }else { +mfc_debug ("MFC needs next buffer.\n" ); +/* Advance to next buffer */ +if (src_buf->b->v4l2_planes[0 ].bytesused ==0 ) { + mfc_debug("Setting ctx->state to
FINISHING\n");
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 12 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +12
-0+ ctx->state =MFCINST_DEC_FINISHING ; + } + ctx->consumed_stream =0 ; +list_del (&src_buf->list); + ctx->src_queue_cnt--; +vb2_buffer_done (src_buf->b,VB2_BUF_STATE_DONE ); + } + } +spin_unlock_irqrestore (&dev->irqlock, flags); +mfc_debug ("Assesing whether this context should be run again.\n" ); +if ((ctx->src_queue_cnt ==0 && ctx->state !=MFCINST_DEC_FINISHING ) + || ctx->dst_queue_cnt < ctx->dpb_count)
{
drivers/media/video/s5p-mfc/s5p_mfc.c line 1450
Quoted 12 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+mfc_debug ("No need to run again.\n" ); +clear_work_bit (ctx); + } + mfc_debug("After assesing whether this context should be runagain.\n");
drivers/media/video/s5p-mfc/s5p_mfc.c new file +7
-0+s5p_mfc_clear_int_flags (); +wake_up_ctx (ctx, reason, err); +if (test_and_clear_bit (0 , &dev->hw_lock) ==0 ) +BUG (); +s5p_mfc_try_run (dev); +} +
Basically, I understand that FINISHING state is starting point just after src
queue/dequeue is
finished. And state goes to the FINISHED right after all extracted. But, you change state as a FINISHED at beginning of s5p_mfc_handle_frame_all_extracted().
What about FINISHING state ?
if (src_buf->b->v4l2_planes[0].bytesused == 0) this condition meets after FINISHED state set
So, it is confusing if state change like (RUNNING -> FINISHING -> FINISHED) is
right.
Snipped...
Quoted 6 lines
1.6.3.3
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driver
Quoted 3 lines
From: Jaeryul Oh [mailto:[email protected]]
Kamil, I have a question about MFC state FINISHING & FINISHED as below.
Hi Peter,
I have answered your question below.
Quoted 235 lines
Quoted 8 lines
-----Original Message-----
From: [email protected] [mailto:linux-media- [email protected]] On Behalf Of Kamil Debski
Sent: Saturday, January 08, 2011 1:26 AM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected];Quoted 36 lines
[email protected]; [email protected]; [email protected]
Subject: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driverMulti Format Codec 5.1 is capable of handling a range of video codecs and this driver provides V4L2 interface for video decoding.
Signed-off-by Kamil Debski <[email protected]>Signed-off-by Kyungmin Park <[email protected]>--- drivers/media/video/Kconfig | 8 + drivers/media/video/Makefile | 1 + drivers/media/video/s5p-mfc/Makefile | 3 + drivers/media/video/s5p-mfc/regs-mfc5.h | 335 +++++ drivers/media/video/s5p-mfc/s5p_mfc.c | 2072 ++++++++++++++++++++++++++ drivers/media/video/s5p-mfc/s5p_mfc_common.h | 224 +++ drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h | 173 +++ drivers/media/video/s5p-mfc/s5p_mfc_debug.h | 47 + drivers/media/video/s5p-mfc/s5p_mfc_intr.c | 92 ++ drivers/media/video/s5p-mfc/s5p_mfc_intr.h | 26 + drivers/media/video/s5p-mfc/s5p_mfc_memory.h | 43 + drivers/media/video/s5p-mfc/s5p_mfc_opr.c | 885 +++++++++++ drivers/media/video/s5p-mfc/s5p_mfc_opr.h | 160 ++ 13 files changed, 4069 insertions(+), 0 deletions(-) create mode 100644 drivers/media/video/s5p-mfc/Makefile create mode 100644 drivers/media/video/s5p-mfc/regs-mfc5.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_common.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_debug.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_intr.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_intr.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_memory.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_opr.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_opr.hSnipped...
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 12 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +12
-0+/* Videobuf opts */ +static struct vb2_ops s5p_mfc_qops = { + .buf_queue = s5p_mfc_buf_queue, + .queue_setup = s5p_mfc_queue_setup, + .start_streaming = s5p_mfc_start_streaming, + .buf_init = s5p_mfc_buf_init, + .stop_streaming = s5p_mfc_stop_streaming, + .wait_prepare = s5p_mfc_unlock, + .wait_finish = s5p_mfc_lock, +}; + +static void s5p_mfc_handle_frame_all_extracted(struct s5p_mfc_ctx*ctx)
Quoted 22 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +22
-0+{ +struct s5p_mfc_dev *dev = ctx->dev; +struct s5p_mfc_buf *dst_buf; + + ctx->state =MFCINST_DEC_FINISHED ; +mfc_debug ("Decided to finish\n" ); + ctx->sequence++; +while (!list_empty (&ctx->dst_queue)) { + dst_buf =list_entry (ctx->dst_queue.next, + struct s5p_mfc_buf, list); +mfc_debug ("Cleaning up buffer: %d\n" , + dst_buf->b->v4l2_buf.index); +vb2_set_plane_payload (dst_buf->b,0 ,0 ); +vb2_set_plane_payload (dst_buf->b,1 ,0 ); +list_del (&dst_buf->list); + ctx->dst_queue_cnt--; + dst_buf->b->v4l2_buf.sequence = (ctx->sequence++); +if (s5p_mfc_get_pic_time_top (ctx) == +s5p_mfc_get_pic_time_bottom (ctx)) + dst_buf->b->v4l2_buf.field =V4L2_FIELD_NONE ; +else + dst_buf->b->v4l2_buf.field =drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+V4L2_FIELD_INTERLACED ; + ctx->dec_dst_flag &= ~(1 << dst_buf->b->v4l2_buf.index); +vb2_buffer_done (dst_buf->b,VB2_BUF_STATE_DONE ); +mfc_debug ("Cleaned up buffer: %d\n" , + dst_buf->b->v4l2_buf.index); + } +mfc_debug ("After cleanup\n" ); +} + +static void s5p_mfc_handle_frame_new(struct s5p_mfc_ctx *ctx,unsigned
Quoted 12 lines
int err)
drivers/media/video/s5p-mfc/s5p_mfc.c new file +11
-0+{ +struct s5p_mfc_dev *dev = ctx->dev; +struct s5p_mfc_buf *dst_buf; +size_t dspl_y_addr =s5p_mfc_get_dspl_y_adr (); + + ctx->sequence++; +/* If frame is same as previous then skip and do not dequeue */ +if (s5p_mfc_get_frame_type () ==S5P_FIMV_DECODE_FRAME_SKIPPED ) +return ; +/* The MFC returns address of the buffer, now we have to +* check which videobuf does it correspond to */ drivers/media/video/s5p-mfc/s5p_mfc.c line 1356
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+list_for_each_entry (dst_buf, &ctx->dst_queue, list) { +mfc_debug ("Listing: %d\n" , dst_buf->b->v4l2_buf.index); +/* Check if this is the buffer we're looking for */ +if (vb2_cma_plane_paddr (dst_buf->b,0 ) == dspl_y_addr) { +list_del (&dst_buf->list); + ctx->dst_queue_cnt--; + dst_buf->b->v4l2_buf.sequence = ctx->sequence; +if (s5p_mfc_get_pic_time_top (ctx) == +s5p_mfc_get_pic_time_bottom (ctx)) + dst_buf->b->v4l2_buf.field =
V4L2_FIELD_NONE;Quoted 7 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+else + dst_buf->b->v4l2_buf.field = +V4L2_FIELD_INTERLACED ; + vb2_set_plane_payload(dst_buf->b, 0, ctx-
luma_size);(quoted diff) +1
-0+ vb2_set_plane_payload(dst_buf->b, 1, ctx-
chroma_size);drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 7 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +7
-0+clear_bit (dst_buf->b->v4l2_buf.index, + &ctx->dec_dst_flag); +if (err) { +vb2_buffer_done (dst_buf->b, +VB2_BUF_STATE_ERROR ); + }else { + vb2_buffer_done(dst_buf->b,
VB2_BUF_STATE_DONE);drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 9 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +9
-0+ } +break ; + } + } +} + +/* Handle frame decoding interrupt */ +static void s5p_mfc_handle_frame (struct s5p_mfc_ctx *ctx, + unsigned int reason, unsigned interr)
Quoted 16 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +16
-0+{ +struct s5p_mfc_dev *dev = ctx->dev; +unsigned int dst_frame_status; +struct s5p_mfc_buf *src_buf; +unsigned long flags; + + dst_frame_status =s5p_mfc_get_dspl_status () + &S5P_FIMV_DEC_STATUS_DECODING_STATUS_MASK ; +mfc_debug ("Frame Status: %x\n" , dst_frame_status); +spin_lock_irqsave (&dev->irqlock, flags); +/* All frames remaining in the buffer have been extracted */ +if (dst_frame_status ==S5P_FIMV_DEC_STATUS_DECODING_EMPTY ) { +s5p_mfc_handle_frame_all_extracted (ctx); + } + +/* A frame has been decoded and is in the buffer */ drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+if (dst_frame_status ==S5P_FIMV_DEC_STATUS_DISPLAY_ONLY || + dst_frame_status ==S5P_FIMV_DEC_STATUS_DECODING_DISPLAY ) { +s5p_mfc_handle_frame_new (ctx, err); + }else { +mfc_debug ("No frame decode.\n" ); + } +/* Mark source buffer as complete */ +if (dst_frame_status !=S5P_FIMV_DEC_STATUS_DISPLAY_ONLY + && !list_empty (&ctx->src_queue)) { + src_buf = list_entry(ctx->src_queue.next, struct
s5p_mfc_buf,Review
Quoted 5 lines
(quoted diff) +2
-0+ list); + mfc_debug("Packed PB test. Size:%d, prev offset: %ld, thisrun:"
(quoted diff) +2
-0+ " %d\n", src_buf->b->v4l2_planes[0].bytesused, + ctx->consumed_stream,
s5p_mfc_get_consumed_stream());Quoted 16 lines
(quoted diff) +2
-0+ ctx->consumed_stream += s5p_mfc_get_consumed_stream(); + if (s5p_mfc_get_frame_type() ==
S5P_FIMV_DECODE_FRAME_P_FRAME(quoted diff) +2
-0+ && ctx->consumed_stream < + src_buf->b-v4l2_planes[0].bytesused) {
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+/* Run MFC again on the same buffer */ +mfc_debug ("Running again the same buffer.\n" ); + s5p_mfc_set_dec_stream_buffer(ctx, + src_buf->cookie.stream, ctx-
consumed_stream,(quoted diff) +2
-0+ src_buf->b->v4l2_planes[0].bytesused - + ctx-
consumed_stream);drivers/media/video/s5p-mfc/s5p_mfc.c new file +2
-0+ dev->curr_ctx = ctx->num; +s5p_mfc_clean_ctx_int_flags (ctx);drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+spin_unlock_irqrestore (&dev->irqlock, flags); +s5p_mfc_clear_int_flags (); +wake_up_ctx (ctx, reason, err); +s5p_mfc_decode_one_frame (ctx,0 ); +return ; + }else { +mfc_debug ("MFC needs next buffer.\n" ); +/* Advance to next buffer */ +if (src_buf->b->v4l2_planes[0 ].bytesused ==0 ) { + mfc_debug("Setting ctx->state toFINISHING\n");
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+ ctx->state =MFCINST_DEC_FINISHING ; + } + ctx->consumed_stream =0 ; +list_del (&src_buf->list); + ctx->src_queue_cnt--; +vb2_buffer_done (src_buf->b,VB2_BUF_STATE_DONE ); + } + } +spin_unlock_irqrestore (&dev->irqlock, flags); + mfc_debug("Assesing whether this context should be runagain.\n");
Review
Quoted 1 line
(quoted diff) +1
-0+ if ((ctx->src_queue_cnt == 0 && ctx->state !=
MFCINST_DEC_FINISHING)Review
Quoted 1 line
(quoted diff) +1
-0+ || ctx->dst_queue_cnt < ctx->dpb_count){
drivers/media/video/s5p-mfc/s5p_mfc.c line 1450
Quoted 12 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+mfc_debug ("No need to run again.\n" ); +clear_work_bit (ctx); + } + mfc_debug("After assesing whether this context should be runagain.\n");
drivers/media/video/s5p-mfc/s5p_mfc.c new file +7
-0+s5p_mfc_clear_int_flags (); +wake_up_ctx (ctx, reason, err); +if (test_and_clear_bit (0 , &dev->hw_lock) ==0 ) +BUG (); +s5p_mfc_try_run (dev); +} +Basically, I understand that FINISHING state is starting point just after
src
queue/dequeue is
finished. And state goes to the FINISHED right after all extracted. But, you change state as a FINISHED at beginning ofs5p_mfc_handle_frame_all_extracted().
Quoted 8 lines
What about FINISHING state ?
if (src_buf->b->v4l2_planes[0].bytesused == 0) this condition meets after
FINISHED state set
So, it is confusing if state change like (RUNNING -> FINISHING -> FINISHED)
is
right.
The state flow is as follows:
1) The driver receives an src buffer with bytesused set to 0 State is changed from RUNNING to FINISHING.
At this point the command that is sent to MFC hw is S5P_FIMV_CH_LAST_FRAME (aka LAST_SEQ).
2) The driver dequeued remaining frames frame by frame. State is FINISHING, S5P_FIMV_CH_LAST_FRAME commands are sent and frames are dequeued in the interrupt handler.
3) If DISPLAY_STATUS[2:0] = 3 (DPB is empty and decoding is finished) Then state is changed to FINISHED. This is the time when s5p_mfc_handle_frame_all_extracted is called.
I guess that the thing that bothers you is the place where state is set to FINISHING. This could be moved to s5p_mfc_run_dec_frame - maybe the code would be clearer. Anyway I think still it is ok, because the following code:
if (src_buf->b->v4l2_planes[0].bytesused == 0) {
mfc_debug("Setting ctx->state to FINISHING\n");
ctx->state = MFCINST_DEC_FINISHING;
}Is run only if the following condition:
if (dst_frame_status != S5P_FIMV_DEC_STATUS_DISPLAY_ONLY
&& !list_empty(&ctx->src_queue))
is met.
I hope I have answered your question.
Quoted 2 lines
Snipped...
Bets regards,
--
Kamil Debski
Linux Platform Group
Samsung Poland R&D Center
RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driver
Kamil, see my comments.
Quoted 284 lines
-----Original Message-----
From: Kamil Debski [mailto:[email protected]]
Sent: Friday, February 18, 2011 8:23 PM
To: [email protected]; [email protected]; linux-samsung- [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driverQuoted 3 lines
From: Jaeryul Oh [mailto:[email protected]]
Kamil, I have a question about MFC state FINISHING & FINISHED as below.
Hi Peter,
I have answered your question below.
Quoted 235 lines
Quoted 8 lines
-----Original Message-----
From: [email protected] [mailto:linux-media- [email protected]] On Behalf Of Kamil Debski
Sent: Saturday, January 08, 2011 1:26 AM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected];Quoted 36 lines
[email protected]; [email protected]; [email protected]
Subject: [RFC/PATCH v6 3/4] MFC: Add MFC 5.1 V4L2 driverMulti Format Codec 5.1 is capable of handling a range of video codecs and this driver provides V4L2 interface for video decoding.
Signed-off-by Kamil Debski <[email protected]>Signed-off-by Kyungmin Park <[email protected]>--- drivers/media/video/Kconfig | 8 + drivers/media/video/Makefile | 1 + drivers/media/video/s5p-mfc/Makefile | 3 + drivers/media/video/s5p-mfc/regs-mfc5.h | 335 +++++ drivers/media/video/s5p-mfc/s5p_mfc.c | 2072 ++++++++++++++++++++++++++ drivers/media/video/s5p-mfc/s5p_mfc_common.h | 224 +++ drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h | 173 +++ drivers/media/video/s5p-mfc/s5p_mfc_debug.h | 47 + drivers/media/video/s5p-mfc/s5p_mfc_intr.c | 92 ++ drivers/media/video/s5p-mfc/s5p_mfc_intr.h | 26 + drivers/media/video/s5p-mfc/s5p_mfc_memory.h | 43 + drivers/media/video/s5p-mfc/s5p_mfc_opr.c | 885 +++++++++++ drivers/media/video/s5p-mfc/s5p_mfc_opr.h | 160 ++ 13 files changed, 4069 insertions(+), 0 deletions(-) create mode 100644 drivers/media/video/s5p-mfc/Makefile create mode 100644 drivers/media/video/s5p-mfc/regs-mfc5.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_common.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_debug.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_intr.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_intr.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_memory.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_opr.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_opr.hSnipped...
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 12 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +12
-0+/* Videobuf opts */ +static struct vb2_ops s5p_mfc_qops = { + .buf_queue = s5p_mfc_buf_queue, + .queue_setup = s5p_mfc_queue_setup, + .start_streaming = s5p_mfc_start_streaming, + .buf_init = s5p_mfc_buf_init, + .stop_streaming = s5p_mfc_stop_streaming, + .wait_prepare = s5p_mfc_unlock, + .wait_finish = s5p_mfc_lock, +}; + +static void s5p_mfc_handle_frame_all_extracted(struct s5p_mfc_ctx*ctx)
Quoted 22 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +22
-0+{ +struct s5p_mfc_dev *dev = ctx->dev; +struct s5p_mfc_buf *dst_buf; + + ctx->state =MFCINST_DEC_FINISHED ; +mfc_debug ("Decided to finish\n" ); + ctx->sequence++; +while (!list_empty (&ctx->dst_queue)) { + dst_buf =list_entry (ctx->dst_queue.next, + struct s5p_mfc_buf, list); +mfc_debug ("Cleaning up buffer: %d\n" , + dst_buf->b->v4l2_buf.index); +vb2_set_plane_payload (dst_buf->b,0 ,0 ); +vb2_set_plane_payload (dst_buf->b,1 ,0 ); +list_del (&dst_buf->list); + ctx->dst_queue_cnt--; + dst_buf->b->v4l2_buf.sequence = (ctx->sequence++); +if (s5p_mfc_get_pic_time_top (ctx) == +s5p_mfc_get_pic_time_bottom (ctx)) + dst_buf->b->v4l2_buf.field =V4L2_FIELD_NONE ; +else + dst_buf->b->v4l2_buf.field =drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+V4L2_FIELD_INTERLACED ; + ctx->dec_dst_flag &= ~(1 << dst_buf->b->v4l2_buf.index); +vb2_buffer_done (dst_buf->b,VB2_BUF_STATE_DONE ); +mfc_debug ("Cleaned up buffer: %d\n" , + dst_buf->b->v4l2_buf.index); + } +mfc_debug ("After cleanup\n" ); +} + +static void s5p_mfc_handle_frame_new(struct s5p_mfc_ctx *ctx,unsigned
Quoted 12 lines
int err)
drivers/media/video/s5p-mfc/s5p_mfc.c new file +11
-0+{ +struct s5p_mfc_dev *dev = ctx->dev; +struct s5p_mfc_buf *dst_buf; +size_t dspl_y_addr =s5p_mfc_get_dspl_y_adr (); + + ctx->sequence++; +/* If frame is same as previous then skip and do not dequeue */ +if (s5p_mfc_get_frame_type () ==S5P_FIMV_DECODE_FRAME_SKIPPED ) +return ; +/* The MFC returns address of the buffer, now we have to +* check which videobuf does it correspond to */ drivers/media/video/s5p-mfc/s5p_mfc.c line 1356
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+list_for_each_entry (dst_buf, &ctx->dst_queue, list) { +mfc_debug ("Listing: %d\n" , dst_buf->b->v4l2_buf.index); +/* Check if this is the buffer we're looking for */ +if (vb2_cma_plane_paddr (dst_buf->b,0 ) == dspl_y_addr) { +list_del (&dst_buf->list); + ctx->dst_queue_cnt--; + dst_buf->b->v4l2_buf.sequence = ctx->sequence; +if (s5p_mfc_get_pic_time_top (ctx) == +s5p_mfc_get_pic_time_bottom (ctx)) + dst_buf->b->v4l2_buf.field =
V4L2_FIELD_NONE;Quoted 7 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+else + dst_buf->b->v4l2_buf.field = +V4L2_FIELD_INTERLACED ; + vb2_set_plane_payload(dst_buf->b, 0, ctx-
luma_size);(quoted diff) +1
-0+ vb2_set_plane_payload(dst_buf->b, 1, ctx-
chroma_size);drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 7 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +7
-0+clear_bit (dst_buf->b->v4l2_buf.index, + &ctx->dec_dst_flag); +if (err) { +vb2_buffer_done (dst_buf->b, +VB2_BUF_STATE_ERROR ); + }else { + vb2_buffer_done(dst_buf->b,
VB2_BUF_STATE_DONE);drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 9 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +9
-0+ } +break ; + } + } +} + +/* Handle frame decoding interrupt */ +static void s5p_mfc_handle_frame (struct s5p_mfc_ctx *ctx, + unsigned int reason, unsigned interr)
Quoted 16 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +16
-0+{ +struct s5p_mfc_dev *dev = ctx->dev; +unsigned int dst_frame_status; +struct s5p_mfc_buf *src_buf; +unsigned long flags; + + dst_frame_status =s5p_mfc_get_dspl_status () + &S5P_FIMV_DEC_STATUS_DECODING_STATUS_MASK ; +mfc_debug ("Frame Status: %x\n" , dst_frame_status); +spin_lock_irqsave (&dev->irqlock, flags); +/* All frames remaining in the buffer have been extracted */ +if (dst_frame_status ==S5P_FIMV_DEC_STATUS_DECODING_EMPTY ) { +s5p_mfc_handle_frame_all_extracted (ctx); + } + +/* A frame has been decoded and is in the buffer */ drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+if (dst_frame_status ==S5P_FIMV_DEC_STATUS_DISPLAY_ONLY || + dst_frame_status ==S5P_FIMV_DEC_STATUS_DECODING_DISPLAY ) { +s5p_mfc_handle_frame_new (ctx, err); + }else { +mfc_debug ("No frame decode.\n" ); + } +/* Mark source buffer as complete */ +if (dst_frame_status !=S5P_FIMV_DEC_STATUS_DISPLAY_ONLY + && !list_empty (&ctx->src_queue)) { + src_buf = list_entry(ctx->src_queue.next, struct
s5p_mfc_buf,Review
Quoted 5 lines
(quoted diff) +2
-0+ list); + mfc_debug("Packed PB test. Size:%d, prev offset: %ld, thisrun:"
(quoted diff) +2
-0+ " %d\n", src_buf->b->v4l2_planes[0].bytesused, + ctx->consumed_stream,
s5p_mfc_get_consumed_stream());Quoted 16 lines
(quoted diff) +2
-0+ ctx->consumed_stream += s5p_mfc_get_consumed_stream(); + if (s5p_mfc_get_frame_type() ==
S5P_FIMV_DECODE_FRAME_P_FRAME(quoted diff) +2
-0+ && ctx->consumed_stream < + src_buf->b-v4l2_planes[0].bytesused) {
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+/* Run MFC again on the same buffer */ +mfc_debug ("Running again the same buffer.\n" ); + s5p_mfc_set_dec_stream_buffer(ctx, + src_buf->cookie.stream, ctx-
consumed_stream,(quoted diff) +2
-0+ src_buf->b->v4l2_planes[0].bytesused - + ctx-
consumed_stream);drivers/media/video/s5p-mfc/s5p_mfc.c new file +2
-0+ dev->curr_ctx = ctx->num; +s5p_mfc_clean_ctx_int_flags (ctx);drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+spin_unlock_irqrestore (&dev->irqlock, flags); +s5p_mfc_clear_int_flags (); +wake_up_ctx (ctx, reason, err); +s5p_mfc_decode_one_frame (ctx,0 ); +return ; + }else { +mfc_debug ("MFC needs next buffer.\n" ); +/* Advance to next buffer */ +if (src_buf->b->v4l2_planes[0 ].bytesused ==0 ) { + mfc_debug("Setting ctx->state toFINISHING\n");
drivers/media/video/s5p-mfc/s5p_mfc.c
Quoted 10 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +10
-0+ ctx->state =MFCINST_DEC_FINISHING ; + } + ctx->consumed_stream =0 ; +list_del (&src_buf->list); + ctx->src_queue_cnt--; +vb2_buffer_done (src_buf->b,VB2_BUF_STATE_DONE ); + } + } +spin_unlock_irqrestore (&dev->irqlock, flags); + mfc_debug("Assesing whether this context should be runagain.\n");
Review
Quoted 1 line
(quoted diff) +1
-0+ if ((ctx->src_queue_cnt == 0 && ctx->state !=
MFCINST_DEC_FINISHING)Review
Quoted 1 line
(quoted diff) +1
-0+ || ctx->dst_queue_cnt < ctx->dpb_count){
drivers/media/video/s5p-mfc/s5p_mfc.c line 1450
Quoted 12 lines
drivers/media/video/s5p-mfc/s5p_mfc.c new file +4
-0+mfc_debug ("No need to run again.\n" ); +clear_work_bit (ctx); + } + mfc_debug("After assesing whether this context should be runagain.\n");
drivers/media/video/s5p-mfc/s5p_mfc.c new file +7
-0+s5p_mfc_clear_int_flags (); +wake_up_ctx (ctx, reason, err); +if (test_and_clear_bit (0 , &dev->hw_lock) ==0 ) +BUG (); +s5p_mfc_try_run (dev); +} +Basically, I understand that FINISHING state is starting point just after
src
queue/dequeue is
finished. And state goes to the FINISHED right after all extracted. But, you change state as a FINISHED at beginning ofs5p_mfc_handle_frame_all_extracted().Quoted 8 lines
What about FINISHING state ?
if (src_buf->b->v4l2_planes[0].bytesused == 0) this condition meets after
FINISHED state set
So, it is confusing if state change like (RUNNING -> FINISHING -> FINISHED)
is
right.The state flow is as follows:
1) The driver receives an src buffer with bytesused set to 0 State is changed from RUNNING to FINISHING.
At this point the command that is sent to MFC hw isS5P_FIMV_CH_LAST_FRAME(akaLAST_SEQ).
2) The driver dequeued remaining frames frame by frame. State is FINISHING,S5P_FIMV_CH_LAST_FRAMEcommands are sent and frames are dequeued in the interrupt handler.
3) If DISPLAY_STATUS[2:0] = 3 (DPB is empty and decoding is finished) Then state is changed to FINISHED. This is the time whens5p_mfc_handle_frame_all_extractedis called.I guess that the thing that bothers you is the place where state is set to FINISHING. This could be moved to
s5p_mfc_run_dec_frame- maybe the code
would be clearer. Anyway I think still it is ok, because the following code:if (src_buf->b->v4l2_planes[0].bytesused == 0) { mfc_debug("Setting ctx->state to FINISHING\n"); ctx->state = MFCINST_DEC_FINISHING; }
Quoted 9 lines
Is run only if the following condition:
if (
dst_frame_status!=S5P_FIMV_DEC_STATUS_DISPLAY_ONLY&& !list_empty(&ctx->src_queue))is met.
I hope I have answered your question.
I just checked your concept of FINISHING & FINISHED by asking you. Yes, it is OK. The condition might be right to set FINISHING & FINISHED. But, order of setting state is wrong. In your sequence of s5p_mfc_handle_frame(),
FINISHED is firstly set before set FINISHING. So we need to move position to set
FINISHING state as you mentioned as above.
Quoted 8 lines
Quoted 2 lines
Snipped...
Bets regards,
--
Kamil Debski
Linux Platform Group
Samsung Poland R&D Center
PATCH v6 4/4 s5pv210: Enable MFC on Goni
In reply to Kamil DebskiThis patch enables MFC 5.1 on Goni board. Multi Format Codec 5.1 is capable of handling a range of video codecs.
--- arch/arm/mach-s5pv210/Kconfig | 1 + arch/arm/mach-s5pv210/mach-goni.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletions(-)
arch/arm/mach-s5pv210/Kconfig +1 -0
@@ -85,6 +85,7 @@ config MACH_GONI select S3C_DEV_HSMMC2 select S3C_DEV_I2C1 select S3C_DEV_I2C2 + select S5P_DEV_MFC select S3C_DEV_USB_HSOTG select S5P_DEV_ONENAND select SAMSUNG_DEV_KEYPAD
arch/arm/mach-s5pv210/mach-goni.c +2 -1
@@ -810,6 +810,7 @@ static struct platform_device *goni_devices[] __initdata = { &goni_i2c_gpio5, &mmc2_fixed_voltage, &goni_device_gpiokeys, + &s5p_device_mfc, &s5p_device_fimc0, &s5p_device_fimc1, &s5p_device_fimc2,
@@ -857,7 +858,7 @@ static void __init goni_reserve(void) };static const char map[]__initconst = -"s5p-mfc5/f=fw;s5p-mfc5/a=b1;s5p-mfc5/b=b2;*=b1,b2" ; +"s5p-mfc/f=fw;s5p-mfc/a=b1;s5p-mfc/b=b2;*=b1,b2" ;cma_set_defaults (regions, map);cma_early_regions_reserve (NULL );
Signature · 1 line
1.6.3.3
Hi Kamil,
I still need to review this carefully since this is the first codec driver. I had hoped to do this during the weekend, but I didn't manage it. I hope I can get to it on Friday.
One thing I noticed: you aren't using the control framework in this driver. Please switch to that. From now on I will NACK any new driver that is not using that framework. I'm in the process of converting all existing drivers to it, and I don't want to have to fix new drivers as well :-)
Documentation is in Documentation/video4linux/v4l2-controls.txt.
Regards,
Hans
Quoted 261 lines · On Friday, January 07, 2011 17:25:30 Kamil Debski wrote:
Hello,
This is the sixth version of the MFC 5.1 driver, decoding part. The suggestions and comments from the group members have been very helpful.
I would be grateful for your comments. Original cover letter ant detailed change log has been attached below.
Best regards,
Kamil Debski* Changelog:
==================
Changes since v5
==================1) Changes suggested by Hans Verkuil:
- small change invideodev2.h- corrected control offsets
- made the code more readable by simplifying if statements and using temporary pointers
-mfc_mutexis now included ins5p_mfc_devstructure
- after discussion with Peter Oh modification of fourcc defintions (replaced DX52 and DX53 with DX50)2) Changes suggested by JongHun Han:
- comsmetic changed of defines inregs-mfc5.h
- in buffers that have no width adn height, such as the buffer for compressed stream, those values are set to 0 instead of 1
- remove redundant pointer to MFC registers
- change name of the union ins5p_mfc_buffrom paddr to cookie
- removed global variable (structs5p_mfc_dev*dev) and moved to usevideo_drvdata3) Other changes:
- added check for values returned after parsing header - in rare circumstances MFC hw returned0x0as image size and this could cause problems==================
Changes since v4
==================1) Changes suggested by Kukjin Kim from:
- removed commentarch/arm/mach-s5pv210/include/mach/map.h
- changed device name to s5p-mfc (removed "5", MFC version number) also removed the version number from the name of MFC device file
- added GPL license toarch/arm/plat-s5p/dev-mfc.c
- removed unused include file fromdev-mfc.cand unnecessary comments2) Cache handling improvement:
- changed cache handling to usedma_map_singleanddma_unmap_single==================
Changes since v3
==================1) Update to the v6 videobuf2 API (here thanks go to Marek Szyprowski)
-s5p_mfc_buf_negotiateands5p_mfc_buf_setup_planefunctions have been merged
- queue initialization has been adapted to the new API
- use of the allocator memops has been changed, now there are single memops for all the allocator contexts2) Split of the
s5p_mfc_try_runands5p_mfc_handle_frame_intfunctions
- parts of thes5p_mfc_try_runfunction have been moved to separate functions (s5p_mfc_get_new_ctx,s5p_mfc_run_dec_last_frames,s5p_mfc_run_dec_frame,s5p_mfc_run_get_inst_no,s5p_mfc_run_return_insts5p_mfc_run_init_dec,s5p_mfc_run_init_dec_buffers)
-s5p_mfc_handle_frame_inthas been split to the following functions:s5p_mfc_handle_frame_all_extracted,s5p_mfc_handle_frame_newands5p_mfc_handle_frameto handle different cases3) Remove remaining magic numbers and tidy up comments
==================
Changes since v2
==================1) Update to newest videobuf2 API
This is the major change from v2. The videobuf2 API will hopefully have no more major API changes. Buffer initialization has been moved frombuf_preparecallback tobuf_initto simplify the process. Locking mechanism has been modified to the requirements of new videobuf2 version.
2) Code cleanup
Removed more magic contants and replaced them with appropriate defines. Changed code to useunlocked_ioctlinstead of ioctl in v4l2 file ops.
3) Allocators
All internal buffer allocations are done using the selected vb2 allocator, instead of using CMA functions directly.==================
Changes since v1
==================1) Cleanup accoridng to Peter Oh suggestions on the mailing list (Thanks).
* Original cover letter:
==============
Introduction
==============The purpose of this RFC is to discuss the driver for a hw video codec embedded in the new Samusng's SoCs. Multi Format Codec 5.0 is able to handle video decoding of in a range of formats.
So far no hardware codec was supported in V4L2 and this would be the first one. I guess there are more similar device that would benefit from a V4L2 unified interface. I suggest a separate control class for codec devices -
V4L2_CTRL_CLASS_CODEC.Internally the driver uses videobuf2 framework and CMA memory allocator. I am aware that those have not yet been merged, but I wanted to start discussion about the driver earlier so it could be merged sooner. The driver posted here is the initial version, so I suppose it will require more work.
==================
Device interface
==================The driver principle is based on the idea of memory-to-memory devices:
it provides a single video node and each opened file handle gets its own private context with separate buffer queues. Each context consist of 2 buffer queues: OUTPUT (for source buffers, i.e. encoded video frames) and CAPTURE (for destination buffers, i.e. decoded raw video frames). The process of decoding video data from stream is a bit more complicated than typical memory-to-memory processing, that's why the m2m framework is not directly used (it is too limited for this case). The main reason for this is the fact that the CAPTURE buffers can be dequeued in a different order than they queued. The hw block decides which buffer has been completely processed. This is due to the structure of most compressed video streams - use of B frames causes that decoding and display order may be different.==============================
Decoding initialization path
==============================First the OUTPUT queue is initialized. With
S_FMTthe application chooses which video format to decode and what size should be the input buffer. Fourcc values have been defined for different codecs e.g.V4L2_PIX_FMT_H264for h264. Then the OUTPUT buffers are requested and mmaped. The stream header frame is loaded into the first buffer, queued and streaming is enabled. At this point the hardware is able to start processing the stream header and afterwards it will have information about the video dimensions and the size of the buffers with raw video data.The next step is setting up the CAPTURE queue and buffers. The width, height, buffer size and minimum number of buffers can be read with
G_FMTcall. The application can request more output buffer if necessary. After requesting and mmaping buffers the device is ready to decode video stream.The stream frames (ES frames) are written to the OUTPUT buffers, and decoded video frames can be read from the CAPTURE buffers. When no more source frames are present a single buffer with bytesused set to 0 should be queued. This will inform the driver that processing should be finished and it can dequeue all video frames that are still left. The number of such frames is dependent on the stream and its internal structure (how many frames had to be kept as reference frames for decoding, etc).
===============
Usage summary
===============This is a step by step summary of the video decoding (from user application point of view, with 2 treads and blocking api):
01.
S_FMT(OUTPUT, V4L2_PIX_FMT_H264, ...)
02.REQ_BUFS(OUTPUT, n)
03. for i=1..nMMAP(OUTPUT, i)
04. put stream header to buffer #1
05.QBUF(OUTPUT, #1)
06.STREAM_ON(OUTPUT)
07.G_FMT(CAPTURE)
08.REQ_BUFS(CAPTURE, m)
09. for j=1..mMMAP(CAPTURE, j)
10. for j=1..mQBUF(CAPTURE, #j)
11.STREAM_ON(CAPTURE)display thread:
12. DQBUF(CAPTURE) -> got decoded video data in buffer #j
13. display buffer #j
14.QBUF(CAPTURE, #j)
15. goto 12parser thread:
16. put next ES frame to buffer #i
17.QBUF(OUTPUT, #i)
18. DQBUF(OUTPUT) -> get next empty buffer #i 19. goto 16...
Similar usage sequence can be achieved with single threaded application and non-blocking api with
poll()call.Branch with MFC, CMA and videobuf2 will be soon available at
http://git.infradead.org/users/kmpark/linux-2.6-samsung/shortlog/refs/heads/vb2-mfc-fimc
This tree is based on 2.6.37 rc4.Please have a look at the code and the idea of how to introduce codec devices to V4L2. Comments will be very much appreciated.
Patch summary:
Subject: [PATCH 0/4] *** SUBJECT HERE ***
*** BLURB HERE ***
Kamil Debski (4):
Changes ininclude/linux/videodev2.hfor MFC
MFC: Add MFC 5.1 driver to plat-s5p and mach-s5pv210
MFC: Add MFC 5.1 V4L2 driver
s5pv210: Enable MFC on Goniarch/arm/mach-s5pv210/Kconfig | 1 + arch/arm/mach-s5pv210/clock.c | 6 + arch/arm/mach-s5pv210/include/mach/map.h | 4 + arch/arm/mach-s5pv210/mach-goni.c | 3 +- arch/arm/plat-s5p/Kconfig | 5 + arch/arm/plat-s5p/Makefile | 2 +- arch/arm/plat-s5p/dev-mfc.c | 49 + arch/arm/plat-samsung/include/plat/devs.h | 2 + drivers/media/video/Kconfig | 8 + drivers/media/video/Makefile | 1 + drivers/media/video/s5p-mfc/Makefile | 3 + drivers/media/video/s5p-mfc/regs-mfc5.h | 335 ++++ drivers/media/video/s5p-mfc/s5p_mfc.c | 2072 +++++++++++++++++++++++ drivers/media/video/s5p-mfc/s5p_mfc_common.h | 224 +++ drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h | 173 ++ drivers/media/video/s5p-mfc/s5p_mfc_debug.h | 47 + drivers/media/video/s5p-mfc/s5p_mfc_intr.c | 92 + drivers/media/video/s5p-mfc/s5p_mfc_intr.h | 26 + drivers/media/video/s5p-mfc/s5p_mfc_memory.h | 43 + drivers/media/video/s5p-mfc/s5p_mfc_opr.c | 885 ++++++++++ drivers/media/video/s5p-mfc/s5p_mfc_opr.h | 160 ++ include/linux/videodev2.h | 45 + 25 files changed, 4233 insertions(+), 3 deletions(-) create mode 100644 arch/arm/plat-s5p/dev-mfc.c create mode 100644 drivers/media/video/s5p-mfc/Makefile create mode 100644 drivers/media/video/s5p-mfc/regs-mfc5.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_common.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_debug.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_intr.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_intr.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_memory.h create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_opr.c create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_opr.h--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Hans Verkuil - video4linux developer - sponsored by Cisco
Hi Hans,
Quoted 8 lines
From: Hans Verkuil [mailto:[email protected]]
Hi Kamil,I still need to review this carefully since this is the first codec driver.
I had hoped to do this during the weekend, but I didn't manage it. I hope I
can get to it on Friday.
This would be great.
Quoted 10 lines
One thing I noticed: you aren't using the control framework in this driver.
Please switch to that. From now on I will NACK any new driver that is not
using that framework. I'm in the process of converting all existing drivers
to it, and I don't want to have to fix new drivers as well :-)Documentation is in
Documentation/video4linux/v4l2-controls.txt.
I am aware of that. I think my reply to one of your previous comments might have got lost in your inbox.
I have doubts about the point of using the control framework in my case. I agree with you that for the majority of drivers it will be very useful. In case of MFC or mem2mem FIMC - those two drivers use per file handle contexts and that's the thing that stops me from using your framework.
If I understand the control framework correctly, there is no support for such use case. When S_CTRL is run on an MFC driver then the value passed to the driver is stored in s5p_mfc_ctx structure instead of writing this to hardware directly. This value is then used, when it is necessary to setup hardware. For example before running codec initialization for that context.
In case of the control framework, the I could implement my .s_ctrl callback which sets the appropriate field in s5p_mfc_ctx structure. The thing I don't like about this is the redundancy of storing the control value. In the one instance scenario it is stored in the driver in s5p_mfc_ctx
and in the control fw. In multiple instance scenario the values in s5p_mfc_ctx
and in the control fw will be different. I know that there are volatile controls in the framework, but in this case all controls would have to be volatile.
Correct me if I am wrong, but I don't see that the control framework is for mem2mem drivers that can have multiple contexts. Again, I agree with you that it is generally a good idea, but not for every driver. I am open to discuss this use case with you - maybe some functionality could be added to the control framework?
Best wishes,
--
Kamil Debski
Linux Platform Group
Samsung Poland R&D Center
Quoted 14 lines · On Friday, January 07, 2011 17:25:30 Kamil Debski wrote:
Quoted 3 lines
Hello,
This is the sixth version of the MFC 5.1 driver, decoding part. The
suggestions
Quoted 3 lines
and comments from the group members have been very helpful.
I would be grateful for your comments. Original cover letter ant
detailed change
Quoted 4 lines
log has been attached below.
Best regards,
Kamil Debski
<snip>
Quoted 49 lines · On Monday, January 17, 2011 08:35:21 Kamil Debski wrote:
Hi Hans,
Quoted 8 lines
From: Hans Verkuil [mailto:[email protected]]
Hi Kamil,I still need to review this carefully since this is the first codec driver.
I had hoped to do this during the weekend, but I didn't manage it. I hope I
can get to it on Friday.This would be great.
Quoted 10 lines
One thing I noticed: you aren't using the control framework in this driver.
Please switch to that. From now on I will NACK any new driver that is not
using that framework. I'm in the process of converting all existing drivers
to it, and I don't want to have to fix new drivers as well :-)Documentation is in
Documentation/video4linux/v4l2-controls.txt.I am aware of that. I think my reply to one of your previous comments might have got lost in your inbox.
I have doubts about the point of using the control framework in my case. I agree with you that for the majority of drivers it will be very useful. In case of MFC or mem2mem FIMC - those two drivers use per file handle contexts and that's the thing that stops me from using your framework.
If I understand the control framework correctly, there is no support for such use case. When
S_CTRLis run on an MFC driver then the value passed to the driver is stored ins5p_mfc_ctxstructure instead of writing this to hardware directly. This value is then used, when it is necessary to setup hardware. For example before running codec initialization for that context.In case of the control framework, the I could implement my .s_ctrl callback which sets the appropriate field in
s5p_mfc_ctxstructure. The thing I don't like about this is the redundancy of storing the control value. In the one instance scenario it is stored in the driver ins5p_mfc_ctx
and in the control fw. In multiple instance scenario the values ins5p_mfc_ctx
and in the control fw will be different. I know that there are volatile controls in the framework, but in this case all controls would have to be volatile.
Quoted 5 lines
Correct me if I am wrong, but I don't see that the control framework is for mem2mem drivers that can have multiple contexts. Again, I agree with you that it is generally a good idea, but not for every driver. I am open to discuss this use case with you - maybe some functionality could be added to the control framework?
Normally the struct v4l2_ctrl_handler is put in either the top-level device structure (a global handler) or it is per-device node. But there is nothing preventing you from doing this per-filehandle.
However, a small change will be needed to the v4l framework since right now it assumes that struct video_device has a pointer to the corresponding control handler. This should be moved down to struct v4l2_fh.
So struct v4l2_fh should get a pointer to a v4l2_ctrl_handler. If not set, then it will use any value set in video_device. And v4l2-ioctl.c should use the struct v4l2_fh control handler pointer if available.
These changes are very minor and then you can use per-filehandle controls.
The reason why I want drivers to use this is that it is next to impossible to write full-featured and correct control handling code without it. I've been implementing control API tests to v4l2-compliance and it is depressing to see how few drivers actually do the right thing.
Regards,
Hans
Quoted 29 lines
Best wishes,
--
Kamil Debski
Linux Platform Group
Samsung Poland R&D CenterQuoted 14 lines · On Friday, January 07, 2011 17:25:30 Kamil Debski wrote:
Quoted 3 lines
Hello,
This is the sixth version of the MFC 5.1 driver, decoding part. The
suggestions
Quoted 3 lines
and comments from the group members have been very helpful.
I would be grateful for your comments. Original cover letter ant
detailed change
Quoted 4 lines
log has been attached below.
Best regards,
Kamil Debski<snip>
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Hans Verkuil - video4linux developer - sponsored by Cisco