Skip to contentSkip to conversation

Multi Format Codec 5.1 driver for s5pv310 SoC

PATCH Superseded Kamil Debski 5 participants 13 messages Mar 4, 2011 – Mar 31, 2011

Subsystems (5)

v7 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v7 cover Multi Format Codec 5.1 driver for s5pv310 SoC

Hi,

This is the seventh version of the MFC 5.1 driver. It is still a work in progress. This version currently supports decoding only, but encoding is heavily developed. For nearly two months new features were added and fixes and suggestions were implemented.

The main purpose for posting this patch is to show an example driver that uses the new IOMMU vb2 allocator. In addition this is the first try to create a V4L2 codec driver that I know of. I hope to discuss issues related to this type of hardware on the upcoming brainstorming session in Warsaw.

Major new features include:
- proper handling for stream seeking (stream off + stream on and resume from another point of the stream).
- support for resolution change in the stream
- power domain handling
- clock gating
- support for IOMMU allocator
- setting buffer flags according to decoded frame type:
V4L2_BUF_FLAG_(KEY|P|B)FRAME
- proper display delay handling for H264

Things that still need to be done:
- move to the control framework
- rebase onto Exynos4 platform name change

* Stream seeking scenario is as follows:

1. Stream off on OUTPUT
2. Stream off on CAPTURE
3. Queue at least one new src buffer on OUTPUT (after stream off they all have been dequeued and at least one buffer has to be queued to successfully do a stream on)
4. Queue dst buffers on CAPTURE (after stream off they all have been dequeued)
5. Stream on on CAPTURE queue
6. Stream on on OUTPUT queue

* Resolution change scenario:

1. Stream off on CAPTURE
2. Unmap the destination buffers
Note: To successfully unmap the buffer they cannot be used by any other hardware, such as FIMC. Thus it necessary to shutdown FIMC - either close, or streamoff and reqbufs(0).
3. Call Reqbufs (0) on CAPTURE
4. Same as after parsing header
a) Run G_FMT on CAPTURE
b) Run G_CROP on CAPTURE
c) Get the minimum number of buffers (by reading the V4L2_CID_CODEC_REQ_NUM_BUFS control)
5. Init CAPTURE stream
a) Run Reqbufs with appropriate number of buffers (minimum + extra)
b) Run Querybuf and Mmap on each buffer
c) Run Q_BUF on the new buffers
6. Stream on on CAPTURE
7. Initialize FIMC

Note: application is notified about resolution change in the same way as the notification that all decoded buffers have been read. The value of bytesused in the capture buffer is set to 0. If the application has sent last encoded stream frame then it is waiting for last decoded frame. If the application receives a frame with bytesused set to 0 with no error set in the middle of a stream then it should treat is as the notification of resolution change.

Best regards,
Kamil

* Changelog:

==================
Changes since v6
==================

1) Stream seeking handling
- done by running stream off and then stream on from another point of the stream
2) Support for streams during which the resolution is changed
- done by calling stream off, reallocating the buffers and stream on again to resume
3) Power domain handling
4) Clock gating hw related operations
- This has introduced a large reduction in power use
5) Support for IOMMU allocator
- Using IOMMU as the memory allocator removes the cache problem and the need for reserving continuous memory at system boot
6) Flags of v4l2_buffer are set accrodingly to the returned buffer frame type V4L2_BUF_FLAG_(KEY|P|B)FRAME
7) Fixed display delay handling of H264. Now dealy of 0 frames is possible, although it may cause that the frames are returned out of order.
8) Minor changes
- global s5p_mfc_dev variable has been removed
- improved Packed PB handling
- fixed error handling - separate for decoding and display frames
- some cosmetic changes to simplify the code and make it more readable

==================
Changes since v5
==================

1) Changes suggested by Hans Verkuil:
- small change in videodev2.h - corrected control offsets
- made the code more readable by simplifying if statements and using temporary pointers
- mfc_mutex is now included in s5p_mfc_dev structure
- after discussion with Peter Oh modification of fourcc defintions (replaced DX52 and DX53 with DX50)

2) Changes suggested by JongHun Han:
- comsmetic changed of defines in regs-mfc5.h
- in buffers that have no width adn height, such as the buffer for compressed stream, those values are set to 0 instead of 1
- remove redundant pointer to MFC registers
- change name of the union in s5p_mfc_buf from paddr to cookie
- removed global variable (struct s5p_mfc_dev *dev) and moved to use video_drvdata

3) Other changes:
- added check for values returned after parsing header - in rare circumstances MFC hw returned 0x0 as image size and this could cause problems

==================
Changes since v4
==================

1) Changes suggested by Kukjin Kim from:
- removed comment arch/arm/mach-s5pv210/include/mach/map.h
- changed device name to s5p-mfc (removed "5", MFC version number) also removed the version number from the name of MFC device file
- added GPL license to arch/arm/plat-s5p/dev-mfc.c
- removed unused include file from dev-mfc.c and unnecessary comments

2) Cache handling improvement:
- changed cache handling to use dma_map_single and dma_unmap_single

==================
Changes since v3
==================

1) Update to the v6 videobuf2 API (here thanks go to Marek Szyprowski)
- s5p_mfc_buf_negotiate and s5p_mfc_buf_setup_plane functions have been merged
- queue initialization has been adapted to the new API
- use of the allocator memops has been changed, now there are single memops for all the allocator contexts

2) Split of the s5p_mfc_try_run and s5p_mfc_handle_frame_int functions
- parts of the s5p_mfc_try_run function have been moved to separate functions (s5p_mfc_get_new_ctx, s5p_mfc_run_dec_last_frames, s5p_mfc_run_dec_frame, s5p_mfc_run_get_inst_no, s5p_mfc_run_return_inst s5p_mfc_run_init_dec,s5p_mfc_run_init_dec_buffers)
- s5p_mfc_handle_frame_int has been split to the following functions:
s5p_mfc_handle_frame_all_extracted, s5p_mfc_handle_frame_new and s5p_mfc_handle_frame to handle different cases

3) Remove remaining magic numbers and tidy up comments

==================
Changes since v2
==================

1) Update to newest videobuf2 API
This is the major change from v2. The videobuf2 API will hopefully have no more major API changes. Buffer initialization has been moved from buf_prepare callback to buf_init to simplify the process. Locking mechanism has been modified to the requirements of new videobuf2 version.
2) Code cleanup
Removed more magic contants and replaced them with appropriate defines. Changed code to use unlocked_ioctl instead of ioctl in v4l2 file ops.
3) Allocators
All internal buffer allocations are done using the selected vb2 allocator, instead of using CMA functions directly.

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

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

* Original cover letter:

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

The purpose of this RFC is to discuss the driver for a hw video codec embedded in the new Samusng's SoCs. Multi Format Codec 5.0 is able to handle video decoding of in a range of formats.

So far no hardware codec was supported in V4L2 and this would be the first one. I guess there are more similar device that would benefit from a V4L2 unified interface. I suggest a separate control class for codec devices - V4L2_CTRL_CLASS_CODEC.

Internally the driver uses videobuf2 framework and CMA memory allocator. I am aware that those have not yet been merged, but I wanted to start discussion about the driver earlier so it could be merged sooner. The driver posted here is the initial version, so I suppose it will require more work.

==================
Device interface
==================

The driver principle is based on the idea of memory-to-memory devices:
it provides a single video node and each opened file handle gets its own private context with separate buffer queues. Each context consist of 2 buffer queues: OUTPUT (for source buffers, i.e. encoded video frames) and CAPTURE (for destination buffers, i.e. decoded raw video frames). The process of decoding video data from stream is a bit more complicated than typical memory-to-memory processing, that's why the m2m framework is not directly used (it is too limited for this case). The main reason for this is the fact that the CAPTURE buffers can be dequeued in a different order than they queued. The hw block decides which buffer has been completely processed. This is due to the structure of most compressed video streams - use of B frames causes that decoding and display order may be different.

==============================
Decoding initialization path
==============================

First the OUTPUT queue is initialized. With S_FMT the application chooses which video format to decode and what size should be the input buffer. Fourcc values have been defined for different codecs e.g. V4L2_PIX_FMT_H264 for h264. Then the OUTPUT buffers are requested and mmaped. The stream header frame is loaded into the first buffer, queued and streaming is enabled. At this point the hardware is able to start processing the stream header and afterwards it will have information about the video dimensions and the size of the buffers with raw video data.

The next step is setting up the CAPTURE queue and buffers. The width, height, buffer size and minimum number of buffers can be read with G_FMT call. The application can request more output buffer if necessary. After requesting and mmaping buffers the device is ready to decode video stream.

The stream frames (ES frames) are written to the OUTPUT buffers, and decoded video frames can be read from the CAPTURE buffers. When no more source frames are present a single buffer with bytesused set to 0 should be queued. This will inform the driver that processing should be finished and it can dequeue all video frames that are still left. The number of such frames is dependent on the stream and its internal structure (how many frames had to be kept as reference frames for decoding, etc).

===============
Usage summary
===============

This is a step by step summary of the video decoding (from user application point of view, with 2 treads and blocking api):

