Skip to contentSkip to conversation

Multi Format Codec 5.0 driver for S5PC110 SoC

PATCH Superseded Kamil Debski 4 participants 15 messages Dec 9, 2010 – Dec 10, 2010 1 message not in the archive

Subsystems (4)

v4 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v4 cover Multi Format Codec 5.0 driver for S5PC110 SoC

Hello,

Last week v3 of this driver has been posted. Since then the driver was changed to use the newest videobuf2 version - v6. Two very long functions have been split to make the code more readible. Minor changes include tidying the comments and replacing remaining magic numbers with defines.

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 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:

Kamil Debski (4):
Changes in include/linux/videodev2.h for MFC
MFC: Add MFC 5.1 driver to plat-s5p, mach-s5pv210 and mach-s5pv210
MFC: Added 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               |    1 +
 arch/arm/plat-s5p/Kconfig                       |    5 +
 arch/arm/plat-s5p/Makefile                      |    1 +
 arch/arm/plat-s5p/dev-mfc5.c                    |   37 +
 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           | 2031 +++++++++++++++++++++++
 drivers/media/video/s5p-mfc/s5p_mfc_common.h    |  222 +++
 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       |  870 ++++++++++
 drivers/media/video/s5p-mfc/s5p_mfc_opr.h       |  131 ++
 include/linux/videodev2.h                       |   48 +
 25 files changed, 4136 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/plat-s5p/dev-mfc5.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
#1 lore raw

PATCH v4 1/4 Changes in include/linux/videodev2.h for MFC 5.1

Add 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 |   48 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 48 insertions(+), 0 deletions(-)
include/linux/videodev2.h +48 -0
index d30c98d..c89f019 100644
@@ -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,21 @@ 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_DIVX500    v4l2_fourcc('D', 'X', '5', '2') /* DivX 5.00 - 5.02  */
+#define V4L2_PIX_FMT_DIVX503    v4l2_fourcc('D', 'X', '5', '3') /* DivX 5.03 - x  */
+#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 +995,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 +1033,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 +1367,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 + 9)
+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 + 110)
+#define V4L2_CID_CODEC_DISPLAY_DELAY		(V4L2_CID_CODEC_BASE + 137)
+#define V4L2_CID_CODEC_REQ_NUM_BUFS		(V4L2_CID_CODEC_BASE + 140)
+#define V4L2_CID_CODEC_SLICE_INTERFACE		(V4L2_CID_CODEC_BASE + 141)
+#define V4L2_CID_CODEC_PACKED_PB		(V4L2_CID_CODEC_BASE + 142)
+
 /*  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
#2 lore raw

RE: [RFC/PATCH v4 1/4] Changes in include/linux/videodev2.h for MFC 5.1

Hi, Kamil

What do you think modification of codec class control ID for MFC as following.
1. Define the CID base for MFC
2. Separate decode & encode controls
3. Separate common & codec-specific controls

Quoted 16 lines

Add 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 |   48
+++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 48 insertions(+), 0 deletions(-)
include/linux/videodev2.h +0 -0
index d30c98d..c89f019 100644

include/linux/videodev2.h struct v4l2_pix_format { · line 339

Quoted 1 line
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

Quoted 2 lines

4:2:2 */
#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') /* 16

Y/CrCb

include/linux/videodev2.h

Quoted 4 lines

4:2:2 */

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

Quoted 10 lines

4:2:0 */

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 */
+
/* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */ #define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') /* 8

BGBG..

Quoted 2 lines

GRGR.. */
#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') /* 8

GBGB..

include/linux/videodev2.h

Quoted 9 lines

RGRG.. */

include/linux/videodev2.h +0 -0
@@ -362,6 +370,21 @@ 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 */

include/linux/videodev2.h +2 -0
+
+#define V4L2_PIX_FMT_H264     v4l2_fourcc('H', '2', '6', '4') /* H264

*/

Quoted 1 line

+#define V4L2_PIX_FMT_H263 v4l2_fourcc('H', '2', '6', '3') /* H263

*/

include/linux/videodev2.h

Quoted 6 lines

+#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
*/

include/linux/videodev2.h +2 -0
+#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

Quoted 2 lines

*/
+#define V4L2_PIX_FMT_DIVX4 v4l2_fourcc('D', 'I', 'V', '4') /* DivX

4.12

include/linux/videodev2.h struct v4l2_pix_format {

Quoted 13 lines

*/
+#define V4L2_PIX_FMT_DIVX500 v4l2_fourcc('D', 'X', '5', '2') /* DivX
5.00 - 5.02 */
+#define V4L2_PIX_FMT_DIVX503 v4l2_fourcc('D', 'X', '5', '3') /* DivX
5.03 - x */

include/linux/videodev2.h +3 -0
+#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 */

include/linux/videodev2.h +2 -0
+
+
 /*  Vendor-specific formats   */
 #define V4L2_PIX_FMT_CPIA1    v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1

YUV

Quoted 2 lines

*/
#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W', 'N', 'V', 'A') /* Winnov

hw

Quoted 22 lines

compress */

include/linux/videodev2.h +1 -0
@@ -972,6 +995,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 */

include/linux/videodev2.h +0 -0
@@ -1009,6 +1033,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 */

include/linux/videodev2.h +1 -0
+#define V4L2_CTRL_CLASS_CODEC 0x009c0000	/* Codec control class */
 
 #define V4L2_CTRL_ID_MASK      	  (0x0fffffff)
 #define V4L2_CTRL_ID2CLASS(id)    ((id) & 0x0fff0000UL)

include/linux/videodev2.h enum v4l2_mpeg_cx2341x_video_median_filter_type { · line 1376

Quoted 10 lines
include/linux/videodev2.h +4 -0
@@ -1342,6 +1367,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)

Quoted 9 lines
include/linux/videodev2.h +9 -0
+
+/* For both decoding and encoding */
+
+/* For encoding */
+#define V4L2_CID_CODEC_LOOP_FILTER_H264		(V4L2_CID_CODEC_BASE
+ 9)
+enum v4l2_cid_codec_loop_filter_h264 {
+	V4L2_CID_CODEC_LOOP_FILTER_H264_ENABLE = 0,
+	V4L2_CID_CODEC_LOOP_FILTER_H264_DISABLE = 1,

include/linux/videodev2.h enum v4l2_mpeg_cx2341x_video_median_filter_type {

Quoted 10 lines
include/linux/videodev2.h +10 -0
+	V4L2_CID_CODEC_LOOP_FILTER_H264_DISABLE_AT_BOUNDARY = 2,
+};
+
+/* For decoding */
+
+#define V4L2_CID_CODEC_LOOP_FILTER_MPEG4_ENABLE	(V4L2_CID_CODEC_BASE
+ 110)
+#define V4L2_CID_CODEC_DISPLAY_DELAY		(V4L2_CID_CODEC_BASE + 137)
+#define V4L2_CID_CODEC_REQ_NUM_BUFS		(V4L2_CID_CODEC_BASE + 140)
+#define