01. S_FMT(OUTPUT, V4L2_PIX_FMT_H264, ...)
02. REQ_BUFS(OUTPUT, n)
03. for i=1..n MMAP(OUTPUT, i)
04. put stream header to buffer #1
05. QBUF(OUTPUT, #1)
06. STREAM_ON(OUTPUT)
07. G_FMT(CAPTURE)
08. REQ_BUFS(CAPTURE, m)
09. for j=1..m MMAP(CAPTURE, j)
10. for j=1..m QBUF(CAPTURE, #j)
11. STREAM_ON(CAPTURE)

display thread:
12. DQBUF(CAPTURE) -> got decoded video data in buffer #j
13. display buffer #j
14. QBUF(CAPTURE, #j)
15. goto 12

parser thread:
16. put next ES frame to buffer #i
17. QBUF(OUTPUT, #i)
18. DQBUF(OUTPUT) -> get next empty buffer #i 19. goto 16

...

Similar usage sequence can be achieved with single threaded application and non-blocking api with poll() call.

Branch with MFC, CMA and videobuf2 will be soon available at
http://git.infradead.org/users/kmpark/linux-2.6-samsung/shortlog/refs/heads/vb2-mfc-fimc
This tree is based on 2.6.37 rc4.

Please have a look at the code and the idea of how to introduce codec devices to V4L2. Comments will be very much appreciated.

Patch summary:

Kamil Debski (5):
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
s5pv310: Enable MFC on C210_universal
v4l: Documentation for the codec interface

 Documentation/DocBook/v4l/dev-codec.xml         |  169 ++-
 arch/arm/mach-s5pv310/Kconfig                   |    1 +
 arch/arm/mach-s5pv310/clock.c                   |   28 +-
 arch/arm/mach-s5pv310/include/mach/map.h        |    2 +
 arch/arm/mach-s5pv310/include/mach/regs-clock.h |    3 +
 arch/arm/mach-s5pv310/mach-universal_c210.c     |    8 +
 arch/arm/plat-s5p/Kconfig                       |    5 +
 arch/arm/plat-s5p/Makefile                      |    2 +-
 arch/arm/plat-s5p/dev-mfc.c                     |   49 +
 arch/arm/plat-samsung/include/plat/devs.h       |    1 +
 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         |  346 ++++
 drivers/media/video/s5p-mfc/s5p_mfc.c           | 2253 +++++++++++++++++++++++
 drivers/media/video/s5p-mfc/s5p_mfc_common.h    |  240 +++
 drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h     |  182 ++
 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       |  913 +++++++++
 drivers/media/video/s5p-mfc/s5p_mfc_opr.h       |  142 ++
 include/linux/videodev2.h                       |   39 +
 24 files changed, 4587 insertions(+), 16 deletions(-)
 create mode 100644 arch/arm/plat-s5p/dev-mfc.c
 create mode 100644 drivers/media/video/s5p-mfc/Makefile
 create mode 100644 drivers/media/video/s5p-mfc/regs-mfc5.h
 create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc.c
 create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_common.h
 create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h
 create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_debug.h
 create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_intr.c
 create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_intr.h
 create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_memory.h
 create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_opr.c
 create mode 100644 drivers/media/video/s5p-mfc/s5p_mfc_opr.h
#1 lore raw

PATCH v7 1/5 Changes in include/linux/videodev2.h for MFC 5.1

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

---
 include/linux/videodev2.h |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)
include/linux/videodev2.h +39 -0
index a94c4d5..a48a42e 100644
@@ -369,6 +369,19 @@ 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 */
@@ -1016,6 +1029,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)
@@ -1349,6 +1363,31 @@ 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 + 1)
+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 + 2)
+#define V4L2_CID_CODEC_DISPLAY_DELAY		(V4L2_CID_CODEC_BASE + 3)
+#define V4L2_CID_CODEC_DISPLAY_DELAY_ENABLE	(V4L2_CID_CODEC_BASE + 4)
+#define V4L2_CID_CODEC_MIN_REQ_BUFS_OUT		(V4L2_CID_CODEC_BASE + 5)
+#define V4L2_CID_CODEC_MIN_REQ_BUFS_CAP		(V4L2_CID_CODEC_BASE + 6)
+#define V4L2_CID_CODEC_SLICE_INTERFACE		(V4L2_CID_CODEC_BASE + 7)
+#define V4L2_CID_CODEC_PACKED_PB		(V4L2_CID_CODEC_BASE + 8)
+
 /*  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 v7 1/5] Changes in include/linux/videodev2.h for MFC 5.1

Quoted 20 lines · On Friday 04 March 2011 12:26:18 Kamil Debski wrote:

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

---
 include/linux/videodev2.h |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)
include/linux/videodev2.h +3 -0
index a94c4d5..a48a42e 100644
@@ -369,6 +369,19 @@ 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  */

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

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

Hans, you mentioned some time ago that you were against ading H.264 or MPEG4 fourccs, and that drivers should use the MPEG controls instead. Could you clarify your current position on this ?

Signature · 3 lines
Regards,

Laurent Pinchart
#3 lore raw

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

Hi,

Quoted 54 lines

-----Original Message-----
From: Laurent Pinchart [mailto:[email protected]]
Sent: 04 March 2011 17:39
To: Kamil Debski
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [RFC/PATCH v7 1/5] Changes in include/linux/videodev2.h for MFC 5.1

Quoted 7 lines · On Friday 04 March 2011 12:26:18 Kamil Debski wrote:

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

---
 include/linux/videodev2.h |   39

+++++++++++++++++++++++++++++++++++++++

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

Quoted 8 lines
 1 files changed, 39 insertions(+), 0 deletions(-)
include/linux/videodev2.h +0 -0
index a94c4d5..a48a42e 100644
@@ -369,6 +369,19 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_DV       v4l2_fourcc('d', 'v', 's', 'd') /*

1394 */

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

Quoted 1 line
include/linux/videodev2.h +0 -0
 #define V4L2_PIX_FMT_MPEG     v4l2_fourcc('M', 'P', 'E', 'G') /*

MPEG-1/2/4 */

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

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

H264 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_H263     v4l2_fourcc('H', '2', '6', '3') /*

H263 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_MPEG12   v4l2_fourcc('M', 'P', '1', '2') /*

MPEG-1/2 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_MPEG4    v4l2_fourcc('M', 'P', 'G', '4') /*

MPEG-4 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_DIVX     v4l2_fourcc('D', 'I', 'V', 'X') /*

DivX */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_DIVX3    v4l2_fourcc('D', 'I', 'V', '3') /*

DivX 3.11 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_DIVX4    v4l2_fourcc('D', 'I', 'V', '4') /*

DivX 4.12 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_DIVX500  v4l2_fourcc('D', 'X', '5', '2') /*

DivX 5.00 - 5.02 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_DIVX503  v4l2_fourcc('D', 'X', '5', '3') /*

DivX 5.03 - x */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_XVID     v4l2_fourcc('X', 'V', 'I', 'D') /*

Xvid */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_VC1      v4l2_fourcc('V', 'C', '1', 'A') /* VC-

1 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_VC1_RCV  v4l2_fourcc('V', 'C', '1', 'R') /* VC-
Quoted 8 lines

1 RCV */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+

Hans, you mentioned some time ago that you were against ading H.264 or MPEG4
fourccs, and that drivers should use the MPEG controls instead. Could you
clarify your current position on this ?

If I remember correct there was no clear conclusion on this. I hope we can discuss this
during the upcoming meeting.

Have you got an alternative suggestion to using fourccs?

The existing MPEG controls won't cover all the functions and parameters that are
used by video codecs. The controls that are in this patch are the ones related to
decoding, there is even more for encoding.

Yesterday I have been talking with Hans on the IRC channel about the control for
quantization parameters and he has suggested to use different for MPEG4, H263 and H264.
Personally I'd like to have a common one, as the QP meaning is the same in those 3
cases, the difference is the range of the value.
So I think that this still is a subject that could use more discussion as there are
a few ideas.

Best regards,

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

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

Hi, I commented as below.

Quoted 88 lines

-----Original Message-----
From: Kamil Debski [mailto:[email protected]]
Sent: Saturday, March 05, 2011 3:57 AM
To: 'Laurent Pinchart'
Cc: [email protected]; [email protected]; Marek Szyprowski; [email protected]; [email protected]; [email protected]
Subject: RE: [RFC/PATCH v7 1/5] Changes in include/linux/videodev2.h for MFC 5.1

Hi,

Quoted 54 lines

-----Original Message-----
From: Laurent Pinchart [mailto:[email protected]]
Sent: 04 March 2011 17:39
To: Kamil Debski
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [RFC/PATCH v7 1/5] Changes in include/linux/videodev2.h for MFC 5.1

Quoted 7 lines · On Friday 04 March 2011 12:26:18 Kamil Debski wrote:

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

---
 include/linux/videodev2.h |   39

+++++++++++++++++++++++++++++++++++++++

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

Quoted 8 lines
 1 files changed, 39 insertions(+), 0 deletions(-)
include/linux/videodev2.h +0 -0
index a94c4d5..a48a42e 100644
@@ -369,6 +369,19 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_DV       v4l2_fourcc('d', 'v', 's', 'd') /*

1394 */

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

Quoted 1 line
include/linux/videodev2.h +0 -0
 #define V4L2_PIX_FMT_MPEG     v4l2_fourcc('M', 'P', 'E', 'G') /*

MPEG-1/2/4 */

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

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

H264 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_H263     v4l2_fourcc('H', '2', '6', '3') /*

H263 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_MPEG12   v4l2_fourcc('M', 'P', '1', '2') /*

MPEG-1/2 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_MPEG4    v4l2_fourcc('M', 'P', 'G', '4') /*

MPEG-4 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_DIVX     v4l2_fourcc('D', 'I', 'V', 'X') /*

DivX */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_DIVX3    v4l2_fourcc('D', 'I', 'V', '3') /*

DivX 3.11 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_DIVX4    v4l2_fourcc('D', 'I', 'V', '4') /*

DivX 4.12 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_DIVX500  v4l2_fourcc('D', 'X', '5', '2') /*

DivX 5.00 - 5.02 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_DIVX503  v4l2_fourcc('D', 'X', '5', '3') /*

DivX 5.03 - x */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_XVID     v4l2_fourcc('X', 'V', 'I', 'D') /*

Xvid */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_VC1      v4l2_fourcc('V', 'C', '1', 'A') /* VC-

1 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_VC1_RCV  v4l2_fourcc('V', 'C', '1', 'R') /* VC-
Quoted 8 lines

1 RCV */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+

Hans, you mentioned some time ago that you were against ading H.264 or MPEG4
fourccs, and that drivers should use the MPEG controls instead. Could you
clarify your current position on this ?

If I remember correct there was no clear conclusion on this. I hope we can discuss this
during the upcoming meeting.

Have you got an alternative suggestion to using fourccs?

The existing MPEG controls won't cover all the functions and parameters that
are
used by video codecs. The controls that are in this patch are the ones related to
decoding, there is even more for encoding.

Quoted 11 lines

Yesterday I have been talking with Hans on the IRC channel about the control
for
quantization parameters and he has suggested to use different for MPEG4, H263 and H264.
Personally I'd like to have a common one, as the QP meaning is the same in those 3
cases, the difference is the range of the value.
So I think that this still is a subject that could use more discussion as there are
a few ideas.

According to the fource.org, and if fourcc definition here has been made from fourcc.org,
We need to have a discussion about new types that Kamil added not only h264 but divx_xxx.
QP might be a same topic. So let's discuss more at Poland meeting.

Quoted 7 lines

Best regards,

--
Kamil Debski
Linux Platform Group
Samsung Poland R&D Center

#5 lore raw

Re: [RFC/PATCH v7 1/5] Changes in include/linux/videodev2.h for MFC 5.1

In reply to Kamil Debski
Quoted 65 lines · On Friday, March 04, 2011 19:56:35 Kamil Debski wrote:

Hi,

Quoted 54 lines

-----Original Message-----
From: Laurent Pinchart [mailto:[email protected]]
Sent: 04 March 2011 17:39
To: Kamil Debski
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [RFC/PATCH v7 1/5] Changes in include/linux/videodev2.h for MFC 5.1

Quoted 7 lines · On Friday 04 March 2011 12:26:18 Kamil Debski wrote:

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

---
 include/linux/videodev2.h |   39

+++++++++++++++++++++++++++++++++++++++

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

Quoted 8 lines
 1 files changed, 39 insertions(+), 0 deletions(-)
include/linux/videodev2.h +0 -0
index a94c4d5..a48a42e 100644
@@ -369,6 +369,19 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_DV       v4l2_fourcc('d', 'v', 's', 'd') /*

1394 */

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

Quoted 1 line
include/linux/videodev2.h +0 -0
 #define V4L2_PIX_FMT_MPEG     v4l2_fourcc('M', 'P', 'E', 'G') /*

MPEG-1/2/4 */

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

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

H264 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_H263     v4l2_fourcc('H', '2', '6', '3') /*

H263 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_MPEG12   v4l2_fourcc('M', 'P', '1', '2') /*

MPEG-1/2 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_MPEG4    v4l2_fourcc('M', 'P', 'G', '4') /*

MPEG-4 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_DIVX     v4l2_fourcc('D', 'I', 'V', 'X') /*

DivX */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_DIVX3    v4l2_fourcc('D', 'I', 'V', '3') /*

DivX 3.11 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_DIVX4    v4l2_fourcc('D', 'I', 'V', '4') /*

DivX 4.12 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_DIVX500  v4l2_fourcc('D', 'X', '5', '2') /*

DivX 5.00 - 5.02 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_DIVX503  v4l2_fourcc('D', 'X', '5', '3') /*

DivX 5.03 - x */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_XVID     v4l2_fourcc('X', 'V', 'I', 'D') /*

Xvid */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_VC1      v4l2_fourcc('V', 'C', '1', 'A') /* VC-

1 */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+#define V4L2_PIX_FMT_VC1_RCV  v4l2_fourcc('V', 'C', '1', 'R') /* VC-
Quoted 8 lines

1 RCV */

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

Quoted 1 line
include/linux/videodev2.h +1 -0
+

Hans, you mentioned some time ago that you were against ading H.264 or MPEG4
fourccs, and that drivers should use the MPEG controls instead. Could you
clarify your current position on this ?

Quoted 3 lines

If I remember correct there was no clear conclusion on this. I hope we can discuss this
during the upcoming meeting.

Yes, we need to discuss this.

Quoted 8 lines

Have you got an alternative suggestion to using fourccs?

The existing MPEG controls won't cover all the functions and parameters that are
used by video codecs. The controls that are in this patch are the ones related to
decoding, there is even more for encoding.

Quoted 10 lines

Yesterday I have been talking with Hans on the IRC channel about the control for
quantization parameters and he has suggested to use different for MPEG4, H263 and H264.
Personally I'd like to have a common one, as the QP meaning is the same in those 3
cases, the difference is the range of the value.
So I think that this still is a subject that could use more discussion as there are
a few ideas.

When I made the MPEG API originally I did design it to be usable for other compression schemes as well. But we need to review that API in light of the current developments and see if it can be used unchanged, needs tweaking or perhaps should be abandoned altogether.

Regards,

Hans

Signature · 1 line
Hans Verkuil - video4linux developer - sponsored by Cisco
#6 lore raw

PATCH v7 2/5 MFC: Add MFC 5.1 driver to plat-s5p

In reply to Kamil Debski

This patch adds platform support for Multi Format Codec 5.1. MFC 5.1 is capable of handling a range of video codecs and this driver provides V4L2 interface for video decoding.

---
 arch/arm/mach-s5pv310/clock.c                   |   28 ++++++++++++-
 arch/arm/mach-s5pv310/include/mach/map.h        |    2 +
 arch/arm/mach-s5pv310/include/mach/regs-clock.h |    3 +
 arch/arm/plat-s5p/Kconfig                       |    5 ++
 arch/arm/plat-s5p/Makefile                      |    2 +-
 arch/arm/plat-s5p/dev-mfc.c                     |   49 +++++++++++++++++++++++
 arch/arm/plat-samsung/include/plat/devs.h       |    1 +
 7 files changed, 88 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/plat-s5p/dev-mfc.c
arch/arm/mach-s5pv310/clock.c +27 -1
index f142b8c..d28fa6f 100644
@@ -523,6 +523,11 @@ static struct clk init_clocks_off[] = {
 		.enable		= s5pv310_clk_ip_lcd1_ctrl,
 		.ctrlbit	= (1 << 0),
 	}, {
+		.name           = "mfc",
+		.id             = -1,
+		.enable         = s5pv310_clk_ip_mfc_ctrl,
+		.ctrlbit        = (1 << 0),
+	}, {
 		.name		= "hsmmc",
 		.id		= 0,
 		.parent		= &clk_aclk_133.clk,
@@ -734,6 +739,18 @@ static struct clksrc_sources clkset_group = {
 	.nr_sources	= ARRAY_SIZE(clkset_group_list),
 };
 
+static struct clk *clkset_group1_list[] = {
+	[0] = &clk_mout_mpll.clk,
+	[1] = &clk_sclk_apll.clk,
+	[2] = &clk_mout_epll.clk,
+	[3] = &clk_sclk_vpll.clk,
+};
+
+static struct clksrc_sources clkset_group1 = {
+	.sources        = clkset_group1_list,
+	.nr_sources     = ARRAY_SIZE(clkset_group1_list),
+};
+
 static struct clk *clkset_mout_g2d0_list[] = {
 	[0] = &clk_mout_mpll.clk,
 	[1] = &clk_sclk_apll.clk,
@@ -1076,7 +1093,16 @@ static struct clksrc_clk clksrcs[] = {
 			.ctrlbit	= (1 << 16),
 		},
 		.reg_div = { .reg = S5P_CLKDIV_FSYS3, .shift = 8, .size = 8 },
-	}
+	}, {
+		.clk            = {
+			.name           = "sclk_mfc",
+			.id             = -1,
+		},
+		.sources = &clkset_group1,
+		.reg_src = { .reg = S5P_CLKSRC_MFC, .shift = 8, .size = 1 },
+		.reg_div = { .reg = S5P_CLKDIV_MFC, .shift = 0, .size = 4 },
+	},
+
 };
 
 /* Clock initialization code */
arch/arm/mach-s5pv310/include/mach/map.h +2 -0
index 0db3a47..576ba55 100644
@@ -29,6 +29,7 @@
 #define S5PV310_PA_FIMC1		0x11810000
 #define S5PV310_PA_FIMC2		0x11820000
 #define S5PV310_PA_FIMC3		0x11830000
+#define S5PV310_PA_MFC			0x13400000
 #define S5PV310_PA_I2S0			0x03830000
 #define S5PV310_PA_I2S1			0xE3100000
 #define S5PV310_PA_I2S2			0xE2A00000
@@ -129,6 +130,7 @@
 #define S5P_PA_FIMC1			S5PV310_PA_FIMC1
 #define S5P_PA_FIMC2			S5PV310_PA_FIMC2
 #define S5P_PA_FIMC3			S5PV310_PA_FIMC3
+#define S5P_PA_MFC			S5PV310_PA_MFC
 #define S5P_PA_ONENAND			S5PC210_PA_ONENAND
 #define S5P_PA_ONENAND_DMA		S5PC210_PA_ONENAND_DMA
 #define S5P_PA_SDRAM			S5PV310_PA_SDRAM
arch/arm/mach-s5pv310/include/mach/regs-clock.h +3 -0
index 9ef5f0c..f6b8181 100644
@@ -176,4 +176,7 @@
 
 #define S5P_EPLL_CON			S5P_EPLL_CON0
 