V4L2_CID_CODEC_SLICE_INTERFACE (V4L2_CID_CODEC_BASE + 141)

Quoted 7 lines
include/linux/videodev2.h +2 -1
+#define V4L2_CID_CODEC_PACKED_PB		(V4L2_CID_CODEC_BASE + 142)
+
 /*  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)
--

1.6.3.3

-/* For codecs */
-
-#define V4L2_CID_CODEC_BASE (V4L2_CTRL_CLASS_CODEC |
0x900)
-#define V4L2_CID_CODEC_CLASS (V4L2_CTRL_CLASS_CODEC | 1)
+/* Codec class control IDs */
+#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 */
+/* Codec class control IDs specific to the MFC5X driver */
+#define V4L2_CID_CODEC_MFC5X_BASE (V4L2_CTRL_CLASS_CODEC |
0x1000)

-/* For encoding */
-#define V4L2_CID_CODEC_LOOP_FILTER_H264
(V4L2_CID_CODEC_BASE + 9)
-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 both decoding and encoding */

/* For decoding */
+/* common */
+#define V4L2_CID_CODEC_MFC5X_DECODE_REQ_NUM_BUFS (V4L2_CID_CODEC_MFC5X_BASE+100)
+#define V4L2_CID_CODEC_MFC5X_DECODE_SLICE_INTERFACE (V4L2_CID_CODEC_MFC5X_BASE+101)

-#define V4L2_CID_CODEC_LOOP_FILTER_MPEG4_ENABLE
(V4L2_CID_CODEC_BASE + 110)

-#define V4L2_CID_CODEC_DISPLAY_DELAY           (V4L2_CID_CODEC_BASE + 137)
-#define V4L2_CID_CODEC_REQ_NUM_BUFS            (V4L2_CID_CODEC_BASE + 140)
-#define V4L2_CID_CODEC_SLICE_INTERFACE         (V4L2_CID_CODEC_BASE + 141)
-#define V4L2_CID_CODEC_PACKED_PB               (V4L2_CID_CODEC_BASE + 142)

+/* codec specific */
+#define V4L2_CID_CODEC_MFC5X_DECODE_H264_DISPLAY_DELAY (V4L2_CID_CODEC_MFC5X_BASE+200)
+#define V4L2_CID_CODEC_MFC5X_DECODE_MPEG4_LOOP_FILTER (V4L2_CID_CODEC_MFC5X_BASE+220)
+#define V4L2_CID_CODEC_MFC5X_DECODE_MPEG4_PACKED_PB (V4L2_CID_CODEC_MFC5X_BASE+221)
+
+/* For encoding */
+/* common */
+#define V4L2_CID_CODEC_MFC5X_ENCODE_GOP_SIZE (V4L2_CID_CODEC_MFC5X_BASE+300)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_MULTI_SLICE_MODE (V4L2_CID_CODEC_MFC5X_BASE+301)
+enum v4l2_codec_mfc5x_encode_multi_slice_mode {

+       V4L2_CODEC_MFC5X_ENCODE_MULTI_SLICE_MODE_DISABLE                = 0,
+       V4L2_CODEC_MFC5X_ENCODE_MULTI_SLICE_MODE_MACROBLOCK_COUNT       = 1,
+       V4L2_CODEC_MFC5X_ENCODE_MULTI_SLICE_MODE_BIT_COUNT              = 3,

+};
+#define V4L2_CID_CODEC_MFC5X_ENCODE_MULTI_SLICE_MB (V4L2_CID_CODEC_MFC5X_BASE+302)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_MULTI_SLICE_BIT (V4L2_CID_CODEC_MFC5X_BASE+303)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_INTRA_REFRESH_MB (V4L2_CID_CODEC_MFC5X_BASE+304)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_PAD_CTRL_ENABLE (V4L2_CID_CODEC_MFC5X_BASE+305)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_PAD_LUMA_VALUE (V4L2_CID_CODEC_MFC5X_BASE+306)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_PAD_CB_VALUE (V4L2_CID_CODEC_MFC5X_BASE+307)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_PAD_CR_VALUE (V4L2_CID_CODEC_MFC5X_BASE+308)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_RC_FRAME_ENABLE (V4L2_CID_CODEC_MFC5X_BASE+309)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_RC_BIT_RATE (V4L2_CID_CODEC_MFC5X_BASE+310)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_RC_REACTION_PARAM (V4L2_CID_CODEC_MFC5X_BASE+311)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_STREAM_SIZE (V4L2_CID_CODEC_MFC5X_BASE+312)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_PICTURE_COUNT (V4L2_CID_CODEC_MFC5X_BASE+313)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_FRAME_TYPE (V4L2_CID_CODEC_MFC5X_BASE+314)
+enum v4l2_codec_mfc5x_encode_frame_type {

+       V4L2_CODEC_MFC5X_ENCODE_FRAME_TYPE_NOT_CODED    = 0,
+       V4L2_CODEC_MFC5X_ENCODE_FRAME_TYPE_I_FRAME      = 1,
+       V4L2_CODEC_MFC5X_ENCODE_FRAME_TYPE_P_FRAME      = 2,
+       V4L2_CODEC_MFC5X_ENCODE_FRAME_TYPE_B_FRAME      = 3,
+       V4L2_CODEC_MFC5X_ENCODE_FRAME_TYPE_SKIPPED      = 4,
+       V4L2_CODEC_MFC5X_ENCODE_FRAME_TYPE_OTHERS       = 5,

+};
+#define V4L2_CID_CODEC_MFC5X_ENCODE_FORCE_FRAME_TYPE (V4L2_CID_CODEC_MFC5X_BASE+315)
+enum v4l2_codec_mfc5x_encode_force_frame_type {

+       V4L2_CODEC_MFC5X_ENCODE_FORCE_FRAME_TYPE_NOT_CODED      = 1,
+       V4L2_CODEC_MFC5X_ENCODE_FORCE_FRAME_TYPE_I_FRAME        = 2,

+};
+#define V4L2_CID_CODEC_MFC5X_ENCODE_VBV_BUF_SIZE (V4L2_CID_CODEC_MFC5X_BASE+316)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_SEQ_HDR_MODE (V4L2_CID_CODEC_MFC5X_BASE+317)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_FRAME_SKIP_MODE (V4L2_CID_CODEC_MFC5X_BASE+318)
+enum v4l2_codec_mfc5x_encode_frame_skip_mode {

+       V4L2_CODEC_MFC5X_ENCODE_FRAME_SKIP_MODE_DISABLE         = 0,
+       V4L2_CODEC_MFC5X_ENCODE_FRAME_SKIP_MODE_LEVEL           = 1,
+       V4L2_CODEC_MFC5X_ENCODE_FRAME_SKIP_MODE_VBV_BUF_SIZE    = 2,

+};
+#define V4L2_CID_CODEC_MFC5X_ENCODE_RC_FIXED_TARGET_BIT (V4L2_CID_CODEC_MFC5X_BASE+319)
+
+/* codec specific */
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_B_FRAMES (V4L2_CID_CODEC_MFC5X_BASE+400)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_PROFILE (V4L2_CID_CODEC_MFC5X_BASE+401)
+enum v4l2_codec_mfc5x_encode_h264_profile {

+       V4L2_CODEC_MFC5X_ENCODE_H264_PROFILE_MAIN       = 0,
+       V4L2_CODEC_MFC5X_ENCODE_H264_PROFILE_HIGH       = 1,
+       V4L2_CODEC_MFC5X_ENCODE_H264_PROFILE_BASELINE   = 2,

+};
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_LEVEL (V4L2_CID_CODEC_MFC5X_BASE+402)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_INTERLACE (V4L2_CID_CODEC_MFC5X_BASE+403)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_LOOP_FILTER_MODE (V4L2_CID_CODEC_MFC5X_BASE+404)
+enum v4l2_codec_mfc5x_encode_h264_loop_filter {

+       V4L2_CODEC_MFC5X_ENCODE_H264_LOOP_FILTER_ENABLE                 = 0,
+       V4L2_CODEC_MFC5X_ENCODE_H264_LOOP_FILTER_DISABLE                = 1,
+       V4L2_CODEC_MFC5X_ENCODE_H264_LOOP_FILTER_DISABLE_AT_BOUNDARY    = 2,

+};
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_LOOP_FILTER_ALPHA (V4L2_CID_CODEC_MFC5X_BASE+405)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_LOOP_FILTER_BETA (V4L2_CID_CODEC_MFC5X_BASE+406)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_ENTROPY_MODE (V4L2_CID_CODEC_MFC5X_BASE+407)
+enum v4l2_codec_mfc5x_encode_h264_entropy_mode {
+ V4L2_CODEC_MFC5X_ENCODE_H264_ENTROPY_MODE_CAVLC = 0,
+ V4L2_CODEC_MFC5X_ENCODE_H264_ENTROPY_MODE_CABAC = 1,
+};
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_MAX_REF_PIC (V4L2_CID_CODEC_MFC5X_BASE+408)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_NUM_REF_PIC_4P (V4L2_CID_CODEC_MFC5X_BASE+409)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_8X8_TRANSFORM (V4L2_CID_CODEC_MFC5X_BASE+410)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_RC_MB_ENABLE (V4L2_CID_CODEC_MFC5X_BASE+411)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_RC_FRAME_RATE (V4L2_CID_CODEC_MFC5X_BASE+412)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_RC_FRAME_QP (V4L2_CID_CODEC_MFC5X_BASE+413)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_RC_MIN_QP (V4L2_CID_CODEC_MFC5X_BASE+414)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_RC_MAX_QP (V4L2_CID_CODEC_MFC5X_BASE+415)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_RC_MB_DARK (V4L2_CID_CODEC_MFC5X_BASE+416)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_RC_MB_SMOOTH (V4L2_CID_CODEC_MFC5X_BASE+417)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_RC_MB_STATIC (V4L2_CID_CODEC_MFC5X_BASE+418)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_RC_MB_ACTIVITY (V4L2_CID_CODEC_MFC5X_BASE+419)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_RC_P_FRAME_QP (V4L2_CID_CODEC_MFC5X_BASE+420)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_RC_B_FRAME_QP (V4L2_CID_CODEC_MFC5X_BASE+421)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_AR_VUI_ENABLE (V4L2_CID_CODEC_MFC5X_BASE+422)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_AR_VUI_IDC (V4L2_CID_CODEC_MFC5X_BASE+423)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_EXT_SAR_WIDTH (V4L2_CID_CODEC_MFC5X_BASE+424)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_EXT_SAR_HEIGHT (V4L2_CID_CODEC_MFC5X_BASE+425)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_OPEN_GOP (V4L2_CID_CODEC_MFC5X_BASE+426)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H264_I_PERIOD (V4L2_CID_CODEC_MFC5X_BASE+427)
+
+#define V4L2_CID_CODEC_MFC5X_ENCODE_MPEG4_B_FRAMES (V4L2_CID_CODEC_MFC5X_BASE+440)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_MPEG4_PROFILE (V4L2_CID_CODEC_MFC5X_BASE+441)
+enum v4l2_codec_mfc5x_encode_mpeg4_profile {

+       V4L2_CODEC_MFC5X_ENCODE_MPEG4_PROFILE_SIMPLE            = 0,
+       V4L2_CODEC_MFC5X_ENCODE_MPEG4_PROFILE_ADVANCED_SIMPLE   = 1,

+};
+#define V4L2_CID_CODEC_MFC5X_ENCODE_MPEG4_LEVEL (V4L2_CID_CODEC_MFC5X_BASE+442)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_MPEG4_RC_FRAME_QP (V4L2_CID_CODEC_MFC5X_BASE+443)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_MPEG4_RC_MIN_QP (V4L2_CID_CODEC_MFC5X_BASE+444)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_MPEG4_RC_MAX_QP (V4L2_CID_CODEC_MFC5X_BASE+445)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_MPEG4_QUARTER_PIXEL (V4L2_CID_CODEC_MFC5X_BASE+446)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_MPEG4_RC_P_FRAME_QP (V4L2_CID_CODEC_MFC5X_BASE+447)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_MPEG4_RC_B_FRAME_QP (V4L2_CID_CODEC_MFC5X_BASE+448)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_MPEG4_VOP_TIME_RES (V4L2_CID_CODEC_MFC5X_BASE+449)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_MPEG4_VOP_FRM_DELTA (V4L2_CID_CODEC_MFC5X_BASE+450)
+
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H263_RC_FRAME_RATE (V4L2_CID_CODEC_MFC5X_BASE+460)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H263_RC_FRAME_QP (V4L2_CID_CODEC_MFC5X_BASE+461)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H263_RC_MIN_QP (V4L2_CID_CODEC_MFC5X_BASE+462)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H263_RC_MAX_QP (V4L2_CID_CODEC_MFC5X_BASE+463)
+#define V4L2_CID_CODEC_MFC5X_ENCODE_H263_RC_P_FRAME_QP (V4L2_CID_CODEC_MFC5X_BASE+464)