+/* MFC related */
+#define S5P_CLKSRC_MFC			S5P_CLKREG(0x0C228)
+#define S5P_CLKDIV_MFC			S5P_CLKREG(0x0C528)
 #endif /* __ASM_ARCH_REGS_CLOCK_H */
arch/arm/plat-s5p/Kconfig +5 -0
index 4166964..ea9032e 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 -1
index cfcd1db..54e330d 100644
@@ -24,7 +24,7 @@ obj-$(CONFIG_SUSPEND)		+= pm.o
 obj-$(CONFIG_SUSPEND)		+= irq-pm.o
 
 # devices
-
+obj-$(CONFIG_S5P_DEV_MFC)	+= dev-mfc.o
 obj-$(CONFIG_S5P_DEV_FIMC0)	+= dev-fimc0.o
 obj-$(CONFIG_S5P_DEV_FIMC1)	+= dev-fimc1.o
 obj-$(CONFIG_S5P_DEV_FIMC2)	+= dev-fimc2.o
arch/arm/plat-s5p/dev-mfc.c new file +49 -0

49 lines not on this page · raw message

arch/arm/plat-samsung/include/plat/devs.h +1 -0
index 9f42dee..6a869b8 100644
@@ -135,6 +135,7 @@ extern struct platform_device s5p_device_fimc1;
 extern struct platform_device s5p_device_fimc2;
 extern struct platform_device s5p_device_fimc3;
 
+extern struct platform_device s5p_device_mfc;
 extern struct platform_device s5p_device_mipi_csis0;
 extern struct platform_device s5p_device_mipi_csis1;
 
Signature · 1 line
1.6.3.3
#7 lore raw

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

Quoted 24 lines · Kamil Debski

This patch adds platform support for Multi Format Codec 5.1. MFC 5.1 is capable of handling a range of video codecs and this driver provides V4L2 interface for video decoding.

---
 arch/arm/mach-s5pv310/clock.c                   |   28 ++++++++++++-
 arch/arm/mach-s5pv310/include/mach/map.h        |    2 +
 arch/arm/mach-s5pv310/include/mach/regs-clock.h |    3 +
 arch/arm/plat-s5p/Kconfig                       |    5 ++
 arch/arm/plat-s5p/Makefile                      |    2 +-
 arch/arm/plat-s5p/dev-mfc.c                     |   49
+++++++++++++++++++++++
 arch/arm/plat-samsung/include/plat/devs.h       |    1 +
 7 files changed, 88 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/plat-s5p/dev-mfc.c
arch/arm/mach-s5pv310/clock.c +0 -0
index f142b8c..d28fa6f 100644

arch/arm/mach-s5pv310/clock.c static struct clk init_clocks_off[] = { · line 528

Quoted 6 lines
arch/arm/mach-s5pv310/clock.c +3 -0
@@ -523,6 +523,11 @@ static struct clk init_clocks_off[] = {
 		.enable		= s5pv310_clk_ip_lcd1_ctrl,
 		.ctrlbit	= (1 << 0),
 	}, {
+		.name           = "mfc",
+		.id             = -1,
+		.enable         = s5pv310_clk_ip_mfc_ctrl,

Where is "s5pv310_clk_ip_mfc_ctrl" in your patch or mainline? Please make sure that your patch can be applied into current maintainer's tree before submitting.

arch/arm/mach-s5pv310/clock.c static struct clksrc_sources clkset_group = { · line 742

Quoted 10 lines
arch/arm/mach-s5pv310/clock.c +3 -0
+		.ctrlbit        = (1 << 0),
+	}, {
 		.name		= "hsmmc",
 		.id		= 0,
 		.parent		= &clk_aclk_133.clk,
@@ -734,6 +739,18 @@ static struct clksrc_sources clkset_group = {
 	.nr_sources	= ARRAY_SIZE(clkset_group_list),
 };
 
+static struct clk *clkset_group1_list[] = {

What group1? We can know it is used for MFC now, but if there is in just clock.c, can't do it.

arch/arm/mach-s5pv310/clock.c static struct clksrc_sources clkset_group = { · line 746

Quoted 4 lines
arch/arm/mach-s5pv310/clock.c +4 -0
+	[0] = &clk_mout_mpll.clk,
+	[1] = &clk_sclk_apll.clk,
+	[2] = &clk_mout_epll.clk,
+	[3] = &clk_sclk_vpll.clk,

As you know, above sources are not connected to one same MUX, so should be separated.

Quoted 11 lines
arch/arm/mach-s5pv310/clock.c +7 -0
+};
+
+static struct clksrc_sources clkset_group1 = {
+	.sources        = clkset_group1_list,
+	.nr_sources     = ARRAY_SIZE(clkset_group1_list),
+};
+
 static struct clk *clkset_mout_g2d0_list[] = {
 	[0] = &clk_mout_mpll.clk,
 	[1] = &clk_sclk_apll.clk,

arch/arm/mach-s5pv310/clock.c static struct clksrc_clk clksrcs[] = { · line 1095

Quoted 3 lines
arch/arm/mach-s5pv310/clock.c +0 -0
@@ -1076,7 +1093,16 @@ static struct clksrc_clk clksrcs[] = {
 			.ctrlbit	= (1 << 16),
 		},
 		.reg_div = { .reg = S5P_CLKDIV_FSYS3, .shift = 8, .size = 8

},

Review

Quoted 36 lines
arch/arm/mach-s5pv310/clock.c +10 -1
-	}
+	}, {
+		.clk            = {
+			.name           = "sclk_mfc",
+			.id             = -1,
+		},
+		.sources = &clkset_group1,
+		.reg_src = { .reg = S5P_CLKSRC_MFC, .shift = 8, .size = 1 },
+		.reg_div = { .reg = S5P_CLKDIV_MFC, .shift = 0, .size = 4 },
+	},
+
 };
 
 /* Clock initialization code */
arch/arm/mach- renamed from arch/arm/mach-s5pv310/include/mach/map.h +0 -0

s5pv310/include/mach/map.h
index 0db3a47..576ba55 100644

arch/arm/mach-s5pv310/include/mach/map.h +2 -0
@@ -29,6 +29,7 @@
 #define S5PV310_PA_FIMC1		0x11810000
 #define S5PV310_PA_FIMC2		0x11820000
 #define S5PV310_PA_FIMC3		0x11830000
+#define S5PV310_PA_MFC			0x13400000
 #define S5PV310_PA_I2S0			0x03830000
 #define S5PV310_PA_I2S1			0xE3100000
 #define S5PV310_PA_I2S2			0xE2A00000
@@ -129,6 +130,7 @@
 #define S5P_PA_FIMC1			S5PV310_PA_FIMC1
 #define S5P_PA_FIMC2			S5PV310_PA_FIMC2
 #define S5P_PA_FIMC3			S5PV310_PA_FIMC3
+#define S5P_PA_MFC			S5PV310_PA_MFC
 #define S5P_PA_ONENAND			S5PC210_PA_ONENAND
 #define S5P_PA_ONENAND_DMA		S5PC210_PA_ONENAND_DMA
 #define S5P_PA_SDRAM			S5PV310_PA_SDRAM
(quoted diff) +0 -0

b/arch/arm/mach-

Quoted 17 lines

s5pv310/include/mach/regs-clock.h
index 9ef5f0c..f6b8181 100644

arch/arm/mach-s5pv310/include/mach/regs-clock.h +3 -0
@@ -176,4 +176,7 @@
 
 #define S5P_EPLL_CON			S5P_EPLL_CON0
 
+/* MFC related */
+#define S5P_CLKSRC_MFC			S5P_CLKREG(0x0C228)
+#define S5P_CLKDIV_MFC			S5P_CLKREG(0x0C528)
 #endif /* __ASM_ARCH_REGS_CLOCK_H */
arch/arm/plat-s5p/Kconfig +0 -0
index 4166964..ea9032e 100644

arch/arm/plat-s5p/Kconfig line 12

Quoted 8 lines
arch/arm/plat-s5p/Kconfig +5 -0
@@ -5,6 +5,11 @@
 #
 # Licensed under GPLv2
 
+config S5P_DEV_MFC
+	bool
+	help
+	  Compile in platform device definitions for MFC
+

Hmm...above S5P_DEV_MFC should be moved after PLAT_S5P?

Quoted 86 lines
arch/arm/plat-s5p/Kconfig +0 -0
 config PLAT_S5P
 	bool
 	depends on (ARCH_S5P64X0 || ARCH_S5P6442 || ARCH_S5PC100 ||

ARCH_S5PV210 || ARCH_S5PV310)

arch/arm/plat-s5p/Makefile +1 -1
index cfcd1db..54e330d 100644
@@ -24,7 +24,7 @@ obj-$(CONFIG_SUSPEND)		+= pm.o
 obj-$(CONFIG_SUSPEND)		+= irq-pm.o
 
 # devices
-
+obj-$(CONFIG_S5P_DEV_MFC)	+= dev-mfc.o
 obj-$(CONFIG_S5P_DEV_FIMC0)	+= dev-fimc0.o
 obj-$(CONFIG_S5P_DEV_FIMC1)	+= dev-fimc1.o
 obj-$(CONFIG_S5P_DEV_FIMC2)	+= dev-fimc2.o
arch/arm/plat-s5p/dev-mfc.c new file +49 -0
new file mode 100644
index 0000000..0dfcb1a
@@ -0,0 +1,49 @@
+/* linux/arch/arm/plat-s5p/dev-mfc.c
+ *
+ * Copyright (c) 2010 Samsung Electronics
+ *
+ * Base S5P MFC 5.1 resource and device definitions
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+
+#include <linux/kernel.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
+#include <linux/ioport.h>
+
+#include <mach/map.h>
+#include <plat/devs.h>
+#include <plat/irqs.h>
+
+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,
+	}
+};
+
+static u64 s5p_mfc_dma_mask = DMA_BIT_MASK(32);
+
+struct platform_device s5p_device_mfc = {
+	.name          = "s5p-mfc",
+	.id            = -1,
+	.num_resources = ARRAY_SIZE(s5p_mfc_resource),
+	.resource      = s5p_mfc_resource,
+	.dev		= {
+		.dma_mask		= &s5p_mfc_dma_mask,
+		.coherent_dma_mask	= DMA_BIT_MASK(32),
+	},
+};
+
+EXPORT_SYMBOL(s5p_device_mfc);
arch/arm/plat- renamed from arch/arm/plat-samsung/include/plat/devs.h +0 -0

samsung/include/plat/devs.h
index 9f42dee..6a869b8 100644

arch/arm/plat-samsung/include/plat/devs.h +1 -1
@@ -135,6 +135,7 @@ extern struct platform_device s5p_device_fimc1;
 extern struct platform_device s5p_device_fimc2;
 extern struct platform_device s5p_device_fimc3;
 
+extern struct platform_device s5p_device_mfc;
 extern struct platform_device s5p_device_mipi_csis0;
 extern struct platform_device s5p_device_mipi_csis1;
 
--
Quoted 1 line

1.6.3.3

Thanks.

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

#8 lore raw

PATCH v7 3/5 MFC: Add MFC 5.1 V4L2 driver

In reply to Kamil Debski

Multi Format Codec 5.1 is capable of handling a range of video codecs and this driver provides V4L2 interface for video decoding.

---
 drivers/media/video/Kconfig                  |    8 +
 drivers/media/video/Makefile                 |    1 +
 drivers/media/video/s5p-mfc/Makefile         |    3 +
 drivers/media/video/s5p-mfc/regs-mfc5.h      |  346 ++++
 drivers/media/video/s5p-mfc/s5p_mfc.c        | 2253 ++++++++++++++++++++++++++
 drivers/media/video/s5p-mfc/s5p_mfc_common.h |  240 +++
 drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h  |  182 +++
 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    |  913 +++++++++++
 drivers/media/video/s5p-mfc/s5p_mfc_opr.h    |  142 ++
 13 files changed, 4296 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 12fb325..0bdc64d 100644
@@ -1025,4 +1025,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
+	select VIDEOBUF2_S5P_IOMMU
+	default n
+	help
+	    MFC 5.1 driver for V4L2.
+
 endif # V4L_MEM2MEM_DRIVERS
drivers/media/video/Makefile +1 -0
index fd9488d..4b09ddb 100644
@@ -164,6 +164,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 +346 -0

346 lines not on this page · raw message

drivers/media/video/s5p-mfc/s5p_mfc.c new file +2253 -0

2,253 lines not on this page · raw message

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

240 lines not on this page · raw message

drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h new file +182 -0

139 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

Lines of this file are not shown. View the raw message.

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 +913 -0

913 lines not on this page · raw message

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

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

#9 lore raw

RE: [RFC/PATCH v7 3/5] MFC: Add MFC 5.1 V4L2 driver

Hi, Kamil

I found some mal-functional points.

drivers/media/video/s5p-mfc/regs-mfc5.h

Quoted 89 lines

-----Original Message-----
From: [email protected] [mailto:linux-media- [email protected]] On Behalf Of Kamil Debski
Sent: Friday, March 04, 2011 8:26 PM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [RFC/PATCH v7 3/5] MFC: Add MFC 5.1 V4L2 driver

Multi Format Codec 5.1 is capable of handling a range of video codecs and this driver provides V4L2 interface for video decoding.

---
 drivers/media/video/Kconfig                  |    8 +
 drivers/media/video/Makefile                 |    1 +
 drivers/media/video/s5p-mfc/Makefile         |    3 +
 drivers/media/video/s5p-mfc/regs-mfc5.h      |  346 ++++
 drivers/media/video/s5p-mfc/s5p_mfc.c        | 2253
++++++++++++++++++++++++++
 drivers/media/video/s5p-mfc/s5p_mfc_common.h |  240 +++
 drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h  |  182 +++
 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    |  913 +++++++++++
 drivers/media/video/s5p-mfc/s5p_mfc_opr.h    |  142 ++
 13 files changed, 4296 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 12fb325..0bdc64d 100644
@@ -1025,4 +1025,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
+	select VIDEOBUF2_S5P_IOMMU
+	default n
+	help
+	    MFC 5.1 driver for V4L2.
+
 endif # V4L_MEM2MEM_DRIVERS
drivers/media/video/Makefile +0 -0
index fd9488d..4b09ddb 100644
@@ -164,6 +164,7 @@ obj-$(CONFIG_VIDEO_SH_MOBILE_CSI2)	+=

sh_mobile_csi2.o
obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o
obj-$(CONFIG_VIDEO_OMAP1) += omap1_camera.o
obj-$(CONFIG_VIDEO_SAMSUNG_S5P_FIMC) += s5p-fimc/

drivers/media/video/Makefile +1 -0
+obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC)	+= s5p-mfc/
 
 obj-$(CONFIG_ARCH_DAVINCI)		+= davinci/
drivers/media/video/s5p-mfc/Makefile new file +3 -0
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 +0 -0
new file mode 100644
index 0000000..eeb6e2e
@@ -0,0 +1,346 @@

snipping

Quoted 12 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +12 -0
+}
+
+static inline void s5p_mfc_run_res_change(struct s5p_mfc_ctx *ctx)
+{
+	struct s5p_mfc_dev *dev = ctx->dev;
+
+	s5p_mfc_set_dec_stream_buffer(ctx, 0, 0, 0);
+	dev->curr_ctx = ctx->num;
+	s5p_mfc_clean_ctx_int_flags(ctx);
+	s5p_mfc_decode_one_frame(ctx, MFC_DEC_RES_CHANGE);
+}
+

drivers/media/video/s5p-mfc/regs-mfc5.h line 22

Quoted 10 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +10 -0
+static inline void s5p_mfc_run_dec_last_frames(struct s5p_mfc_ctx *ctx)
+{
+	struct s5p_mfc_dev *dev = ctx->dev;
+
+	s5p_mfc_set_dec_stream_buffer(ctx, 0, 0, 0);
+	dev->curr_ctx = ctx->num;
+	s5p_mfc_clean_ctx_int_flags(ctx);
+	s5p_mfc_decode_one_frame(ctx, MFC_DEC_LAST_FRAME);
+}
+

You used '0' as a second param.(= buf_addr) in s5p_mfc_set_dec_stream_buffer(ctx, 0, 0, 0)
This must be a problem, 'cause OFFSETA(buf_addr) is calculated wrongly. And I propose that
why don't you try to check addr condition(necessary cond. of MFC, it should be located at
rear region from base_addr)

Quoted 87 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +20 -0
+static inline int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx)
+{
+	struct s5p_mfc_dev *dev = ctx->dev;
+	struct s5p_mfc_buf *temp_vb;
+	unsigned long flags;
+	int dec_arg = MFC_DEC_FRAME;
+
+	spin_lock_irqsave(&dev->irqlock, flags);
+
+	/* Frames are being decoded */
+	if (list_empty(&ctx->src_queue)) {
+		mfc_debug("No src buffers.\n");
+		spin_unlock_irqrestore(&dev->irqlock, flags);
+		return -EAGAIN;
+	}
+	/* Get the next source buffer */
+	temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
+	mfc_debug("Temp vb: %p\n", temp_vb);
+	mfc_debug("Src Addr: %08x\n", s5p_mfc_plane_addr(temp_vb->b, 0));
+	s5p_mfc_set_dec_stream_buffer(ctx, s5p_mfc_plane_addr(temp_vb->b,

0),

drivers/media/video/s5p-mfc/regs-mfc5.h new file +1 -0
+				ctx->consumed_stream, temp_vb->b-
Quoted 1 line

v4l2_planes[0].bytesused);

drivers/media/video/s5p-mfc/regs-mfc5.h new file +61 -0
+	spin_unlock_irqrestore(&dev->irqlock, flags);
+	dev->curr_ctx = ctx->num;
+	s5p_mfc_clean_ctx_int_flags(ctx);
+	if (temp_vb->b->v4l2_planes[0].bytesused == 0) {
+	        mfc_debug("Setting ctx->state to FINISHING\n");
+	        ctx->state = MFCINST_DEC_FINISHING;
+		dec_arg = MFC_DEC_LAST_FRAME;
+	}
+	s5p_mfc_decode_one_frame(ctx,
+				dec_arg);
+
+	return 0;
+}
+
+static inline int s5p_mfc_run_get_inst_no(struct s5p_mfc_ctx *ctx)
+{
+	struct s5p_mfc_dev *dev = ctx->dev;
+	int ret;
+
+	/* Preparing decoding - getting instance number */
+	mfc_debug("Getting instance number\n");
+	dev->curr_ctx = ctx->num;
+	s5p_mfc_clean_ctx_int_flags(ctx);
+	ret = s5p_mfc_open_inst(ctx);
+	if (ret) {
+		mfc_err("Failed to create a new instance.\n");
+		ctx->state = MFCINST_DEC_ERROR;
+	}
+	return ret;
+}
+
+static inline int s5p_mfc_run_return_inst(struct s5p_mfc_ctx *ctx)
+{
+	struct s5p_mfc_dev *dev = ctx->dev;
+	int ret;
+
+	/* Closing decoding instance  */
+	mfc_debug("Returning instance number\n");
+	dev->curr_ctx = ctx->num;
+	s5p_mfc_clean_ctx_int_flags(ctx);
+	ret = s5p_mfc_return_inst_no(ctx);
+	if (ret) {
+		mfc_err("Failed to return an instance.\n");
+		ctx->state = MFCINST_DEC_ERROR;
+		return ret;
+	}
+	return ret;
+}
+
+static inline void s5p_mfc_run_init_dec(struct s5p_mfc_ctx *ctx)
+{
+	struct s5p_mfc_dev *dev = ctx->dev;
+	unsigned long flags;
+	struct s5p_mfc_buf *temp_vb;
+
+	/* Initializing decoding - parsing header */
+	spin_lock_irqsave(&dev->irqlock, flags);
+	mfc_debug("Preparing to init decoding.\n");
+	temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
+	s5p_mfc_set_dec_desc_buffer(ctx);
+	mfc_debug("Header size: %d\n", temp_vb->b-
Quoted 1 line

v4l2_planes[0].bytesused);

drivers/media/video/s5p-mfc/regs-mfc5.h new file +1 -0
+	s5p_mfc_set_dec_stream_buffer(ctx, s5p_mfc_plane_addr(temp_vb->b,

0),

drivers/media/video/s5p-mfc/regs-mfc5.h

Quoted 5 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +5 -0
+				0, temp_vb->b->v4l2_planes[0].bytesused);
+	spin_unlock_irqrestore(&dev->irqlock, flags);
+	dev->curr_ctx = ctx->num;
+	mfc_debug("paddr: %08x\n",
+			(int)phys_to_virt(s5p_mfc_plane_addr(temp_vb->b,

0)));

Quoted 7 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +7 -0
+	s5p_mfc_clean_ctx_int_flags(ctx);
+	s5p_mfc_init_decode(ctx);
+}
+
+static inline int s5p_mfc_run_init_dec_buffers(struct s5p_mfc_ctx *ctx)
+{
+	struct s5p_mfc_dev *dev = ctx->dev;

drivers/media/video/s5p-mfc/regs-mfc5.h

Quoted 10 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +10 -0
+	unsigned long flags;
+	struct s5p_mfc_buf *temp_vb;
+	int ret;
+	/* Header was parsed now starting processing
+	 * First set the output frame buffers
+	 * s5p_mfc_alloc_dec_buffers(ctx); */
+
+	if (ctx->capture_state != QUEUE_BUFS_MMAPED) {
+		mfc_err("It seems that not all destionation buffers were "
+			"mmaped.\nMFC requires that all destination are

mmaped

drivers/media/video/s5p-mfc/regs-mfc5.h

Quoted 10 lines

"

drivers/media/video/s5p-mfc/regs-mfc5.h new file +8 -0
+			"before starting processing.\n");
+		return -EAGAIN;
+	}
+
+	spin_lock_irqsave(&dev->irqlock, flags);
+
+	if (list_empty(&ctx->src_queue)) {
+		mfc_err("Header has been deallocated in the middle of "

+ "initialization.\n")
;

Quoted 10 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +6 -0
+		spin_unlock_irqrestore(&dev->irqlock, flags);
+		return -EIO;
+	}
+
+	temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
+	mfc_debug("Header size: %d\n", temp_vb->b-
Quoted 1 line

v4l2_planes[0].bytesused);

drivers/media/video/s5p-mfc/regs-mfc5.h new file +1 -0
+	s5p_mfc_set_dec_stream_buffer(ctx, s5p_mfc_plane_addr(temp_vb->b,

0),

drivers/media/video/s5p-mfc/regs-mfc5.h new file +1 -0
+				0, temp_vb->b->v4l2_planes[0].bytesused);

drivers/media/video/s5p-mfc/regs-mfc5.h

Quoted 10 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +10 -0
+	spin_unlock_irqrestore(&dev->irqlock, flags);
+	dev->curr_ctx = ctx->num;
+	s5p_mfc_clean_ctx_int_flags(ctx);
+	ret = s5p_mfc_set_dec_frame_buffer(ctx);
+	if (ret) {
+		mfc_err("Failed to alloc frame mem.\n");
+		ctx->state = MFCINST_DEC_ERROR;
+	}
+	return ret;
+}

snipping

Quoted 10 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +9 -0
+/* Set registers for decoding stream buffer */
+int s5p_mfc_set_dec_stream_buffer(struct s5p_mfc_ctx *ctx, int buf_addr,
+		  unsigned int start_num_byte, unsigned int buf_size)
+{
+	struct s5p_mfc_dev *dev = ctx->dev;
+
+	mfc_debug_enter();
+	mfc_debug("inst_no: %d, buf_addr: 0x%08x, buf_size: 0x"
+		"%08x (%d)\n",  ctx->inst_no, buf_addr, buf_size, buf_size);

drivers/media/video/s5p-mfc/regs-mfc5.h

Quoted 10 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +10 -0
+	WRITEL(OFFSETA(buf_addr), S5P_FIMV_SI_CH0_SB_ST_ADR);
+	WRITEL(CPB_BUF_SIZE, S5P_FIMV_SI_CH0_CPB_SIZE);
+	WRITEL(buf_size, S5P_FIMV_SI_CH0_SB_FRM_SIZE);
+	mfc_debug("Shared_virt: %p (start offset: %d)\n",
+					ctx->shared_virt, start_num_byte);
+	s5p_mfc_set_start_num(ctx, start_num_byte);
+	mfc_debug_leave();
+	return 0;
+}
+

Snipping

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

#10 lore raw

RE: [RFC/PATCH v7 3/5] MFC: Add MFC 5.1 V4L2 driver

Quoted 2 lines

From: Jaeryul Oh [mailto:[email protected]]
Hi, Kamil

Hi Peter,

Quoted 1 line

I found some mal-functional points.

I have commented below.

Quoted 116 lines

drivers/media/video/s5p-mfc/regs-mfc5.h

Quoted 90 lines

-----Original Message-----
From: [email protected] [mailto:linux-media- [email protected]] On Behalf Of Kamil Debski
Sent: Friday, March 04, 2011 8:26 PM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [RFC/PATCH v7 3/5] MFC: Add MFC 5.1 V4L2 driver

Multi Format Codec 5.1 is capable of handling a range of video codecs and this driver provides V4L2 interface for video decoding.

---
 drivers/media/video/Kconfig                  |    8 +
 drivers/media/video/Makefile                 |    1 +
 drivers/media/video/s5p-mfc/Makefile         |    3 +
 drivers/media/video/s5p-mfc/regs-mfc5.h      |  346 ++++
 drivers/media/video/s5p-mfc/s5p_mfc.c        | 2253
++++++++++++++++++++++++++
 drivers/media/video/s5p-mfc/s5p_mfc_common.h |  240 +++
 drivers/media/video/s5p-mfc/s5p_mfc_ctrls.h  |  182 +++
 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    |  913 +++++++++++
 drivers/media/video/s5p-mfc/s5p_mfc_opr.h    |  142 ++
 13 files changed, 4296 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 12fb325..0bdc64d 100644
@@ -1025,4 +1025,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
+	select VIDEOBUF2_S5P_IOMMU
+	default n
+	help
+	    MFC 5.1 driver for V4L2.
+
 endif # V4L_MEM2MEM_DRIVERS
drivers/media/video/Makefile +0 -0
index fd9488d..4b09ddb 100644
@@ -164,6 +164,7 @@ obj-$(CONFIG_VIDEO_SH_MOBILE_CSI2)	+=

sh_mobile_csi2.o
obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o
obj-$(CONFIG_VIDEO_OMAP1) += omap1_camera.o
obj-$(CONFIG_VIDEO_SAMSUNG_S5P_FIMC) += s5p-fimc/

drivers/media/video/Makefile +1 -0
+obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC)	+= s5p-mfc/
 
 obj-$(CONFIG_ARCH_DAVINCI)		+= davinci/
drivers/media/video/s5p-mfc/Makefile new file +3 -0
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 +0 -0
new file mode 100644
index 0000000..eeb6e2e
@@ -0,0 +1,346 @@

snipping

Quoted 12 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +12 -0
+}
+
+static inline void s5p_mfc_run_res_change(struct s5p_mfc_ctx *ctx)
+{
+	struct s5p_mfc_dev *dev = ctx->dev;
+
+	s5p_mfc_set_dec_stream_buffer(ctx, 0, 0, 0);
+	dev->curr_ctx = ctx->num;
+	s5p_mfc_clean_ctx_int_flags(ctx);
+	s5p_mfc_decode_one_frame(ctx, MFC_DEC_RES_CHANGE);
+}
+