Quoted 5 lines

--
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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

RE: [RFC/PATCH v4 1/4] Changes in include/linux/videodev2.h for MFC 5.1

Hi,

From: Mauro Carvalho Chehab [mailto:[email protected]]

Quoted 17 lines

Em 10-12-2010 01:32, 박정태 escreveu:

Quoted 10 lines

Hi, Kamil

What do you think modification of codec class control ID for MFC as following.
1. Define the CID base for MFC
2. Separate decode & encode controls
3. Separate common & codec-specific controls

Quoted 2 lines

Add fourcc values for compressed video stream formats and V4L2_CTRL_CLASS_CODEC. Also adds controls used by MFC 5.1 driver.

This is a very bad idea. As much as possible, controls should be generic enough
to avoid us to have the same control provided by two different hardware.

Quoted 6 lines

The only case were a control should be per-driver, is when the control is for some
very specific implementation detail on that hardware, that it is unlikely that other
chipsets will implement it at the same way.

I agree with Mauro. The point of having a general class for codecs (V4L2_CID_CODEC_CLASS) is reusing same controls for different hardware. I think that most controls, maybe all, could be used by other hw codecs.

Quoted 1 line

(snip)

Best regards,

Signature · 3 lines
Kamil Debski
Linux Platform Group
Samsung Poland R&D Center
#5 lore raw

PATCH v4 2/4 MFC: Add MFC 5.1 driver to plat-s5p

In reply to Kamil Debski

Add platform support for Multi Format Codec 5.1 is a module available on S5PC110 and S5PC210 Samsung SoCs. Hardware 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                      |    1 +
 arch/arm/plat-s5p/dev-mfc5.c                    |   37 +++++++++++++++++++++++
 arch/arm/plat-samsung/include/plat/devs.h       |    2 +
 9 files changed, 104 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/plat-s5p/dev-mfc5.c
arch/arm/mach-s5pv210/clock.c +6 -0
index 5014b62..f7d742d 100644
@@ -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
index 0982443..8f887c4 100644
@@ -107,6 +107,9 @@
 #define S5PV210_PA_DMC0		(0xF0000000)
 #define S5PV210_PA_DMC1		(0xF1400000)
 
+/* MFC */
+#define S5PV210_PA_MFC		(0xF1700000)
+
 /* 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
index 9755df9..c7a048e 100644
@@ -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 -0
index df65cb7..ed0f33d 100644
@@ -23,6 +23,7 @@ obj-$(CONFIG_PM)		+= pm.o
 obj-$(CONFIG_PM)		+= irq-pm.o
 
 # devices
+obj-$(CONFIG_S5P_DEV_MFC)	+= dev-mfc5.o
 
 obj-$(CONFIG_S5P_DEV_FIMC0)	+= dev-fimc0.o
 obj-$(CONFIG_S5P_DEV_FIMC1)	+= dev-fimc1.o
arch/arm/plat-s5p/dev-mfc5.c new file +37 -0
new file mode 100644
index 0000000..c06ea97
@@ -0,0 +1,37 @@
+/* Base S3C64XX mfc resource and device definitions */
+
+
+#include <linux/kernel.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/ioport.h>
+
+#include <mach/map.h>
+#include <plat/map-base.h>
+#include <plat/devs.h>
+#include <plat/irqs.h>
+
+/* MFC controller */
+static struct resource s5p_mfc_resource[] = {
+	[0] = {
+		.start  = S5P_PA_MFC,
+		.end    = S5P_PA_MFC + SZ_64K - 1,
+		.flags  = IORESOURCE_MEM,
+	},
+	[1] = {
+		.start  = IRQ_MFC,
+		.end    = IRQ_MFC,
+		.flags  = IORESOURCE_IRQ,
+	}
+};
+
+struct platform_device s5p_device_mfc5 = {
+	.name          = "s5p-mfc5",
+	.id            = -1,
+	.num_resources = ARRAY_SIZE(s5p_mfc_resource),
+	.resource      = s5p_mfc_resource,
+};
+
+EXPORT_SYMBOL(s5p_device_mfc5);
+
+
arch/arm/plat-samsung/include/plat/devs.h +2 -0
index 628b331..fc169da 100644
@@ -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_mfc5;
+
 /* s3c2440 specific devices */
 
 #ifdef CONFIG_CPU_S3C2440