drivers/media/video/s5p-mfc/regs-mfc5.h line 22

Quoted 10 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +10 -0
+static inline void s5p_mfc_run_dec_last_frames(struct s5p_mfc_ctx *ctx)
+{
+	struct s5p_mfc_dev *dev = ctx->dev;
+
+	s5p_mfc_set_dec_stream_buffer(ctx, 0, 0, 0);
+	dev->curr_ctx = ctx->num;
+	s5p_mfc_clean_ctx_int_flags(ctx);
+	s5p_mfc_decode_one_frame(ctx, MFC_DEC_LAST_FRAME);
+}
+
Quoted 7 lines

You used '0' as a second param.(= buf_addr) in s5p_mfc_set_dec_stream_buffer(ctx, 0, 0, 0)
This must be a problem, 'cause OFFSETA(buf_addr) is calculated wrongly. And I propose that
why don't you try to check addr condition(necessary cond. of MFC, it should be located at
rear region from base_addr)

This function is called after the last input buffer has been sent to be decoded. Its purpose is to get the output buffers that were kept in MFC as reference frames.
At this time there is no useful data in the input buffer and if I understand correct
it should not be used by MFC firmware, thus I don't see the reason to set its address.

Is there something I don't know? Is MFC using this buffer? When I used MFC with IOMMU I had no page faults at this point of time.

Quoted 159 lines
Quoted 87 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +20 -0
+static inline int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx)
+{
+	struct s5p_mfc_dev *dev = ctx->dev;
+	struct s5p_mfc_buf *temp_vb;
+	unsigned long flags;
+	int dec_arg = MFC_DEC_FRAME;
+
+	spin_lock_irqsave(&dev->irqlock, flags);
+
+	/* Frames are being decoded */
+	if (list_empty(&ctx->src_queue)) {
+		mfc_debug("No src buffers.\n");
+		spin_unlock_irqrestore(&dev->irqlock, flags);
+		return -EAGAIN;
+	}
+	/* Get the next source buffer */
+	temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
+	mfc_debug("Temp vb: %p\n", temp_vb);
+	mfc_debug("Src Addr: %08x\n", s5p_mfc_plane_addr(temp_vb->b, 0));
+	s5p_mfc_set_dec_stream_buffer(ctx, s5p_mfc_plane_addr(temp_vb->b,

0),

drivers/media/video/s5p-mfc/regs-mfc5.h new file +1 -0
+				ctx->consumed_stream, temp_vb->b-
Quoted 1 line

v4l2_planes[0].bytesused);

drivers/media/video/s5p-mfc/regs-mfc5.h new file +61 -0
+	spin_unlock_irqrestore(&dev->irqlock, flags);
+	dev->curr_ctx = ctx->num;
+	s5p_mfc_clean_ctx_int_flags(ctx);
+	if (temp_vb->b->v4l2_planes[0].bytesused == 0) {
+	        mfc_debug("Setting ctx->state to FINISHING\n");
+	        ctx->state = MFCINST_DEC_FINISHING;
+		dec_arg = MFC_DEC_LAST_FRAME;
+	}
+	s5p_mfc_decode_one_frame(ctx,
+				dec_arg);
+
+	return 0;
+}
+
+static inline int s5p_mfc_run_get_inst_no(struct s5p_mfc_ctx *ctx)
+{
+	struct s5p_mfc_dev *dev = ctx->dev;
+	int ret;
+
+	/* Preparing decoding - getting instance number */
+	mfc_debug("Getting instance number\n");
+	dev->curr_ctx = ctx->num;
+	s5p_mfc_clean_ctx_int_flags(ctx);
+	ret = s5p_mfc_open_inst(ctx);
+	if (ret) {
+		mfc_err("Failed to create a new instance.\n");
+		ctx->state = MFCINST_DEC_ERROR;
+	}
+	return ret;
+}
+
+static inline int s5p_mfc_run_return_inst(struct s5p_mfc_ctx *ctx)
+{
+	struct s5p_mfc_dev *dev = ctx->dev;
+	int ret;
+
+	/* Closing decoding instance  */
+	mfc_debug("Returning instance number\n");
+	dev->curr_ctx = ctx->num;
+	s5p_mfc_clean_ctx_int_flags(ctx);
+	ret = s5p_mfc_return_inst_no(ctx);
+	if (ret) {
+		mfc_err("Failed to return an instance.\n");
+		ctx->state = MFCINST_DEC_ERROR;
+		return ret;
+	}
+	return ret;
+}
+
+static inline void s5p_mfc_run_init_dec(struct s5p_mfc_ctx *ctx)
+{
+	struct s5p_mfc_dev *dev = ctx->dev;
+	unsigned long flags;
+	struct s5p_mfc_buf *temp_vb;
+
+	/* Initializing decoding - parsing header */
+	spin_lock_irqsave(&dev->irqlock, flags);
+	mfc_debug("Preparing to init decoding.\n");
+	temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
+	s5p_mfc_set_dec_desc_buffer(ctx);
+	mfc_debug("Header size: %d\n", temp_vb->b-
Quoted 1 line

v4l2_planes[0].bytesused);

drivers/media/video/s5p-mfc/regs-mfc5.h new file +1 -0
+	s5p_mfc_set_dec_stream_buffer(ctx, s5p_mfc_plane_addr(temp_vb->b,

0),

drivers/media/video/s5p-mfc/regs-mfc5.h

Quoted 5 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +5 -0
+				0, temp_vb->b->v4l2_planes[0].bytesused);
+	spin_unlock_irqrestore(&dev->irqlock, flags);
+	dev->curr_ctx = ctx->num;
+	mfc_debug("paddr: %08x\n",
+			(int)phys_to_virt(s5p_mfc_plane_addr(temp_vb->b,

0)));

Quoted 7 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +7 -0
+	s5p_mfc_clean_ctx_int_flags(ctx);
+	s5p_mfc_init_decode(ctx);
+}
+
+static inline int s5p_mfc_run_init_dec_buffers(struct s5p_mfc_ctx *ctx)
+{
+	struct s5p_mfc_dev *dev = ctx->dev;

drivers/media/video/s5p-mfc/regs-mfc5.h

Quoted 10 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +10 -0
+	unsigned long flags;
+	struct s5p_mfc_buf *temp_vb;
+	int ret;
+	/* Header was parsed now starting processing
+	 * First set the output frame buffers
+	 * s5p_mfc_alloc_dec_buffers(ctx); */
+
+	if (ctx->capture_state != QUEUE_BUFS_MMAPED) {
+		mfc_err("It seems that not all destionation buffers were "
+			"mmaped.\nMFC requires that all destination are

mmaped

Quoted 10 lines

"

drivers/media/video/s5p-mfc/regs-mfc5.h new file +8 -0
+			"before starting processing.\n");
+		return -EAGAIN;
+	}
+
+	spin_lock_irqsave(&dev->irqlock, flags);
+
+	if (list_empty(&ctx->src_queue)) {
+		mfc_err("Header has been deallocated in the middle of "
(quoted diff) +1 -0
+							"initialization.\n")

;

Quoted 10 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +6 -0
+		spin_unlock_irqrestore(&dev->irqlock, flags);
+		return -EIO;
+	}
+
+	temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
+	mfc_debug("Header size: %d\n", temp_vb->b-
Quoted 1 line

v4l2_planes[0].bytesused);

drivers/media/video/s5p-mfc/regs-mfc5.h new file +1 -0
+	s5p_mfc_set_dec_stream_buffer(ctx, s5p_mfc_plane_addr(temp_vb->b,

0),

drivers/media/video/s5p-mfc/regs-mfc5.h new file +1 -0
+				0, temp_vb->b->v4l2_planes[0].bytesused);

drivers/media/video/s5p-mfc/regs-mfc5.h

Quoted 10 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +10 -0
+	spin_unlock_irqrestore(&dev->irqlock, flags);
+	dev->curr_ctx = ctx->num;
+	s5p_mfc_clean_ctx_int_flags(ctx);
+	ret = s5p_mfc_set_dec_frame_buffer(ctx);
+	if (ret) {
+		mfc_err("Failed to alloc frame mem.\n");
+		ctx->state = MFCINST_DEC_ERROR;
+	}
+	return ret;
+}

snipping

Quoted 13 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +13 -0
+/* Set registers for decoding stream buffer */
+int s5p_mfc_set_dec_stream_buffer(struct s5p_mfc_ctx *ctx, int buf_addr,
+		  unsigned int start_num_byte, unsigned int buf_size)
+{
+	struct s5p_mfc_dev *dev = ctx->dev;
+
+	mfc_debug_enter();
+	mfc_debug("inst_no: %d, buf_addr: 0x%08x, buf_size: 0x"
+		"%08x (%d)\n",  ctx->inst_no, buf_addr, buf_size, buf_size);
+	WRITEL(OFFSETA(buf_addr), S5P_FIMV_SI_CH0_SB_ST_ADR);
+	WRITEL(CPB_BUF_SIZE, S5P_FIMV_SI_CH0_CPB_SIZE);
+	WRITEL(buf_size, S5P_FIMV_SI_CH0_SB_FRM_SIZE);
+	mfc_debug("Shared_virt: %p (start offset: %d)\n",
Quoted 9 lines

drivers/media/video/s5p-mfc/regs-mfc5.h

Quoted 7 lines
drivers/media/video/s5p-mfc/regs-mfc5.h new file +6 -0
+					ctx->shared_virt, start_num_byte);
+	s5p_mfc_set_start_num(ctx, start_num_byte);
+	mfc_debug_leave();
+	return 0;
+}
+

Snipping

Best regards,
--
Kamil Debski
Linux Platform Group
Samsung Poland R&D Center

#11 lore raw

PATCH v7 4/5 s5pv310: Enable MFC on universal_c210 board

In reply to Kamil Debski

This patch enables MFC 5.1 on the universal_c210 board. Multi Format Codec 5.1 is capable of handling a range of video codecs.

---
 arch/arm/mach-s5pv310/Kconfig               |    1 +
 arch/arm/mach-s5pv310/mach-universal_c210.c |    8 ++++++++
 2 files changed, 9 insertions(+), 0 deletions(-)
arch/arm/mach-s5pv310/Kconfig +1 -0
index c850086..6f83817 100644
@@ -107,6 +107,7 @@ config MACH_UNIVERSAL_C210
 	select S5PV310_SETUP_SDHCI
 	select S3C_DEV_I2C1
 	select S3C_DEV_I2C5