Signature · 1 line
1.6.3.3
#6 lore raw

RE: [RFC/PATCH v4 2/4] MFC: Add MFC 5.1 driver to plat-s5p

Quoted 1 line · Kamil Debski

Would be better if you could keep the subject style...

Quoted 41 lines

Add platform support for Multi Format Codec 5.1 is a module available on S5PC110 and S5PC210 Samsung SoCs. Hardware 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                      |    1 +
 arch/arm/plat-s5p/dev-mfc5.c                    |   37
+++++++++++++++++++++++
 arch/arm/plat-samsung/include/plat/devs.h       |    2 +
 9 files changed, 104 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/plat-s5p/dev-mfc5.c
arch/arm/mach-s5pv210/clock.c +6 -0
index 5014b62..f7d742d 100644
@@ -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- renamed from arch/arm/mach-s5pv210/include/mach/map.h +0 -0

s5pv210/include/mach/map.h
index 0982443..8f887c4 100644

arch/arm/mach-s5pv210/include/mach/map.h line 110

Quoted 4 lines
arch/arm/mach-s5pv210/include/mach/map.h +1 -0
@@ -107,6 +107,9 @@
 #define S5PV210_PA_DMC0		(0xF0000000)
 #define S5PV210_PA_DMC1		(0xF1400000)
 
+/* MFC */

No need useless comment.

Quoted 35 lines
arch/arm/mach-s5pv210/include/mach/map.h +3 -0
+#define S5PV210_PA_MFC		(0xF1700000)
+
 /* 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
index 9755df9..c7a048e 100644
@@ -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 +0 -0
index df65cb7..ed0f33d 100644

arch/arm/plat-s5p/Makefile obj-$(CONFIG_PM) += pm.o · line 26

Quoted 4 lines
arch/arm/plat-s5p/Makefile +1 -0
@@ -23,6 +23,7 @@ obj-$(CONFIG_PM)		+= pm.o
 obj-$(CONFIG_PM)		+= irq-pm.o
 
 # devices
+obj-$(CONFIG_S5P_DEV_MFC)	+= dev-mfc5.o

Do we really need to distinguish mfc version in file name? So why did you use just CONFIG_S5P_DEV_MFC as config name?

I mean don't use mixed name in there.

+obj-$(CONFIG_S5P_DEV_MFC5) += dev-mfc5.o

Or

+obj-$(CONFIG_S5P_DEV_MFC) += dev-mfc.o

I prefer the latter...because no need to separate the hardware version in platform data now.

arch/arm/plat-s5p/dev-mfc5.c line 3

Quoted 12 lines
arch/arm/plat-s5p/Makefile +0 -0
 obj-$(CONFIG_S5P_DEV_FIMC0)	+= dev-fimc0.o
 obj-$(CONFIG_S5P_DEV_FIMC1)	+= dev-fimc1.o
arch/arm/plat-s5p/dev-mfc5.c new file +3 -0
new file mode 100644
index 0000000..c06ea97
@@ -0,0 +1,37 @@
+/* Base S3C64XX mfc resource and device definitions */
+
+

Where is the GPL license?
This is very important...

arch/arm/plat-s5p/dev-mfc5.c line 10

Quoted 7 lines
arch/arm/plat-s5p/dev-mfc5.c new file +7 -0
+#include <linux/kernel.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/ioport.h>
+
+#include <mach/map.h>
+#include <plat/map-base.h>

Do we _really_ need <plat/map-base.h> inclusion? NO.

arch/arm/plat-s5p/dev-mfc5.c line 14

Quoted 4 lines
arch/arm/plat-s5p/dev-mfc5.c new file +4 -0
+#include <plat/devs.h>
+#include <plat/irqs.h>
+
+/* MFC controller */

No need above comment.

Quoted 13 lines
arch/arm/plat-s5p/dev-mfc5.c new file +13 -0
+static struct resource s5p_mfc_resource[] = {
+	[0] = {
+		.start  = S5P_PA_MFC,
+		.end    = S5P_PA_MFC + SZ_64K - 1,
+		.flags  = IORESOURCE_MEM,
+	},
+	[1] = {
+		.start  = IRQ_MFC,
+		.end    = IRQ_MFC,
+		.flags  = IORESOURCE_IRQ,
+	}
+};
+

arch/arm/plat-s5p/dev-mfc5.c line 37

Quoted 10 lines
arch/arm/plat-s5p/dev-mfc5.c new file +10 -0
+struct platform_device s5p_device_mfc5 = {
+	.name          = "s5p-mfc5",
+	.id            = -1,
+	.num_resources = ARRAY_SIZE(s5p_mfc_resource),
+	.resource      = s5p_mfc_resource,
+};
+
+EXPORT_SYMBOL(s5p_device_mfc5);
+
+

No need useless 2 empty lines here.

Quoted 6 lines
arch/arm/plat- renamed from arch/arm/plat-samsung/include/plat/devs.h +0 -0

samsung/include/plat/devs.h
index 628b331..fc169da 100644

arch/arm/plat-samsung/include/plat/devs.h extern struct platform_device s5p_device_fimc2;

Quoted 9 lines
arch/arm/plat-samsung/include/plat/devs.h +2 -1
@@ -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_mfc5;
+
 /* s3c2440 specific devices */
 
 #ifdef CONFIG_CPU_S3C2440
--

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.

#7 lore raw

RE: [RFC/PATCH v4 2/4] MFC: Add MFC 5.1 driver to plat-s5p

Hi,

Quoted 5 lines

From: Kukjin Kim [mailto:[email protected]]

Quoted 1 line · Kamil Debski

Would be better if you could keep the subject style...

Ok, I'll make the comment more consistent.

(snip)

Quoted 10 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/arch/arm/mach-

Quoted 8 lines

s5pv210/include/mach/map.h
index 0982443..8f887c4 100644

arch/arm/mach-s5pv210/include/mach/map.h +0 -0
@@ -107,6 +107,9 @@
 #define S5PV210_PA_DMC0		(0xF0000000)
 #define S5PV210_PA_DMC1		(0xF1400000)
 
Quoted 3 lines

arch/arm/mach-s5pv210/include/mach/map.h line 110

Quoted 1 line
arch/arm/mach-s5pv210/include/mach/map.h +1 -0
+/* MFC */

No need useless comment.

Just above the place, where I have added MFC, there are defines for AC97, PCM, I2S etc. and all of them have such comment before ( /* AC97 */ for AC97 codec). As such I wanted to keep the style. I agree that it is not necessary, but removing it could make the file less consistent. Are you sure you want me to remove it?

Quoted 38 lines
Quoted 38 lines
arch/arm/mach-s5pv210/include/mach/map.h +3 -0
+#define S5PV210_PA_MFC		(0xF1700000)
+
 /* 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
index 9755df9..c7a048e 100644
@@ -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 +0 -0
index df65cb7..ed0f33d 100644
@@ -23,6 +23,7 @@ obj-$(CONFIG_PM)		+= pm.o
 obj-$(CONFIG_PM)		+= irq-pm.o
 
Quoted 7 lines

arch/arm/plat-s5p/Makefile obj-$(CONFIG_PM) += pm.o · line 26

Quoted 2 lines
arch/arm/plat-s5p/Makefile +1 -0
 # devices
+obj-$(CONFIG_S5P_DEV_MFC)	+= dev-mfc5.o

Do we really need to distinguish mfc version in file name? So why did you use just CONFIG_S5P_DEV_MFC as config name?

I mean don't use mixed name in there.

Right, I think removing the version number is ok. Another way would be adding
"v5" everywhere. But I don't think it is necessary.

Quoted 9 lines

+obj-$(CONFIG_S5P_DEV_MFC5) += dev-mfc5.o

Or

+obj-$(CONFIG_S5P_DEV_MFC) += dev-mfc.o

I prefer the latter...because no need to separate the hardware version in
platform data now.

Ok.

Quoted 5 lines

arch/arm/plat-s5p/dev-

Quoted 4 lines
arch/arm/plat-s5p/Makefile +0 -0
 obj-$(CONFIG_S5P_DEV_FIMC0)	+= dev-fimc0.o
 obj-$(CONFIG_S5P_DEV_FIMC1)	+= dev-fimc1.o
arch/arm/plat-s5p/dev- renamed from arch/arm/plat-s5p/dev-mfc5.c +0 -0

mfc5.c

Quoted 11 lines

arch/arm/plat-s5p/dev-mfc5.c line 3

Quoted 8 lines

new file mode 100644
index 0000000..c06ea97

arch/arm/plat-s5p/dev-mfc5.c new file +3 -0
@@ -0,0 +1,37 @@
+/* Base S3C64XX mfc resource and device definitions */
+
+

Where is the GPL license?
This is very important...

The file lacks a proper comment altogether. Thanks for pointing this out, indeed it is important.

Quoted 10 lines

arch/arm/plat-s5p/dev-mfc5.c line 10

Quoted 7 lines
arch/arm/plat-s5p/dev-mfc5.c new file +7 -0
+#include <linux/kernel.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/ioport.h>
+
+#include <mach/map.h>
+#include <plat/map-base.h>

Do we _really_ need <plat/map-base.h> inclusion?
NO.

Right.

Quoted 7 lines

arch/arm/plat-s5p/dev-mfc5.c line 14

Quoted 5 lines
arch/arm/plat-s5p/dev-mfc5.c new file +4 -0
+#include <plat/devs.h>
+#include <plat/irqs.h>
+
+/* MFC controller */

No need above comment.

Ok.

Quoted 17 lines
Quoted 17 lines
arch/arm/plat-s5p/dev-mfc5.c new file +17 -0
+static struct resource s5p_mfc_resource[] = {
+	[0] = {
+		.start  = S5P_PA_MFC,
+		.end    = S5P_PA_MFC + SZ_64K - 1,
+		.flags  = IORESOURCE_MEM,
+	},
+	[1] = {
+		.start  = IRQ_MFC,
+		.end    = IRQ_MFC,
+		.flags  = IORESOURCE_IRQ,
+	}
+};
+
+struct platform_device s5p_device_mfc5 = {
+	.name          = "s5p-mfc5",
+	.id            = -1,
+	.num_resources = ARRAY_SIZE(s5p_mfc_resource),
Quoted 8 lines

arch/arm/plat-s5p/dev-mfc5.c line 37

Quoted 6 lines
arch/arm/plat-s5p/dev-mfc5.c new file +6 -0
+	.resource      = s5p_mfc_resource,
+};
+
+EXPORT_SYMBOL(s5p_device_mfc5);
+
+

No need useless 2 empty lines here.

Ok.

(snip)

Thank you for your comments.

Best regards,

Signature · 3 lines
Kamil Debski
Linux Platform Group
Samsung Poland R&D Center
#8 lore raw

RE: [RFC/PATCH v4 2/4] MFC: Add MFC 5.1 driver to plat-s5p

In reply to Kamil Debski
Quoted 8 lines · Kamil Debski

Add platform support for Multi Format Codec 5.1 is a module available on S5PC110 and S5PC210 Samsung SoCs. Hardware is capable of handling a range of video codecs and this driver provides V4L2 interface for video decoding.

(snip)

Quoted 1 line

+struct platform_device s5p_device_mfc5 = {

In this case, just "s5p_device_mfc" is better because basically used last number as channel, for example, fimc0 means fimc channel 0.

arch/arm/plat-s5p/dev-mfc5.c line 35

Quoted 7 lines
arch/arm/plat-s5p/dev-mfc5.c new file +7 -0
+	.name          = "s5p-mfc5",
+	.id            = -1,
+	.num_resources = ARRAY_SIZE(s5p_mfc_resource),
+	.resource      = s5p_mfc_resource,
+};
+
+EXPORT_SYMBOL(s5p_device_mfc5);

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.

#9 lore raw

PATCH v4 3/4 MFC: Added MFC 5.1 V4L2 driver

In reply to Kamil Debski