+	select S5P_DEV_MFC
 	select S5PV310_DEV_PD
 	select S5PV310_DEV_SYSMMU
 	select S5PV310_SETUP_I2C1
arch/arm/mach-s5pv310/mach-universal_c210.c +8 -0
index f153895..ce88262 100644
@@ -827,6 +827,10 @@ static struct platform_device *universal_devices[] __initdata = {
 	&s5pv310_device_sysmmu[S5P_SYSMMU_FIMC1],
 	&s5pv310_device_sysmmu[S5P_SYSMMU_FIMC2],
 	&s5pv310_device_sysmmu[S5P_SYSMMU_FIMC3],
+	&s5p_device_mfc,
+	&s5pv310_device_pd[PD_MFC],
+	&s5pv310_device_sysmmu[S5P_SYSMMU_MFC_L],
+	&s5pv310_device_sysmmu[S5P_SYSMMU_MFC_R],
 
 	/* Universal Devices */
 	&universal_gpio_keys,
@@ -862,6 +866,10 @@ static void __init universal_machine_init(void)
 	s5pv310_device_sysmmu[S5P_SYSMMU_FIMC1].dev.parent = &s5pv310_device_pd[PD_CAM].dev;
 	s5pv310_device_sysmmu[S5P_SYSMMU_FIMC2].dev.parent = &s5pv310_device_pd[PD_CAM].dev;
 	s5pv310_device_sysmmu[S5P_SYSMMU_FIMC3].dev.parent = &s5pv310_device_pd[PD_CAM].dev;
+	
+	s5p_device_mfc.dev.parent = &s5pv310_device_pd[PD_MFC].dev;
+	s5pv310_device_sysmmu[S5P_SYSMMU_MFC_L].dev.parent = &s5pv310_device_pd[PD_MFC].dev;
+	s5pv310_device_sysmmu[S5P_SYSMMU_MFC_R].dev.parent = &s5pv310_device_pd[PD_MFC].dev;
 }
 
 MACHINE_START(UNIVERSAL_C210, "UNIVERSAL_C210")
Signature · 1 line
1.6.3.3
#12 lore raw

PATCH v7 5/5 v4l: Documentation for the codec interface

In reply to Kamil Debski

This patch adds documentation for the codec interface of V4L2.

---
 Documentation/DocBook/v4l/dev-codec.xml |  169 ++++++++++++++++++++++++++++---
 1 files changed, 155 insertions(+), 14 deletions(-)
Documentation/DocBook/v4l/dev-codec.xml +155 -14
index 6e156dc..73ecee8 100644
@@ -1,21 +1,162 @@
-  <title>Codec Interface</title>
+	<title>Codec Interface</title>
 
-  <note>
-    <title>Suspended</title>
+	<para>
+A V4L2 codec can compress, decompress, transform, or otherwise convert
+video data from one format into another format, in memory. Applications
+can send and receive the data in two ways. First method utilizes
+&func-write; and &func-read; calls to exchange the data. The second
+uses streaming I/O to interact with the driver.
+	</para>
 
-    <para>This interface has been be suspended from the V4L2 API
-implemented in Linux 2.6 until we have more experience with codec
-device interfaces.</para>
-  </note>
+	<para>
+Codec devices belong to the group of memory-to-memory devices – memory
+buffer containing a frame in one format is converted and stored in another
+buffer in the memory. The format of capture and output buffers is
+determined by the pixel formats passed in the &VIDIOC-S-FMT; call.
+	</para>
 
-  <para>A V4L2 codec can compress, decompress, transform, or otherwise
-convert video data from one format into another format, in memory.
-Applications send data to be converted to the driver through a
-&func-write; call, and receive the converted data through a
-&func-read; call. For efficiency a driver may also support streaming
-I/O.</para>
+	<para>
+Many advanced video codecs – such as H264 and MPEG4 require that decoded buffers
+are kept as reference for other frames. This requirement may result in a use
+case where a few output buffers have to be processed before the first capture
+buffer is returned. In addition the buffers may be dequeued in an arbitrary
+order.
+	</para>
 
-  <para>[to do]</para>
+	<para>
+The codec hardware may enable to tweak decoding parameters and will require the
+application to set encoding parameters. Hence the <constant>
+V4L2_CTRL_CLASS_CODEC control</constant> class has been introduced.
+	</para>
+
+	<para>
+The standard V4L2 naming of buffers is kept – output means input of the device,
+capture on the other hand means the device’s output.
+	</para>
+
+<section>
+	<title>Querying Capabilities</title>
+
+	<para>
+Devices that support the codec interface set the
+<costant>V4L2_CAP_VIDEO_M2M</constant> flag of the capabilities field of the
+v4l2_capability struct returned by the &VIDIOC-QUERYCAP; ioctl. At least one of
+the read/write or streaming I/O methods must be supported.
+	</para>
+</section>
+
+<section>
+	<title>Multiple Instance Capabilities</title>
+
+	<para>
+Codecs as memory to memory devices can support multiple instances.
+Drivers for devices with such capabilities should store configuration context
+for every open file descriptor. This means that configuration is kept only until
+the descriptor is closed and it is not possible to configure the device with one
+application and perform streaming with another. If the device is capable of
+handling only one stream at a time it can use a single context.
+	</para>
+</section>
+
+<section>
+	<title>Image Format Negotiation</title>
+
+	<para>
+In case of decoding a video stream, the header may need to be parsed before the
+stream decoding can take place. Usually only after the header is processed the
+dimensions of the decoded image and the minimum number of buffers is known. This
+requires that the output part of the interface has to be able to process the
+header before allocating the buffers for capture. &VIDIOC-G-FMT; can be used by
+the application to get the parameters of the capture buffers. If necessary the
+&VIDIOC-S-FMT; call can be used to change those parameters, but it is up to the
+driver to validate and correct those values. In addition it is necessary to
+negotiate the number of capture buffers. In many cases the application may need
+to allocate N more buffers than the minimum required by the codec. It can be
+useful in case the device has a minimum number of buffers that have to be queued
+in hardware to operate and if the application needs to keep N buffers dequeued
+for processing. This cannot be easily done with &VIDIOC-REQBUFS; alone. To
+address this issue the V4L2_CID_CODEC_MIN_REQ_ BUFS_CAP control has been
+introduced and can be read to determine the minimum buffer count for the
+capture queue. The application can use this number to calculate the number of
+buffers passed to the REQBUFS call. The V4L2_CID_CODEC_MIN_REQ_ BUFS_OUT
+control can also be used if the minimum number of buffers is determined for the
+output queue, for example in case of encoding.
+	</para>
+
+	<para>
+When encoding &VIDIOC-S-FMT; has to be done on both capture and output.
+&VIDIOC-S-FMT; on capture will determine the video codec to be used and encoding
+parameters should be configured by setting appropriate controls. &VIDIOC-S-FMT;
+on output will be used to determine the input image parameters.
+	</para>
+</section>
+
+<section>
+	<title>Processing</title>
+
+	<para>
+In case of streaming I/O the processing is done by queueing and dequeueing
+buffers on both the capture and output queue. In case of decoding it may be
+necessary to parse the header before the parameters of the video are determined.
+In such case the size and number of capture buffers is unknown, hence only the
+output part of the device is initialized. The application should extract the
+header from the stream and queue it as the first buffer on the output queue.
+After the header is parsed by the hardware the capture part of the codec can be
+initialized. In case of encoding both capture and output parts have to be
+initialized before stream on is called.
+	</para>
+
+	<para>
+When streamoff is called then the buffers that were in that queue are discarded.
+This can be used to support compressed stream seeking – after streamoff on
+capture and output all the frames are discarded. Then buffers from new position
+in the stream are queued on the output queue and empty buffers are queued on the
+capture queue. When stream on is called afterwards processing is resumed from
+the new position in the stream.
+	</para>
+
+	<para>
+Marking end-of-stream is necessary, because a number of buffers may be kept
+queued in the hardware for the purpose of acting as reference frames. After
+reaching end of compressed stream it is necessary to mark end-of-stream with a
+buffer which bytesused is set to 0 on the output side. After all remaining
+buffers are dequeued on the capture side, a buffer with bytesused set to 0 is
+dequeued.
+	</para>
+</section>
+
+<section>
+	<title>Resolution change</title>
+
+	<para>
+The resolution and the minimum number of buffers of the decoded picture can be
+changed during streaming. This feature is widely used in digital TV broadcasts.
+If the hardware is able to support such feature it is necessary that the driver
+notifies the application about such event. It might be necessary for the
+application to reallocate the buffers. Such notification is similar to the
+end-of-stream notification – if resolution or the number of necessary buffers is
+changed then the remaining capture buffers are dequeued and then one buffer with
+bytesused set to 0 is returned to the application. At this time the application
+should reallocate and queue the capture buffers. To do this it is necessary to
+call streamoff on the capture, unmap the buffers, free the memory by calling
+reqbufs with count set to 0. Now the application can read the new resolution by
+running &VIDIOC-G-FMT; and the minimum number of buffers by reading the
+V4L2_CID_CODEC_MIN_REQ_BUFS_CAP control. After allocating, mmaping and queueing the
+buffers the hardware will continue processing.
+	</para>
+</section>
+
+<section>
+	<title>Supplemental features</title>
+
+	<para>
+Hardware and format constraints may influence the size of the capture buffer.
+For example the hardware may need the image buffer to be aligned to 128x32
+size.  To read the actual video frame size the application should use the
+&VIDIOC-G-CROP; call for decoding and use &VIDIOC-S-CROP; call in case of
+encoding.
+	</para>
+</section>
 
   <!--
 Local Variables:
Signature · 1 line
1.6.3.3