Multi Format Codec 5.1 is a module available on S5PC110 and S5PC210 Samsung SoCs. Hardware 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        | 2031 ++++++++++++++++++++++++++
 drivers/media/video/s5p-mfc/s5p_mfc_common.h |  222 +++
 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    |  870 +++++++++++
 drivers/media/video/s5p-mfc/s5p_mfc_opr.h    |  131 ++
 13 files changed, 3982 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
index 5cddbad..ab2d754 100644
@@ -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
index 90861eb..ee51c44 100644
@@ -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
new file mode 100644
index 0000000..69b6294
@@ -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 +2031 -0

2,031 lines not on this page · raw message

drivers/media/video/s5p-mfc/s5p_mfc_common.h new file +222 -0

222 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
new file mode 100644
index 0000000..8c531b6
@@ -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

43 lines not on this page · raw message

drivers/media/video/s5p-mfc/s5p_mfc_opr.c new file +870 -0

9 lines not on this page · raw message

drivers/media/video/s5p-mfc/s5p_mfc_opr.h new file +131 -0

131 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.

#10 lore raw

PATCH v4 4/4 s5pv210: Enable MFC on Goni

In reply to Kamil Debski

Multi Format Codec 5.1 is a module available on S5PC110 and S5PC210 Samsung SoCs. Hardware is capable of handling a range of video codecs.

---
 arch/arm/mach-s5pv210/Kconfig     |    1 +
 arch/arm/mach-s5pv210/mach-goni.c |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/mach-s5pv210/Kconfig +1 -0
index c45a1b7..43f408d 100644
@@ -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 +1 -0
index 8d19ead..50f10b9 100644
@@ -810,6 +810,7 @@ static struct platform_device *goni_devices[] __initdata = {
 	&goni_i2c_gpio5,
 	&mmc2_fixed_voltage,
 	&goni_device_gpiokeys,
+	&s5p_device_mfc5,
 	&s5p_device_fimc0,
 	&s5p_device_fimc1,
 	&s5p_device_fimc2,
Signature · 1 line
1.6.3.3
#11 lore raw
In reply to Kamil Debski
Quoted 6 lines · Kamil Debski

Hello,

Last week v3 of this driver has been posted. Since then the driver was changed
to use the newest videobuf2 version - v6. Two very long functions have

been

Quoted 205 lines

split to make the code more readible. Minor changes include tidying the comments and replacing remaining magic numbers with defines.

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 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:

Kamil Debski (4):
Changes in include/linux/videodev2.h for MFC
MFC: Add MFC 5.1 driver to plat-s5p, mach-s5pv210 and mach-s5pv210
MFC: Added 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               |    1 +
 arch/arm/plat-s5p/Kconfig                       |    5 +
 arch/arm/plat-s5p/Makefile                      |    1 +
 arch/arm/plat-s5p/dev-mfc5.c                    |   37 +
 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           | 2031
+++++++++++++++++++++++
 drivers/media/video/s5p-mfc/s5p_mfc_common.h    |  222 +++
 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       |  870 ++++++++++
 drivers/media/video/s5p-mfc/s5p_mfc_opr.h       |  131 ++
 include/linux/videodev2.h                       |   48 +
 25 files changed, 4136 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/plat-s5p/dev-mfc5.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
Quoted 9 lines
 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

Hi Kamil,

I think, should be added my e-mail in Cc...

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.

#12 lore raw
Quoted 223 lines · Kukjin Kim
Quoted 6 lines · Kamil Debski

Hello,

Last week v3 of this driver has been posted. Since then the driver was changed
to use the newest videobuf2 version - v6. Two very long functions have

been

Quoted 201 lines

split to make the code more readible. Minor changes include tidying the comments and replacing remaining magic numbers with defines.

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 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:

Kamil Debski (4):
  Changes in include/linux/videodev2.h for MFC
  MFC: Add MFC 5.1 driver to plat-s5p, mach-s5pv210 and mach-s5pv210
  MFC: Added 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               |    1 + arch/arm/plat-s5p/Kconfig                       |    5 + arch/arm/plat-s5p/Makefile                      |    1 + arch/arm/plat-s5p/dev-mfc5.c                    |   37 + 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           | 2031
+++++++++++++++++++++++

 drivers/media/video/s5p-mfc/s5p_mfc_common.h    |  222 +++
 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       |  870 ++++++++++ drivers/media/video/s5p-mfc/s5p_mfc_opr.h       |  131 ++ include/linux/videodev2.h                       |   48 +

 25 files changed, 4136 insertions(+), 1 deletions(-)
Quoted 13 lines

 create mode 100644 arch/arm/plat-s5p/dev-mfc5.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

Quoted 3 lines

Hi Kamil,

I think, should be added my e-mail in Cc...

No need to cc all, only machine specific only.
and I hope minimal modification at machine specific and move to media if possible.

Thank you,
Kyungmin Park

#13 lore raw
Quoted 2 lines · Kyungmin Park

On Fri, Dec 10, 2010 at 11:32 AM, Kukjin Kim <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 3 lines · Kamil Debski

Hello,

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

Last week v3 of this driver has been posted. Since then the driver was changed
to use the newest videobuf2 version - v6. Two very long functions have

been

Quoted 4 lines

split to make the code more readible. Minor changes include tidying the comments and replacing remaining magic numbers with defines.

I would be grateful for your comments. Original cover letter ant

detailed

Quoted 28 lines
Quoted 28 lines
Quoted 28 lines

change
log has been attached below.

Best regards,
Kamil Debski

* Changelog:

==================
 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

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

more
major API changes. Buffer initialization has been moved from

buf_prepare

Quoted 1 line
Quoted 1 line
Quoted 1 line

callback to buf_init to simplify the process. Locking mechanism has

been

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

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,

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

instead of using CMA functions directly.

==================
 Changes since v1
==================

1) Cleanup accoridng to Peter Oh suggestions on the mailing list

(Thanks).

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

* Original cover letter:

==============
 Introduction
==============

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

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

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

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.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

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

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

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

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines

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.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

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

Quoted 1 line
Quoted 1 line
Quoted 1 line

call. The application can request more output buffer if necessary.

After

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

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

Quoted 95 lines
Quoted 95 lines
Quoted 94 lines

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:

Kamil Debski (4):
  Changes in include/linux/videodev2.h for MFC
  MFC: Add MFC 5.1 driver to plat-s5p, mach-s5pv210 and mach-s5pv210
  MFC: Added 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               |    1 + arch/arm/plat-s5p/Kconfig                       |    5 + arch/arm/plat-s5p/Makefile                      |    1 + arch/arm/plat-s5p/dev-mfc5.c                    |   37 + 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           | 2031
+++++++++++++++++++++++

 drivers/media/video/s5p-mfc/s5p_mfc_common.h    |  222 +++
 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       |  870 ++++++++++ drivers/media/video/s5p-mfc/s5p_mfc_opr.h       |  131 ++ include/linux/videodev2.h                       |   48 +

 25 files changed, 4136 insertions(+), 1 deletions(-)

 create mode 100644 arch/arm/plat-s5p/dev-mfc5.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

Quoted 8 lines
Quoted 3 lines

Hi Kamil,

I think, should be added my e-mail in Cc...

No need to cc all, only machine specific only.
and I hope minimal modification at machine specific and move to media if possible.

Should be reviewed proper maintainer even though it is small changes. Really, I don't want to argue to you about my maintaining ship...

And I have a wondering about your sign.
Did you really check this patch before Kamil's submitting? Unfortunately, I don't think so...

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.

#14 lore raw
Quoted 242 lines · Kukjin Kim
Quoted 2 lines · Kyungmin Park

On Fri, Dec 10, 2010 at 11:32 AM, Kukjin Kim <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 3 lines · Kamil Debski

Hello,

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

Last week v3 of this driver has been posted. Since then the driver was changed
to use the newest videobuf2 version - v6. Two very long functions have

been

Quoted 4 lines

split to make the code more readible. Minor changes include tidying the comments and replacing remaining magic numbers with defines.

I would be grateful for your comments. Original cover letter ant

detailed

Quoted 28 lines
Quoted 28 lines
Quoted 28 lines

change
log has been attached below.

Best regards,
Kamil Debski

* Changelog:

==================
 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

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

more
major API changes. Buffer initialization has been moved from

buf_prepare

Quoted 1 line
Quoted 1 line
Quoted 1 line

callback to buf_init to simplify the process. Locking mechanism has

been

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

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,

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

instead of using CMA functions directly.

==================
 Changes since v1
==================

1) Cleanup accoridng to Peter Oh suggestions on the mailing list

(Thanks).

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

* Original cover letter:

==============
 Introduction
==============

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

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

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

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.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

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

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

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

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines

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.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

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

Quoted 1 line
Quoted 1 line
Quoted 1 line

call. The application can request more output buffer if necessary.

After

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

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

Quoted 97 lines
Quoted 97 lines
Quoted 81 lines

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:

Kamil Debski (4):
  Changes in include/linux/videodev2.h for MFC
  MFC: Add MFC 5.1 driver to plat-s5p, mach-s5pv210 and mach-s5pv210
  MFC: Added 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               |    1 + arch/arm/plat-s5p/Kconfig                       |    5 + arch/arm/plat-s5p/Makefile                      |    1 + arch/arm/plat-s5p/dev-mfc5.c                    |   37 + 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           | 2031
+++++++++++++++++++++++

 drivers/media/video/s5p-mfc/s5p_mfc_common.h    |  222 +++
 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       |  870 ++++++++++ drivers/media/video/s5p-mfc/s5p_mfc_opr.h       |  131 ++ include/linux/videodev2.h                       |   48 +

 25 files changed, 4136 insertions(+), 1 deletions(-)
Quoted 13 lines

 create mode 100644 arch/arm/plat-s5p/dev-mfc5.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

Hi Kamil,

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I think, should be added my e-mail in Cc...

No need to cc all, only machine specific only.
and I hope minimal modification at machine specific and move to media if possible.

Should be reviewed proper maintainer even though it is small changes. Really, I don't want to argue to you about my maintaining ship...

Each preference is different and you and me are different unfortunately.

Quoted 4 lines

And I have a wondering about your sign.
Did you really check this patch before Kamil's submitting? Unfortunately, I don't think so...

I don't care minor issues I'm more focus on the logic.

What's the matter mfc or mfc5 and so on? some time later these names are changed if new mfc are introduced.
Currently we're use the mfc version 5.

Do you have any rules on samsung soc variable, module naming? I think it depends on each case by case.

Thank you,
Kyungmin Park

#15 lore raw
Quoted 6 lines · Kyungmin Park
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

Hi Kamil,

I think, should be added my e-mail in Cc...

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

No need to cc all, only machine specific only.
and I hope minimal modification at machine specific and move to media if possible.

Should be reviewed proper maintainer even though it is small changes. Really, I don't want to argue to you about my maintaining ship...

Each preference is different and you and me are different unfortunately.

Hmm...What's different? If you want to submit something, should be sent to proper maintainer.
If two maintainers, you need both maintainers' agreement or at least ack to merge it.

Quoted 7 lines
Quoted 4 lines

And I have a wondering about your sign.
Did you really check this patch before Kamil's submitting? Unfortunately, I don't think so...

I don't care minor issues I'm more focus on the logic.

Maybe you didn't check/review Kamil's patch before submitting. So your sign has a problem. Please see "Documentation/SubmittingPatches".

I don't think that something like missing GPL license is minor issue. I mean if you want to add your sign, you had to check it before posting.

And it doesn't matter it's small or big.

Quoted 4 lines

What's the matter mfc or mfc5 and so on? some time later these names are changed if new mfc are introduced.
Currently we're use the mfc version 5.

How about fimc0 or fimc1...it is used as hardware version? No...it means channel. Why do you use mixed rule?

As I said, if separate hardware version required, we can do it later.

Quoted 3 lines

Do you have any rules on samsung soc variable, module naming? I think it depends on each case by case.

Already mentioned.

...

I'd like to stop this here, we already talked about similar issues many times.

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.