TV drivers for Samsung S5P platform (media part)
v6 cover TV drivers for Samsung S5P platform (media part)
Hello,
I would like to present the 6th version of TV drivers for Samsung S5P platform. The most recent changes are:
1. The patch for TV drivers was separated into three patches.
- one patch for HDMI and HDMIPHY driver
- two patches respectively for SDO and Mixer
2. Number of fixes after Hans Verkuil's review.
- code cleanup, fixed upside-down function order
- merged PAL standards for SDO driver
- added colorspace support
- fixed setting caps bits
- fixed return values on errors
- add usage of v4l2_fh framework
- reduced debugging control to simple on/off switch in Kconfig
- marked drivers as experimental due to usage of OVERLAY buffer for cropping configuration
3. New API features.
- support for VIDIOC_G_DV_PRESET
- support for VIDIOC_G_STD
- support for VIDIOC_G_OUTPUT
- support for PRIORITY api
- drivers passed v4l2-compliance tests
4. Other fixes
- fixed hang-up problem on pm_runtime resume caused by resetting mixer while its clock's parent was off. The problem is caused by incorrect clock modelling for Samsung S5P platform
- fixed calculations of multiplane related fields
- fix in v4l_fill_dv_preset_info function
- added new callbacks to v4l2_subdev: g_tvnorms_output, g_dv_preset, g_std_output
Updated RFC for TV driver:
==============
Introduction
==============
The purpose of this RFC is to discuss the driver for a TV output interface available in upcoming Samsung SoC. The HW is able to generate digital and analog signals. Current version of the driver supports only digital output.
Internally the driver uses videobuf2 framework, and DMA-CONTIG memory allocator.
======================
Hardware description
======================
The SoC contains a few HW sub-blocks:
1. Video Processor (VP). It is used for processing of NV12 data. An image stored in RAM is accessed by DMA. Pixels are cropped, scaled. Additionally, post processing operations like brightness, sharpness and contrast adjustments could be performed. The output in YCbCr444 format is send to Mixer.
2. Mixer (MXR). The piece of hardware responsible for mixing and blending multiple data inputs before passing it to an output device. The MXR is capable of handling up to three image layers. One is the output of VP. Other two are images in RGB format (multiple variants are supported). The layers are scaled, cropped and blended with background color. The blending factor, and layers' priority are controlled by MXR's registers. The output is passed either to HDMI or SDO.
3. HDMI. The piece of HW responsible for generation of HDMI packets. It takes pixel data from mixer and transforms it into data frames. The output is send to HDMIPHY interface.
4. HDMIPHY. Physical interface for HDMI. Its duties are sending HDMI packets to HDMI connector. Basically, it contains a PLL that produces source clock for Mixer, VP and HDMI during streaming.
5. SDO. Generation of TV analog signal. The alternative output for the Mixer. It receives data and passes it to VideoDAC. The SDO is responsible for timing generation of analog TV signal. It supports multiple standards.
6. VideoDAC. Modulator for TVOUT signal. Receives data from SDO. Converts it to analog domain. Next, the signal is modulated to CVBS format, amplified and sent to Composite Connector.
The diagram below depicts connection between all HW pieces.
+-----------+
NV12 data ---dma--->| Video |
| Processor |
+-----------+
|
V
+-----------+
RGB data ---dma--->| |
| Mixer |
RGB data ---dma--->| |
+-----------+
|
* dmux
/
+-----* *------+
| |
V V
+-----------+ +-----------+
| HDMI | | SDO |
+-----------+ +-----------+
| |
V V
+-----------+ +-----------+
| HDMIPHY | | VideoDAC |
+-----------+ +-----------+
| |
V V
HDMI Composite
connector connector==================
Driver interface
==================
The posted driver implements three V4L2 nodes. Every video node implements V4L2 output buffer. One of nodes corresponds to input of Video Processor. The other two nodes correspond to RGB inputs of Mixer. All nodes share the same output. It is one of the Mixer's outputs: SDO or HDMI. Changing output in one layer using S_OUTPUT would change outputs of all other video nodes. The same thing happens if one try to reconfigure output i.e. by calling S_DV_PRESET. However it not possible to change or reconfigure the output while streaming. To sum up, all features in posted version of driver goes as follows:
1. QUERYCAP
2. S_FMT, G_FMT - multiplanar API, single planar modes must be emulated
a) node named video0 supports formats NV12, NV21, NV12T (tiled version of
NV12), NV12MT (multiplane version of NV12T).
b) nodes named graph0 and graph1 support formats RGB565, ARGB1555, ARGB4444,
ARGB8888.
3. Buffer with USERPTR and MMAP memory.
4. Streaming and buffer control. (STREAMON, STREAMOFF, REQBUF, QBUF, DQBUF)
5. OUTPUT configurations and enumeration using VIDIOC_{ENUM/S/G}_OUTPUT.
6. DV preset control (SET, GET, ENUM). Currently modes 480P59_94, 720P59_94, 1080P30, 1080P59_94 and 1080P60 work.
7. Analog standards using VIDIOC_{S_/G_/ENUM}STD. Modes PAL_N, PAL_Nc, PAL_M, PAL_60, NTSC_443, PAL_BGHID, NTSC_M are supported.
8. Positioning layer's window on output display using S_CROP, G_GROP, CROPCAP.
9. Positioning and cropping data in buffer using S_CROP, G_GROP, CROPCAP with buffer type OVERLAY *. This is temporary interface and it is going to be substituted by SELECTION api.
10. Support for priority api: VIDIOC_{G/S}_PRIORITY
TODOs:
- add control of alpha blending / chroma keying via V4L2 controls
- add controls for luminance curve and sharpness in VP
- consider exporting all output functionalities to separate video node
- consider media controller framework
* The need of cropping in source buffers came from problem with MFC driver for S5P. The MFC supports only width divisible by 64. If a width of a decoded movie is not aligned do 64 then padding pixels are filled with zeros. This is an ugly green color in YCbCr colorspace. Filling it with zeros by a CPU is a waste of resources since an image can be cropped in VP. Is it possible to set crops for user data for M2M devices. V4L2 lacks such functionality of non-M2M devices. Therefore cropping in buffer V4L2_BUF_TYPE_VIDEO_OVERLAY was used as an work around.
=====================
Device Architecture
=====================
Three drivers are added in this patch.
1. HDMIPHY. It is an I2C driver for HDMIPHY interface. It exports following callback by V4L2 subdevice:
- s_power: currently stub
- s_stream: configures and starts/stops HDMIPHY
- s_dv_preset: used to choose proper frequency of clock for other TV devices
2. HDMI. The auxiliary driver used to control HDMI interface. It exports its subdev in its private data for use by other drivers. The following callbacks are implemented:
- s_power: runs HDMI hardware, regulators and clocks.
- s_stream: runs HDMIPHY and starts generation of video frames.
- enum_dv_presets
- s_dv_preset
- g_dv_preset: returns current preset used by HDMI
- g_mbus_format: returns information on data format expected by on HDMI input The driver supports an interrupt. It is used to detect plug/unplug events in
kernel debugs. The API for detection of such an events in V4L2 API is to be defined.
3. SDO. The auxiliary driver used to control analog TV. It also exports its subdev for other drivers. The following callbacks are implemented.
- s_power: runs TV hardware, regulators and clocks.
- s_stream: runs TV clock and starts generation of video signal.
- s_std_output: set configuration of TV standard from one of PAL/NTSC family
- g_std_output: get current configuration of TV standard
- g_tvnorms_output: used by Mixer to obtain tv standards supported by SDO
- g_mbus_format: returns information on data format expected by on SDO input
5. Mixer & Video Processor driver. It is called 's5p-mixer' because of historical reasons. It was decided combine VP and MXR drivers into one because of shared interrupt and very similar interface via V4L2 nodes. The driver is a realization of many-to-many relation between multiple input layers and multiple outputs. All shared resources are kept in struct mxr_device. It provides utilities for management and synchronization of access to resources and reference counting. The outputs are obtained from HDMI/SDO private data. One layer is a single video node. Simple inheritance is applied because there only little difference between layer's types. Every layer type implements set of ops. There are different ops for Mixer layers and other for VP layer.
The videobuf2 framework was used for the management of buffers and streaming. All other V4L2 ioctls are processed in layers common interface. The DMA-COHERENT was used as memory allocator for Mixer's buffers. It could be easily exchanged with any other allocator integrated with videobuf2 framework.
===============
Usage summary
===============
Follow steps below to display double-buffered animation on output. In order to use other output please use VIDIOC_S_OUTPUT.
01. Open video node named graph0.
02. S_FMT(type = OUTPUT, pixelformat = V4L2_PIX_FMT_RGB*, width, height, ...)
03. REQ_BUFS(type = OUTPUT, memory = MMAP, count = 2)
04. MMAP(type = OUTPUT, index = 0)
05. MMAP(type = OUTPUT, index = 1)
06. Fill buffer 0 with data
07. QBUF(type = OUTPUT, index = 0)
08. STREAM_ON(type = OUTPUT)
09. Fill buffer 1 with data
10. QBUF(type = OUTPUT, index = 1)
11. DQBUF(type = OUTPUT)
12. QBUF(type = OUTPUT, index = 0)
13. DQBUF(type = OUTPUT)
14. Goto 09
===============
Patch Summary
===============
Tomasz Stanislawski (8):
v4l: add macro for 1080p59_54 preset
v4l: add g_tvnorms_output callback to V4L2 subdev
v4l: add g_dv_preset callback to V4L2 subdev
v4l: add g_std_output callback to V4L2 subdev
v4l: fix v4l_fill_dv_preset_info function
v4l: s5p-tv: add drivers for HDMI on Samsung S5P platform
v4l: s5p-tv: add SDO driver for Samsung S5P platform
v4l: s5p-tv: add TV Mixer driver for Samsung S5P platform
drivers/media/video/Kconfig | 2 + drivers/media/video/Makefile | 1 + drivers/media/video/s5p-tv/Kconfig | 76 ++ drivers/media/video/s5p-tv/Makefile | 17 + drivers/media/video/s5p-tv/hdmi_drv.c | 1043 ++++++++++++++++++++++++++ drivers/media/video/s5p-tv/hdmiphy_drv.c | 196 +++++ drivers/media/video/s5p-tv/mixer.h | 354 +++++++++ drivers/media/video/s5p-tv/mixer_drv.c | 487 ++++++++++++ drivers/media/video/s5p-tv/mixer_grp_layer.c | 185 +++++ drivers/media/video/s5p-tv/mixer_reg.c | 541 +++++++++++++ drivers/media/video/s5p-tv/mixer_video.c | 1006 +++++++++++++++++++++++++ drivers/media/video/s5p-tv/mixer_vp_layer.c | 211 ++++++ drivers/media/video/s5p-tv/regs-hdmi.h | 141 ++++ drivers/media/video/s5p-tv/regs-mixer.h | 121 +++ drivers/media/video/s5p-tv/regs-sdo.h | 63 ++ drivers/media/video/s5p-tv/regs-vp.h | 88 +++ drivers/media/video/s5p-tv/sdo_drv.c | 479 ++++++++++++ drivers/media/video/v4l2-common.c | 3 + include/linux/videodev2.h | 1 + include/media/v4l2-subdev.h | 12 + 20 files changed, 5027 insertions(+), 0 deletions(-) create mode 100644 drivers/media/video/s5p-tv/Kconfig create mode 100644 drivers/media/video/s5p-tv/Makefile create mode 100644 drivers/media/video/s5p-tv/hdmi_drv.c create mode 100644 drivers/media/video/s5p-tv/hdmiphy_drv.c create mode 100644 drivers/media/video/s5p-tv/mixer.h create mode 100644 drivers/media/video/s5p-tv/mixer_drv.c create mode 100644 drivers/media/video/s5p-tv/mixer_grp_layer.c create mode 100644 drivers/media/video/s5p-tv/mixer_reg.c create mode 100644 drivers/media/video/s5p-tv/mixer_video.c create mode 100644 drivers/media/video/s5p-tv/mixer_vp_layer.c create mode 100644 drivers/media/video/s5p-tv/regs-hdmi.h create mode 100644 drivers/media/video/s5p-tv/regs-mixer.h create mode 100644 drivers/media/video/s5p-tv/regs-sdo.h create mode 100644 drivers/media/video/s5p-tv/regs-vp.h create mode 100644 drivers/media/video/s5p-tv/sdo_drv.c
Signature · 1 line
1.7.5.4
PATCH v6 1/8 v4l: add macro for 1080p59_54 preset
The 1080p59_94 is supported by latest Samsung SoC.
--- drivers/media/video/v4l2-common.c | 1 + include/linux/videodev2.h | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)
drivers/media/video/v4l2-common.c +1 -0
@@ -582,6 +582,7 @@ int v4l_fill_dv_preset_info(u32 preset, struct v4l2_dv_enum_preset *info) { 1920, 1080, "1080p@30" }, /* V4L2_DV_1080P30 */ { 1920, 1080, "1080p@50" }, /* V4L2_DV_1080P50 */ { 1920, 1080, "1080p@60" }, /* V4L2_DV_1080P60 */ + { 1920, 1080, "[email protected]" }, /* V4L2_DV_1080P59_94 */ };if (info ==NULL || preset >=ARRAY_SIZE (dv_presets))
include/linux/videodev2.h +1 -0
@@ -872,6 +872,7 @@ struct v4l2_dv_enum_preset {#define V4L2_DV_1080P30 16/* SMPTE 296M */ #define V4L2_DV_1080P50 17/* BT.1120 */ #define V4L2_DV_1080P60 18/* BT.1120 */ +#define V4L2_DV_1080P59_94 19/* * D V B T T I M I N G S
Signature · 1 line
1.7.5.4
[RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Em 29-06-2011 09:51, Tomasz Stanislawski escreveu:
Quoted 27 lines
The 1080p59_94 is supported by latest Samsung SoC.
Signed-off-by Tomasz Stanislawski <[email protected]>Signed-off-by Kyungmin Park <[email protected]>Reviewed-by Hans Verkuil <[email protected]>--- drivers/media/video/v4l2-common.c | 1 + include/linux/videodev2.h | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)drivers/media/video/v4l2-common.c +1
-0@@ -582,6 +582,7 @@ int v4l_fill_dv_preset_info(u32 preset, struct v4l2_dv_enum_preset *info) { 1920, 1080, "1080p@30" }, /* V4L2_DV_1080P30 */ { 1920, 1080, "1080p@50" }, /* V4L2_DV_1080P50 */ { 1920, 1080, "1080p@60" }, /* V4L2_DV_1080P60 */ + { 1920, 1080, "[email protected]" }, /* V4L2_DV_1080P59_94 */ };if (info ==NULL || preset >=ARRAY_SIZE (dv_presets))include/linux/videodev2.h +0
-0
include/linux/videodev2.h struct v4l2_dv_enum_preset { · line 878
Quoted 7 lines
include/linux/videodev2.h +1
-0@@ -872,6 +872,7 @@ struct v4l2_dv_enum_preset {#define V4L2_DV_1080P30 16/* SMPTE 296M */ #define V4L2_DV_1080P50 17/* BT.1120 */ #define V4L2_DV_1080P60 18/* BT.1120 */ +#define V4L2_DV_1080P59_94 19/* * D V B T T I M I N G S
This patch deserves further discussions, as the specs that define the presets are not so clear with respect to 60Hz and 60/1.001 Hz.
Let me summarize the issue.
1) PRESET STANDARDS
====== =========
There are 3 specs involved with DV presets: ITU-R BT 709 and BT 1120 and CEA 861.
At ITU-R BT.709, both 60Hz and 60/1.001 Hz are equally called as "60 Hz". BT.1120 follows the same logic, as it uses BT.709 as a reference for video timings.
The CEA-861-E spec says at item 4, that:
A video timing with a vertical frequency that is an integer multiple of 6.00 Hz (i.e. 24.00, 30.00, 60.00, 120.00 or 240.00 Hz) is considered to be the same as a video timing with the equivalent detailed timing information but where the vertical frequency is adjusted by a factor of 1000/1001 (i.e., 24/1.001, 30/1.001, 60/1.001, 120/1.001 or 240/1.001). That is, they are considered two versions of the same video timing but with slightly different pixel clock frequencies. Therefore, a DTV that declares it is capable of displaying a video timing with a vertical frequency that is either an integer multiple of 6 Hz or an integer multiple of 6 Hz adjusted by a factor of 1000/1001 shall be capable of displaying both versions of the video timing.
At the same item, the table 2 describes several video parameters for each preset, associating the Video Identification Codes (VIC) for each preset.
Table 4 associates each VIC with the supported formats. For example, VIC 16 means a resolution of 1920x1080 at 59.94Hz/60Hz. The spec does explicitly allow that all vertical frequencies that are multiple of 6 Hz to accept both 59.94 Hz and 60 Hz, as said at note 3 of table 2:
3. A video timing with a vertical frequency that is an integer multiple of 6.00 Hz (i.e. 24.00, 30.00, 60.00, 120.00 or 240.00 Hz) is considered to be the same as a video timing with the equivalent detailed timing information but where the vertical frequency is adjusted by a factor of 1000/1001 (i.e., 24/1.001, 30/1.001, 60/1.001, 120/1.001 or 240/1.001). That is, they are considered two versions of the same video timing but with slightly different pixel clock frequencies. The vertical frequencies of the 240p, 480p, and 480i video formats are typically adjusted by a factor of exactly 1000/1001 for NTSC video compatibility, while the 576p, 576i, and the HDTV video formats are not. The VESA DMT standard [65] specifies a ± 0.5% pixel clock frequency tolerance. Therefore, the nominally 25.175 MHz pixel clock frequency value given for video identification code 1 may be adjusted to 25.2 MHz to obtain an exact 60 Hz vertical frequency.
In other words, the preset for 1920x1080p@60Hz can be used for both 60Hz and 59.94 Hz, according with the above note, being 59.94 Hz the typical value (e. g. the value that should be used on most places).
However, there are some "60 Hz" vertical resolutions that have VIC's with different framerates (like 59.94Hz, 60.054Hz, etc). Those seem to not be covered by the "multiple of 6.00 Hz" rule.
2. V4L2 API
==== ===
The V4L2 specs define a DV timing as having those fields:
__u32 width Width of the active video in pixels__u32 height Height of the active video in lines__u32 interlaced Progressive (0) or interlaced (1)__u32 polarities This is a bit mask that defines polarities of sync signals.__u64 pixelclock Pixel clock in Hz. Ex. 74.25MHz->74250000__u32 hfrontporch Horizontal front porch in pixels__u32 hsync Horizontal sync length in pixels__u32 hbackporch Horizontal back porch in pixels__u32 vfrontporch Vertical front porch in lines__u32 vsync Vertical sync length in lines__u32 vbackporch Vertical back porch in lines__u32 il_vfrontporch Vertical front porch in lines for bottom field of interlaced field formats__u32 il_vsync Vertical sync length in lines for bottom field of interlaced field formats__u32 il_vbackporch Vertical back porch in lines for bottom field of interlaced field formats
[1] http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-g-dv-timings.html
So, it basically allows adjusting the timings for each of the VIC's, but it seems that there is one limitation at the current API:
vblank is an integer value, for both frames 0 and 1. So, it doesn't allow to adjust vblanks like 22.5. This prevents specifying presets like VICs 10/11.
The presets ioctl's [2] provide the following fields:
__u32 index Number of the DV preset, set by the application.__u32 preset This field identifies one of the DV preset values listed in Table A.15, “struct DV Presets”.__u8 name[24] Name of the preset, a NUL-terminated ASCII string, for example: "720P-60", "1080I-60". This information is intended for the user.__u32 width Width of the active video in pixels for the DV preset.__u32 height Height of the active video in lines for the DV preset.
[2] http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-enum-dv-presets.html#v4l2-dv-presets-vals
Where "preset" can mean:
V4L2_DV_INVALID 0 Invalid preset value.V4L2_DV_480P59_94 1 720x480 progressive video at 59.94 fps as per BT.1362.V4L2_DV_576P50 2 720x576 progressive video at 50 fps as per BT.1362.V4L2_DV_720P24 3 1280x720 progressive video at 24 fps as per SMPTE 296M.V4L2_DV_720P25 4 1280x720 progressive video at 25 fps as per SMPTE 296M.V4L2_DV_720P30 5 1280x720 progressive video at 30 fps as per SMPTE 296M.V4L2_DV_720P50 6 1280x720 progressive video at 50 fps as per SMPTE 296M.V4L2_DV_720P59_94 7 1280x720 progressive video at 59.94 fps as per SMPTE 274M.V4L2_DV_720P60 8 1280x720 progressive video at 60 fps as per SMPTE 274M/296M.V4L2_DV_1080I29_97 9 1920x1080 interlaced video at 29.97 fps as per BT.1120/SMPTE 274M.V4L2_DV_1080I30 10 1920x1080 interlaced video at 30 fps as per BT.1120/SMPTE 274M.V4L2_DV_1080I25 11 1920x1080 interlaced video at 25 fps as per BT.1120.V4L2_DV_1080I50 12 1920x1080 interlaced video at 50 fps as per SMPTE 296M.V4L2_DV_1080I60 13 1920x1080 interlaced video at 60 fps as per SMPTE 296M.V4L2_DV_1080P24 14 1920x1080 progressive video at 24 fps as per SMPTE 296M.V4L2_DV_1080P25 15 1920x1080 progressive video at 25 fps as per SMPTE 296M.V4L2_DV_1080P30 16 1920x1080 progressive video at 30 fps as per SMPTE 296M.V4L2_DV_1080P50 17 1920x1080 progressive video at 50 fps as per BT.1120.V4L2_DV_1080P60 18 1920x1080 progressive video at 60 fps as per BT.1120.
3. ISSUES AT V4L2 API
====== == ==== ===
There are some troubles at the way we currently define the presets:
3.1) The preset macros have the name of the active video lines, but this is also present at
the height field;
3.2) The preset macros don't have the name of the active video columns;
3.3) If someone would want to add a preset for some CEA-861-E VICs, namespace conflicts will
happen. For example, a preset for 1440x576@50Hz would have the same name as a preset
for 2880x576p at 50 Hz. Both would be called as V4L2_DV_576P50.3.4) It doesn't mind what DV timing is used, CEA-861-E and BT.709 allows to use the 60Hz
timings as either 60Hz or 59.94 Hz. That applies to all VIC format timings at table 2 for 60 Hz, 120 Hz and 240 Hz.
3.5) There are lots of format at CEA-861-E without a V4L2 preset.
4. PROPOSED SOLUTION
======== ========
In order to fix the issue, we need change the API without breaking the current apps that use the timings ioctls. Also, the vertical rate clock for 60Hz formats needs to allow a fractional adjustment of either 1 or 1000/1001, in order to support the specs.
4.1) Preset renaming
---------------
To avoid having duplicated namespace conflicts, the better seems to rename the existing presets to contain both width and height at their macro definitions, like:
#define V4L2_DV_1920_1080P60 18 1920x1080 progressive video at 60 fps as per BT.1120
(for the sake of simplicity, I just took one value from the table. The same fix is needed
to be applied for the other macro definitions)
To avoid breaking userspace, the old names need to be associated with the new ones, with:
#define V4L2_DV_1080P60 V4L2_DV_1920_1080P60
This fixes issue 3.2 and 3.3. Unfortunately, fixing 3.1 is not possible anymore, so, we have to keep the same information duplicated on two places (at the macro name and at the width/height).
The question that remains unsolved is what an userspace application would handle a driver that might eventually provide inconsistent data at width/height and at the macro names?
4.2) Framerate selection for 60Hz preset
-----------------------------------
As the spec allows using any format that it is multiple of 6.00 Hz multiplied by either 1 or 1000/1001, the selection betweem them should be done via VIDIOC_G_PARM/VIDIOC_S_PARM. So, V4L2 spec should say, at the "Digital Video (DV) Timings" section:
Devices that implement DV timings shall implement VIDIOC_G_PARM/VIDIOC_S_PARM, in order to allow controlling the vertical frame rate for the presets whose vertical rate is multiple of 6.00 Hz, in order to allow setting the timing between 60 Hz and 59.94 Hz. The default value, at device init, shall be 59.94 Hz.
4.3) Add the missing CEA-861-E presets
---------------------------------
As those formats are part of the spec that is implemented by this V4L2 API, the better would be to implement all the missing formats at the V4L2 spec. As a generic rule, we don't add support at the Kernel without having a driver using it, but, in this specific case, we want to be able to be compatible with the specs, so, it seems a good idea to implement the remaining ones, or, at least reserve its namespace at the DocBook. This solves issue 3.5.
5) S5P-TV SUPPORT FOR 59.94 HZ
===========================
It is not clear, from this patch, if you're really wanting to implement support for VIC 16 format @59.94 Hz, or something else. From CEA-861-E, it seems to be the case, as this is the only 1920x1080p format for 60 Hz. If this is the case, according with my proposal, the driver should be using the 60Hz format, instead, and implement S_PARM to allow selecting between 60Hz and 59.94Hz.
Comments?
Cheers,
Mauro
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Hi Mauro,
On Monday 04 July 2011 18:09:18 Mauro Carvalho Chehab wrote:
[snip]
Quoted 11 lines
1) PRESET STANDARDS
====== =========There are 3 specs involved with DV presets: ITU-R BT 709 and BT 1120 and CEA 861.
At ITU-R BT.709, both 60Hz and 60/1.001 Hz are equally called as "60 Hz". BT.1120 follows the same logic, as it uses BT.709 as a reference for video timings.
The CEA-861-E spec says at item 4, that:
[snip]
Quoted 2 lines
At the same item, the table 2 describes several video parameters for each preset, associating the Video Identification Codes (VIC) for each preset.
This might be a bit out of scope, but why aren't we using the VICs as DV presets ?
Signature · 3 lines
Regards, Laurent Pinchart
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Em 04-07-2011 19:47, Laurent Pinchart escreveu:
Quoted 18 lines
Hi Mauro,
On Monday 04 July 2011 18:09:18 Mauro Carvalho Chehab wrote:
[snip]
Quoted 11 lines
1) PRESET STANDARDS
====== =========There are 3 specs involved with DV presets: ITU-R BT 709 and BT 1120 and CEA 861.
At ITU-R BT.709, both 60Hz and 60/1.001 Hz are equally called as "60 Hz". BT.1120 follows the same logic, as it uses BT.709 as a reference for video timings.
The CEA-861-E spec says at item 4, that:
Quoted 7 lines
[snip]
Quoted 2 lines
At the same item, the table 2 describes several video parameters for each preset, associating the Video Identification Codes (VIC) for each preset.
This might be a bit out of scope, but why aren't we using the VICs as DV presets ?
I had the same question after analyzing the specs ;)
That's said, abstracting from the spec could be a good idea if we have newer versions of the spec re-defining the VICs.
Maybe the right thing to do would be to rename the presets as:
V4L2_DV_CEA861_VIC_16V4L2_DV_CEA861_VIC_35_36
...
(or course, preserving the old names with compatibility macros)
Cheers,
Mauro
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
In reply to Laurent PinchartQuoted 18 lines · On Tuesday, July 05, 2011 00:47:43 Laurent Pinchart wrote:
Hi Mauro,
On Monday 04 July 2011 18:09:18 Mauro Carvalho Chehab wrote:
[snip]
Quoted 11 lines
1) PRESET STANDARDS
====== =========There are 3 specs involved with DV presets: ITU-R BT 709 and BT 1120 and CEA 861.
At ITU-R BT.709, both 60Hz and 60/1.001 Hz are equally called as "60 Hz". BT.1120 follows the same logic, as it uses BT.709 as a reference for video timings.
The CEA-861-E spec says at item 4, that:
Quoted 7 lines
[snip]
Quoted 2 lines
At the same item, the table 2 describes several video parameters for each preset, associating the Video Identification Codes (VIC) for each preset.
This might be a bit out of scope, but why aren't we using the VICs as DV presets ?
The VIC does more than just set the timings. It also determines the pixel aspect ratio. So exactly the same video timings may have two VICs, the only difference being the pixel aspect which is *not* part of the timings. The VIC is part of the AVI InfoFrame, however.
So VIC != timings.
Regards,
Hans
Hans Verkuil
NAKRe: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
In reply to Mauro Carvalho ChehabQuoted 61 lines · On Monday, July 04, 2011 18:09:18 Mauro Carvalho Chehab wrote:
Em 29-06-2011 09:51, Tomasz Stanislawski escreveu:
Quoted 27 lines
The 1080p59_94 is supported by latest Samsung SoC.
Signed-off-by Tomasz Stanislawski <[email protected]>Signed-off-by Kyungmin Park <[email protected]>Reviewed-by Hans Verkuil <[email protected]>--- drivers/media/video/v4l2-common.c | 1 + include/linux/videodev2.h | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)drivers/media/video/v4l2-common.c +1
-0@@ -582,6 +582,7 @@ int v4l_fill_dv_preset_info(u32 preset, struct v4l2_dv_enum_preset *info) { 1920, 1080, "1080p@30" }, /* V4L2_DV_1080P30 */ { 1920, 1080, "1080p@50" }, /* V4L2_DV_1080P50 */ { 1920, 1080, "1080p@60" }, /* V4L2_DV_1080P60 */ + { 1920, 1080, "[email protected]" }, /* V4L2_DV_1080P59_94 */ };if (info ==NULL || preset >=ARRAY_SIZE (dv_presets))include/linux/videodev2.h +0
-0include/linux/videodev2.h struct v4l2_dv_enum_preset { · line 878
Quoted 7 lines
include/linux/videodev2.h +1
-0@@ -872,6 +872,7 @@ struct v4l2_dv_enum_preset {#define V4L2_DV_1080P30 16/* SMPTE 296M */ #define V4L2_DV_1080P50 17/* BT.1120 */ #define V4L2_DV_1080P60 18/* BT.1120 */ +#define V4L2_DV_1080P59_94 19/* * D V B T T I M I N G S This patch deserves further discussions, as the specs that define the presets are not so clear with respect to 60Hz and 60/1.001 Hz.
Let me summarize the issue.
1) PRESET STANDARDS
====== =========There are 3 specs involved with DV presets: ITU-R BT 709 and BT 1120 and CEA 861.
At ITU-R BT.709, both 60Hz and 60/1.001 Hz are equally called as "60 Hz". BT.1120 follows the same logic, as it uses BT.709 as a reference for video timings.
The CEA-861-E spec says at item 4, that:
A video timing with a vertical frequency that is an integer multiple of 6.00 Hz (i.e. 24.00, 30.00, 60.00, 120.00 or 240.00 Hz) is considered to be the same as a video timing with the equivalent detailed timing information but where the vertical frequency is adjusted by a factor of 1000/1001 (i.e., 24/1.001, 30/1.001, 60/1.001, 120/1.001 or 240/1.001). That is, they are considered two versions of the same video timing but with slightly different pixel clock frequencies. Therefore, a DTV that declares it is capable of displaying a video timing with a vertical frequency that is either an integer multiple of 6 Hz or an integer multiple of 6 Hz adjusted by a factor of 1000/1001 shall be capable of displaying both versions of the video timing.
Quoted 2 lines
At the same item, the table 2 describes several video parameters for each preset, associating the Video Identification Codes (VIC) for each preset.
No, *multiple VICs* are associated with each preset. VIC != preset.
Also, the VICs do not differentiate between 60 and 59.94 Hz.
Quoted 14 lines
Table 4 associates each VIC with the supported formats. For example, VIC 16 means a resolution of 1920x1080 at 59.94Hz/60Hz. The spec does explicitly allow that all vertical frequencies that are multiple of 6 Hz to accept both 59.94 Hz and 60 Hz, as said at note 3 of table 2:
3. A video timing with a vertical frequency that is an integer multiple of 6.00 Hz (i.e. 24.00, 30.00, 60.00, 120.00 or 240.00 Hz) is considered to be the same as a video timing with the equivalent detailed timing information but where the vertical frequency is adjusted by a factor of 1000/1001 (i.e., 24/1.001, 30/1.001, 60/1.001, 120/1.001 or 240/1.001). That is, they are considered two versions of the same video timing but with slightly different pixel clock frequencies. The vertical frequencies of the 240p, 480p, and 480i video formats are typically adjusted by a factor of exactly 1000/1001 for NTSC video compatibility, while the 576p, 576i, and the HDTV video formats are not. The VESA DMT standard [65] specifies a ± 0.5% pixel clock frequency tolerance. Therefore, the nominally 25.175 MHz pixel clock frequency value given for video identification code 1 may be adjusted to 25.2 MHz to obtain an exact 60 Hz vertical frequency.
Quoted 7 lines
In other words, the preset for 1920x1080p@60Hz can be used for both 60Hz and 59.94 Hz, according with the above note, being 59.94 Hz the typical value (e. g. the value that should be used on most places).
However, there are some "60 Hz" vertical resolutions that have VIC's with different framerates (like 59.94Hz, 60.054Hz, etc). Those seem to not be covered by the "multiple of 6.00 Hz" rule.
No. A preset identifies one specific modeline (to use the terminology from the GPU world). It defines the front/back porches, sync lengths, active area and pixelclock frequency. Any ambiguities as to the timings of a preset should be resolved by the documentation (which clearly needs a bit more work). In general, though, all the currently defined presets refer to CEA-861. The standards mentioned in videodev2.h all refer to the same things, but CEA-861 is the standard where it all comes together.
In practice there are four different standards that the preset API can use:
CEA-861 for all things HDTV (HDMI)
VESA DMT timings for DVI-D (PC) type timings (VGA, XVGA, etc.) VESA GTF timings (officially deprecated, but still quite common algorithm to
calculate timings)
VESA CVT timings (the newer algorithm to calculate timings)
GTF and CVT pose there own problems and Cisco will be making a proposal for how to handle this some time this year.
VESA DMT timings as easy to add since they are well-defined. We plan on doing that.
Quoted 21 lines
2. V4L2 API
==== ===The V4L2 specs define a DV timing as having those fields:
__u32width Width of the active video in pixels__u32height Height of the active video in lines__u32interlaced Progressive (0) or interlaced (1)__u32polarities This is a bit mask that defines polarities of sync signals.__u64pixelclock Pixel clock in Hz. Ex. 74.25MHz->74250000__u32hfrontporch Horizontal front porch in pixels__u32hsync Horizontal sync length in pixels__u32hbackporch Horizontal back porch in pixels__u32vfrontporch Vertical front porch in lines__u32vsync Vertical sync length in lines__u32vbackporch Vertical back porch in lines__u32il_vfrontporchVertical front porch in lines for bottom field of interlaced field formats__u32il_vsyncVertical sync length in lines for bottom field of interlaced field formats__u32il_vbackporchVertical back porch in lines for bottom field of interlaced field formats
Quoted 7 lines
[1] http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-g-dv-timings.html
So, it basically allows adjusting the timings for each of the VIC's, but it seems that there is one limitation at the current API:
vblank is an integer value, for both frames 0 and 1. So, it doesn't allow to adjust vblanks like 22.5. This prevents specifying presets like VICs 10/11.
vblanks are never halflines. One field is one line longer than the other. As note 1 in table 2
says: "fractional values indicate that the number of blanking lines varies". It's why we have those il_ fields.
Quoted 24 lines
The presets ioctl's [2] provide the following fields:
__u32index Number of the DV preset, set by the application.__u32preset This field identifies one of the DV preset values listed in Table A.15, “struct DV Presets”.__u8name[24] Name of the preset, a NUL-terminated ASCII string, for example: "720P-60", "1080I-60". This information is intended for the user.__u32width Width of the active video in pixels for the DV preset.__u32height Height of the active video in lines for the DV preset.[2] http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-enum-dv-presets.html#v4l2-dv-presets-vals
Where "preset" can mean:
V4L2_DV_INVALID0 Invalid preset value.V4L2_DV_480P59_941 720x480 progressive video at 59.94 fps as per BT.1362.V4L2_DV_576P502 720x576 progressive video at 50 fps as per BT.1362.V4L2_DV_720P243 1280x720 progressive video at 24 fps as per SMPTE 296M.V4L2_DV_720P254 1280x720 progressive video at 25 fps as per SMPTE 296M.V4L2_DV_720P305 1280x720 progressive video at 30 fps as per SMPTE 296M.V4L2_DV_720P506 1280x720 progressive video at 50 fps as per SMPTE 296M.V4L2_DV_720P59_947 1280x720 progressive video at 59.94 fps as per SMPTE 274M.V4L2_DV_720P608 1280x720 progressive video at 60 fps as per SMPTE 274M/296M.V4L2_DV_1080I29_979 1920x1080 interlaced video at 29.97 fps as per BT.1120/SMPTE 274M.V4L2_DV_1080I3010 1920x1080 interlaced video at 30 fps as per BT.1120/SMPTE 274M.
Quoted 8 lines
V4L2_DV_1080I2511 1920x1080 interlaced video at 25 fps as per BT.1120.V4L2_DV_1080I5012 1920x1080 interlaced video at 50 fps as per SMPTE 296M.V4L2_DV_1080I6013 1920x1080 interlaced video at 60 fps as per SMPTE 296M.V4L2_DV_1080P2414 1920x1080 progressive video at 24 fps as per SMPTE 296M.V4L2_DV_1080P2515 1920x1080 progressive video at 25 fps as per SMPTE 296M.V4L2_DV_1080P3016 1920x1080 progressive video at 30 fps as per SMPTE 296M.V4L2_DV_1080P5017 1920x1080 progressive video at 50 fps as per BT.1120.V4L2_DV_1080P6018 1920x1080 progressive video at 60 fps as per BT.1120.
All these standards need to be replaced with CEA-861.
Quoted 9 lines
3. ISSUES AT V4L2 API
====== == ==== ===There are some troubles at the way we currently define the presets:
3.1) The preset macros have the name of the active video lines, but this is also present at
the height field;
??? While a human can see that V4L2_DV_1080P60 refers to 1080 lines, a computer can't. The macro is a just a number, so you need to communicate the width and height explicitly.
Quoted 1 line
3.2) The preset macros don't have the name of the active video columns;
For the current set of macros the industry convention is used. 1080P50 always refers to 1920x1080. Anything else should be made explicit.
Quoted 3 lines
3.3) If someone would want to add a preset for some CEA-861-E VICs, namespace conflicts will
happen. For example, a preset for 1440x576@50Hz would have the same name as a preset for 2880x576p at 50 Hz. Both would be called as V4L2_DV_576P50.
Obviously that would have to be called V4L2_DV_2880X576P50 (or something similar).
Quoted 3 lines
3.4) It doesn't mind what DV timing is used, CEA-861-E and BT.709 allows to use the 60Hz
timings as either 60Hz or 59.94 Hz. That applies to all VIC format timings at table 2 for 60 Hz, 120 Hz and 240 Hz.
No, the pixelclock is part of the preset timings. So V4L2_DV_1080P60 and V4L2_DV_1080P59_94 are different presets with different timings. Just as they would be different modelines for your graphics card. I really don't see the problem here.
Quoted 1 line
3.5) There are lots of format at CEA-861-E without a V4L2 preset.
True. Frankly I have yet to encounter any of the weird ones (i.e. other than 640x480, 480p/i, 576p/i, 720p/i and 1080p/i with their various framerates).
Quoted 14 lines
4. PROPOSED SOLUTION
======== ========In order to fix the issue, we need change the API without breaking the current apps that use the timings ioctls. Also, the vertical rate clock for 60Hz formats needs to allow a fractional adjustment of either 1 or 1000/1001, in order to support the specs.
4.1) Preset renaming
---------------To avoid having duplicated namespace conflicts, the better seems to rename the existing presets to contain both width and height at their macro definitions, like:
Quoted 8 lines
#define
V4L2_DV_1920_1080P6018 1920x1080 progressive video at 60 fps as per BT.1120(for the sake of simplicity, I just took one value from the table. The same fix is needed
to be applied for the other macro definitions)To avoid breaking userspace, the old names need to be associated with the new ones, with:
#define
V4L2_DV_1080P60V4L2_DV_1920_1080P60
I've no problem with that. 1080P60 is still a useful shorthand.
Quoted 4 lines
This fixes issue 3.2 and 3.3. Unfortunately, fixing 3.1 is not possible anymore, so, we have to keep the same information duplicated on two places (at the macro name and at the width/height).
As I mentioned above, for a program the macro name is useless.
Quoted 2 lines
The question that remains unsolved is what an userspace application would handle a driver that might eventually provide inconsistent data at width/height and at the macro names?
That's a driver bug.
Quoted 11 lines
4.2) Framerate selection for 60Hz preset
-----------------------------------As the spec allows using any format that it is multiple of 6.00 Hz multiplied by either 1 or 1000/1001, the selection betweem them should be done via VIDIOC_G_PARM/VIDIOC_S_PARM. So, V4L2 spec should say, at the "Digital Video (DV) Timings" section:
Devices that implement DV timings shall implement VIDIOC_G_PARM/VIDIOC_S_PARM, in order to allow controlling the vertical frame rate for the presets whose vertical rate is multiple of 6.00 Hz, in order to allow setting the timing between 60 Hz and 59.94 Hz. The default value, at device init, shall be 59.94 Hz.
NACK.
The pixel clock is part of the video timings and hence defined by the preset.
VIDIOC_S_PARM is used when the desired framerate differs from the actual framerate and the driver can do frame repeating or frameskipping. At least that's what the V4L2 spec says. In practice it is used to set the framerate for sensors. I'm not sure if there is any driver that actually uses it for frameskipping. To my knowledge it is not used at all for video output.
Quoted 9 lines
4.3) Add the missing CEA-861-E presets
---------------------------------As those formats are part of the spec that is implemented by this V4L2 API, the better would be to implement all the missing formats at the V4L2 spec. As a generic rule, we don't add support at the Kernel without having a driver using it, but, in this specific case, we want to be able to be compatible with the specs, so, it seems a good idea to implement the remaining ones, or, at least reserve its namespace at the DocBook. This solves issue 3.5.
I'm not so sure. There are lots of weird resolutions in CEA-861 that I have never seen in use. A better approach IMHO is that whenever we add a resolution to the preset table, then we do that for all variants of that resolution.
Quoted 8 lines
5) S5P-TV SUPPORT FOR 59.94 HZ
===========================It is not clear, from this patch, if you're really wanting to implement support for VIC 16 format @59.94 Hz, or something else. From CEA-861-E, it seems to be the case, as this is the only 1920x1080p format for 60 Hz. If this is the case, according with my proposal, the driver should be using the 60Hz format, instead, and implement
S_PARMto allow selecting between 60Hz and 59.94Hz.
NACK. You need two presets: V4L2_DV_1080P60 and 1080P59_94. Just as is already there for 720P60 and 720P59_94. I really don't see the problem.
Regards,
Hans
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Em 05-07-2011 04:26, Hans Verkuil escreveu:
Quoted 62 lines · On Monday, July 04, 2011 18:09:18 Mauro Carvalho Chehab wrote:
Quoted 61 lines
Em 29-06-2011 09:51, Tomasz Stanislawski escreveu:
Quoted 27 lines
The 1080p59_94 is supported by latest Samsung SoC.
Signed-off-by Tomasz Stanislawski <[email protected]>Signed-off-by Kyungmin Park <[email protected]>Reviewed-by Hans Verkuil <[email protected]>--- drivers/media/video/v4l2-common.c | 1 + include/linux/videodev2.h | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)drivers/media/video/v4l2-common.c +1
-0@@ -582,6 +582,7 @@ int v4l_fill_dv_preset_info(u32 preset, struct v4l2_dv_enum_preset *info) { 1920, 1080, "1080p@30" }, /* V4L2_DV_1080P30 */ { 1920, 1080, "1080p@50" }, /* V4L2_DV_1080P50 */ { 1920, 1080, "1080p@60" }, /* V4L2_DV_1080P60 */ + { 1920, 1080, "[email protected]" }, /* V4L2_DV_1080P59_94 */ };if (info ==NULL || preset >=ARRAY_SIZE (dv_presets))include/linux/videodev2.h +0
-0include/linux/videodev2.h struct v4l2_dv_enum_preset { · line 878
Quoted 7 lines
include/linux/videodev2.h +1
-0@@ -872,6 +872,7 @@ struct v4l2_dv_enum_preset {#define V4L2_DV_1080P30 16/* SMPTE 296M */ #define V4L2_DV_1080P50 17/* BT.1120 */ #define V4L2_DV_1080P60 18/* BT.1120 */ +#define V4L2_DV_1080P59_94 19/* * D V B T T I M I N G S This patch deserves further discussions, as the specs that define the presets are not so clear with respect to 60Hz and 60/1.001 Hz.
Let me summarize the issue.
1) PRESET STANDARDS
====== =========There are 3 specs involved with DV presets: ITU-R BT 709 and BT 1120 and CEA 861.
At ITU-R BT.709, both 60Hz and 60/1.001 Hz are equally called as "60 Hz". BT.1120 follows the same logic, as it uses BT.709 as a reference for video timings.
The CEA-861-E spec says at item 4, that:
A video timing with a vertical frequency that is an integer multiple of 6.00 Hz (i.e. 24.00, 30.00, 60.00, 120.00 or 240.00 Hz) is considered to be the same as a video timing with the equivalent detailed timing information but where the vertical frequency is adjusted by a factor of 1000/1001 (i.e., 24/1.001, 30/1.001, 60/1.001, 120/1.001 or 240/1.001). That is, they are considered two versions of the same video timing but with slightly different pixel clock frequencies. Therefore, a DTV that declares it is capable of displaying a video timing with a vertical frequency that is either an integer multiple of 6 Hz or an integer multiple of 6 Hz adjusted by a factor of 1000/1001 shall be capable of displaying both versions of the video timing.
Quoted 4 lines
Quoted 2 lines
At the same item, the table 2 describes several video parameters for each preset, associating the Video Identification Codes (VIC) for each preset.
No, *multiple VICs* are associated with each preset. VIC != preset.
There are two VIC's for several presets, as it is also used at the spec to determine the aspect ratio, but, basically, for one given VIC, there's just one timings preset at the table 2.
Quoted 1 line
Also, the VICs do not differentiate between 60 and 59.94 Hz.
Yes, but V4L2 DV timings also don't differentiate.
Quoted 18 lines
Quoted 18 lines
Table 4 associates each VIC with the supported formats. For example, VIC 16 means a resolution of 1920x1080 at 59.94Hz/60Hz. The spec does explicitly allow that all vertical frequencies that are multiple of 6 Hz to accept both 59.94 Hz and 60 Hz, as said at note 3 of table 2:
3. A video timing with a vertical frequency that is an integer multiple of 6.00 Hz (i.e. 24.00, 30.00, 60.00, 120.00 or 240.00 Hz) is considered to be the same as a video timing with the equivalent detailed timing information but where the vertical frequency is adjusted by a factor of 1000/1001 (i.e., 24/1.001, 30/1.001, 60/1.001, 120/1.001 or 240/1.001). That is, they are considered two versions of the same video timing but with slightly different pixel clock frequencies. The vertical frequencies of the 240p, 480p, and 480i video formats are typically adjusted by a factor of exactly 1000/1001 for NTSC video compatibility, while the 576p, 576i, and the HDTV video formats are not. The VESA DMT standard [65] specifies a ± 0.5% pixel clock frequency tolerance. Therefore, the nominally 25.175 MHz pixel clock frequency value given for video identification code 1 may be adjusted to 25.2 MHz to obtain an exact 60 Hz vertical frequency.
In other words, the preset for 1920x1080p@60Hz can be used for both 60Hz and 59.94 Hz, according with the above note, being 59.94 Hz the typical value (e. g. the value that should be used on most places).
Quoted 8 lines
Quoted 3 lines
However, there are some "60 Hz" vertical resolutions that have VIC's with different framerates (like 59.94Hz, 60.054Hz, etc). Those seem to not be covered by the "multiple of 6.00 Hz" rule.
No. A preset identifies one specific modeline (to use the terminology from the GPU world). It defines the front/back porches, sync lengths, active area and pixelclock frequency. Any ambiguities as to the timings of a preset should be resolved by the documentation (which clearly needs a bit more work).
As I pointed before, it is not just documentation. For all the 6.00 Hz multiple standard, CEA defines that, using the same DV timings, it is possible to choose to shift the clock by 1000/1001 to support the "59.94Hz". So, this applies to several VIC's for 60Hz, 120 Hz and 240Hz.
While it is possible to duplicate the DV timing line for all affected VICs, We'll end by having a very messy API, as there will be two 60 Hz standards, one with the shift and the other without, for the same CEA VIC, plus the CEA standards that are defined for other vertical resolutions like 60.054 Hz, 59.826 Hz, 119.88 Hz, 239.76 Hz and even 59.940 Hz.
Part of the problem is the u32 "preset" var, at v4l2_dv_enum_preset. It requires a namespace to identify the presets, but this can become very confusing with time. How would you distinguish from a CEA-861 60.00 Hz standard with a Vertical frequency shift of 1000/1001 and a CEA-861 59.94 Hz? The current namespace doesn't allow that, and creating a namespace to accommodate would be weird and would easily be very confusing.
Quoted 13 lines
In general,
though, all the currently defined presets refer to CEA-861. The standards mentioned invideodev2.hall refer to the same things, but CEA-861 is the standard where it all comes together.In practice there are four different standards that the preset API can use:
CEA-861 for all things HDTV (HDMI)
VESA DMT timings for DVI-D (PC) type timings (VGA, XVGA, etc.) VESA GTF timings (officially deprecated, but still quite common algorithm to
calculate timings)
VESA CVT timings (the newer algorithm to calculate timings)
Quoted 5 lines
GTF and CVT pose there own problems and Cisco will be making a proposal for how to handle this some time this year.
VESA DMT timings as easy to add since they are well-defined. We plan on doing that.
Well, try to accomodate all those timings using the current namespace for preset. I bet you'll end by having lots of duplicated names for distinct timings.
The API needs to be fixed, and it is better sooner than later.
Quoted 25 lines
Quoted 25 lines
2. V4L2 API
==== ===The V4L2 specs define a DV timing as having those fields:
__u32width Width of the active video in pixels__u32height Height of the active video in lines__u32interlaced Progressive (0) or interlaced (1)__u32polarities This is a bit mask that defines polarities of sync signals.__u64pixelclock Pixel clock in Hz. Ex. 74.25MHz->74250000__u32hfrontporch Horizontal front porch in pixels__u32hsync Horizontal sync length in pixels__u32hbackporch Horizontal back porch in pixels__u32vfrontporch Vertical front porch in lines__u32vsync Vertical sync length in lines__u32vbackporch Vertical back porch in lines__u32il_vfrontporchVertical front porch in lines for bottom field of interlaced field formats__u32il_vsyncVertical sync length in lines for bottom field of interlaced field formats__u32il_vbackporchVertical back porch in lines for bottom field of interlaced field formats[1] http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-g-dv-timings.html
So, it basically allows adjusting the timings for each of the VIC's, but it seems that there is one limitation at the current API:
Quoted 6 lines
Quoted 2 lines
vblank is an integer value, for both frames 0 and 1. So, it doesn't allow to adjust vblanks like 22.5. This prevents specifying presets like VICs 10/11.
vblanks are never halflines. One field is one line longer than the other. As note 1 in table 2
says: "fractional values indicate that the number of blanking lines varies". It's why we have thoseil_fields.
OK.
Quoted 33 lines
Quoted 24 lines
The presets ioctl's [2] provide the following fields:
__u32index Number of the DV preset, set by the application.__u32preset This field identifies one of the DV preset values listed in Table A.15, “struct DV Presets”.__u8name[24] Name of the preset, a NUL-terminated ASCII string, for example: "720P-60", "1080I-60". This information is intended for the user.__u32width Width of the active video in pixels for the DV preset.__u32height Height of the active video in lines for the DV preset.[2] http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-enum-dv-presets.html#v4l2-dv-presets-vals
Where "preset" can mean:
V4L2_DV_INVALID0 Invalid preset value.V4L2_DV_480P59_941 720x480 progressive video at 59.94 fps as per BT.1362.V4L2_DV_576P502 720x576 progressive video at 50 fps as per BT.1362.V4L2_DV_720P243 1280x720 progressive video at 24 fps as per SMPTE 296M.V4L2_DV_720P254 1280x720 progressive video at 25 fps as per SMPTE 296M.V4L2_DV_720P305 1280x720 progressive video at 30 fps as per SMPTE 296M.V4L2_DV_720P506 1280x720 progressive video at 50 fps as per SMPTE 296M.V4L2_DV_720P59_947 1280x720 progressive video at 59.94 fps as per SMPTE 274M.V4L2_DV_720P608 1280x720 progressive video at 60 fps as per SMPTE 274M/296M.V4L2_DV_1080I29_979 1920x1080 interlaced video at 29.97 fps as per BT.1120/SMPTE 274M.V4L2_DV_1080I3010 1920x1080 interlaced video at 30 fps as per BT.1120/SMPTE 274M.Quoted 8 lines
V4L2_DV_1080I2511 1920x1080 interlaced video at 25 fps as per BT.1120.V4L2_DV_1080I5012 1920x1080 interlaced video at 50 fps as per SMPTE 296M.V4L2_DV_1080I6013 1920x1080 interlaced video at 60 fps as per SMPTE 296M.V4L2_DV_1080P2414 1920x1080 progressive video at 24 fps as per SMPTE 296M.V4L2_DV_1080P2515 1920x1080 progressive video at 25 fps as per SMPTE 296M.V4L2_DV_1080P3016 1920x1080 progressive video at 30 fps as per SMPTE 296M.V4L2_DV_1080P5017 1920x1080 progressive video at 50 fps as per BT.1120.V4L2_DV_1080P6018 1920x1080 progressive video at 60 fps as per BT.1120.
Quoted 1 line
All these standards need to be replaced with CEA-861.
Sorry, but I couldn't understand your proposal here.
Quoted 5 lines
Quoted 5 lines
3. ISSUES AT V4L2 API
====== == ==== ===
Quoted 8 lines
Quoted 4 lines
There are some troubles at the way we currently define the presets:
3.1) The preset macros have the name of the active video lines, but this is also present at
the height field;??? While a human can see that
V4L2_DV_1080P60refers to 1080 lines, a computer can't. The macro is a just a number, so you need to communicate the width and height explicitly.
Yes, but the namespace is confusing, and developers might code it as:
if (preset >= V4L2_DV_1080I29_97 || preset <= V4L2_DV_1080P60)
width = 1080;
(or doing the same inside a switch, although I've seen several userspace applications
implementing things like above).
The above would be valid, and the end result is that a duplicated information is provided.
I failed to see what information is provided by the "presets" name. If this were removed from the ioctl, and fps would be added instead, the API would be clearer. The only adjustment would be to use "index" as the preset selection key. Anyway, it is too late for such change. We need to live with that.
Quoted 11 lines
Quoted 2 lines
3.2) The preset macros don't have the name of the active video columns;
For the current set of macros the industry convention is used. 1080P50 always refers to 1920x1080. Anything else should be made explicit.
Quoted 3 lines
3.3) If someone would want to add a preset for some CEA-861-E VICs, namespace conflicts will
happen. For example, a preset for 1440x576@50Hz would have the same name as a preset for 2880x576p at 50 Hz. Both would be called as V4L2_DV_576P50.Obviously that would have to be called
V4L2_DV_2880X576P50(or something similar).
So, the namespace will become messy, with will make developers very confused about what they should use. As you've mentioned, there are currently 4 standards with timings that will needed to be supported. So, at the end of the day, we'll have:
V4L2_DV_576P50V4L2_DV_576P50_fooV4L2_DV_576P50_barV4L2_DV_576P50_deltaV4L2_DV_2880X576P50V4L2_DV_2880X576P50_fooV4L2_DV_2880X576P50_barV4L2_DV_2880X576P50_delta
...
where foo, bar, and delta would be some othe DV-timings based naming. It will become a nightmare for developers to discover, from the above list, what are the timings from VESA DMT and what are from CEA-861.
The solution is to associate its name to the standards naming, like:
V4L2_DV_CEA_861_VIC_35_36
For the timings associated with VICs 35 and 36.
Quoted 8 lines
Quoted 4 lines
3.4) It doesn't mind what DV timing is used, CEA-861-E and BT.709 allows to use the 60Hz
timings as either 60Hz or 59.94 Hz. That applies to all VIC format timings at table 2 for 60 Hz, 120 Hz and 240 Hz.No, the pixelclock is part of the preset timings. So
V4L2_DV_1080P60andV4L2_DV_1080P59_94are different presets with different timings. Just as they would be different modelines for your graphics card. I really don't see the problem here.
Sorry, but the current way that this documented is not clear enough. Also, there's nothing at VIDIOC_ENUM_DV_PRESETS that allows checking the fps, except for the preset name, which is confusing enough.
Quoted 21 lines
Quoted 1 line
3.5) There are lots of format at CEA-861-E without a V4L2 preset.
True. Frankly I have yet to encounter any of the weird ones (i.e. other than 640x480, 480p/i, 576p/i, 720p/i and 1080p/i with their various framerates).
Quoted 16 lines
4. PROPOSED SOLUTION
======== ========In order to fix the issue, we need change the API without breaking the current apps that use the timings ioctls. Also, the vertical rate clock for 60Hz formats needs to allow a fractional adjustment of either 1 or 1000/1001, in order to support the specs.
4.1) Preset renaming
---------------To avoid having duplicated namespace conflicts, the better seems to rename the existing presets to contain both width and height at their macro definitions, like:
#define
V4L2_DV_1920_1080P6018 1920x1080 progressive video at 60 fps as per BT.1120
Quoted 8 lines
Quoted 6 lines
(for the sake of simplicity, I just took one value from the table. The same fix is needed
to be applied for the other macro definitions)To avoid breaking userspace, the old names need to be associated with the new ones, with:
#define
V4L2_DV_1080P60V4L2_DV_1920_1080P60I've no problem with that. 1080P60 is still a useful shorthand.
As I said before, it will be better to change it to explicitly associate with the specs that defined that video timing, with whatever ID code there. So, for CEA-861, it would be, in this case:
#define V4L2_DV_CEA_861_VIC_16 18
and the legacy compat macro:
#define V4L2_DV_1080P60 V4L2_DV_CEA_861_VIC_16
Quoted 24 lines
Quoted 4 lines
This fixes issue 3.2 and 3.3. Unfortunately, fixing 3.1 is not possible anymore, so, we have to keep the same information duplicated on two places (at the macro name and at the width/height).
As I mentioned above, for a program the macro name is useless.
Quoted 2 lines
The question that remains unsolved is what an userspace application would handle a driver that might eventually provide inconsistent data at width/height and at the macro names?
That's a driver bug.
Quoted 11 lines
4.2) Framerate selection for 60Hz preset
-----------------------------------As the spec allows using any format that it is multiple of 6.00 Hz multiplied by either 1 or 1000/1001, the selection betweem them should be done via VIDIOC_G_PARM/VIDIOC_S_PARM. So, V4L2 spec should say, at the "Digital Video (DV) Timings" section:
Devices that implement DV timings shall implement VIDIOC_G_PARM/VIDIOC_S_PARM, in order to allow controlling the vertical frame rate for the presets whose vertical rate is multiple of 6.00 Hz, in order to allow setting the timing between 60 Hz and 59.94 Hz. The default value, at device init, shall be 59.94 Hz.
Quoted 6 lines
NACK.
The pixel clock is part of the video timings and hence defined by the preset.
VIDIOC_S_PARMis used when the desired framerate differs from the actual framerate and the driver can do frame repeating or frameskipping.
NO. VIDIOC_S_PARM is used on all places where the user desires to specify a framerate. All webcams use it to select the desired framerate.
Quoted 1 line
At least that's what the V4L2 spec says.
I'll prepare a patch fixing it. This is one of the parts of the API that got outdated with time.
Quoted 2 lines
In practice it is used to set the framerate for sensors. I'm not sure if there is any driver that actually uses it for frameskipping.
There are some video capture drivers that implement it, so I think that some use it for frameskipping.
Quoted 1 line
To my knowledge it is not used at all for video output.
In any case, selecting a DV timing preset with an specific fps is currently confusing, and requires that the userspace application to have a switch(v4l2_dv_enum_preset.preset) in order to associate a preset macro name with a fps. This is a very bad idea.
I see only two practical solutions for that. The first one is to use S_PARAM. The other one is to stop providing the frequency inside the macro name, and add a field for that at the v4l2_dv_enum_preset struct:
struct v4l2_dv_enum_preset {
__u32 index;
__u32 preset;
__u8 name[32]; /* Name of the preset timing */
__u32 width;
__u32 height;
v4l2_fract fps;
__u32 reserved[2];
};So, for example, a driver that supports only CEA-861 VIC 16 will report 2 presets:
struct v4l2_dv_enum_preset dv[] = {
{ 0, V4L2_DV_CEA_861_VIC_16__60HZ, "CEA-861 1920x1080p 60Hz", 1920, 1080, {60, 1} },
{ 1, V4L2_DV_CEA_861_VIC_16__59_94HZ, "CEA-861 1920x1080p 59.94Hz", 1920, 1080, {60000, 1001} },
};Yet, we should be sure that this will also cover all current VESA standards.
Quoted 10 lines
Quoted 9 lines
4.3) Add the missing CEA-861-E presets
---------------------------------As those formats are part of the spec that is implemented by this V4L2 API, the better would be to implement all the missing formats at the V4L2 spec. As a generic rule, we don't add support at the Kernel without having a driver using it, but, in this specific case, we want to be able to be compatible with the specs, so, it seems a good idea to implement the remaining ones, or, at least reserve its namespace at the DocBook. This solves issue 3.5.
Quoted 3 lines
I'm not so sure. There are lots of weird resolutions in CEA-861 that I have never seen in use. A better approach IMHO is that whenever we add a resolution to the preset table, then we do that for all variants of that resolution.
This works for me.
Quoted 11 lines
Quoted 8 lines
5) S5P-TV SUPPORT FOR 59.94 HZ
===========================It is not clear, from this patch, if you're really wanting to implement support for VIC 16 format @59.94 Hz, or something else. From CEA-861-E, it seems to be the case, as this is the only 1920x1080p format for 60 Hz. If this is the case, according with my proposal, the driver should be using the 60Hz format, instead, and implement
S_PARMto allow selecting between 60Hz and 59.94Hz.NACK. You need two presets:
V4L2_DV_1080P60and 1080P59_94. Just as is already there for 720P60 and 720P59_94. I really don't see the problem.
NACK adding it as "V4L2_DV_1080P59_94".
Let's fix the namespace and provide a way to specify/enumberate the fps first, and then change the patch to follow whatever decided.
Thanks,
Mauro
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Quoted 63 lines · On Tuesday, July 05, 2011 14:08:03 Mauro Carvalho Chehab wrote:
Em 05-07-2011 04:26, Hans Verkuil escreveu:
Quoted 62 lines · On Monday, July 04, 2011 18:09:18 Mauro Carvalho Chehab wrote:
Quoted 61 lines
Em 29-06-2011 09:51, Tomasz Stanislawski escreveu:
Quoted 27 lines
The 1080p59_94 is supported by latest Samsung SoC.
Signed-off-by Tomasz Stanislawski <[email protected]>Signed-off-by Kyungmin Park <[email protected]>Reviewed-by Hans Verkuil <[email protected]>--- drivers/media/video/v4l2-common.c | 1 + include/linux/videodev2.h | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)drivers/media/video/v4l2-common.c +1
-0@@ -582,6 +582,7 @@ int v4l_fill_dv_preset_info(u32 preset, struct v4l2_dv_enum_preset *info) { 1920, 1080, "1080p@30" }, /* V4L2_DV_1080P30 */ { 1920, 1080, "1080p@50" }, /* V4L2_DV_1080P50 */ { 1920, 1080, "1080p@60" }, /* V4L2_DV_1080P60 */ + { 1920, 1080, "[email protected]" }, /* V4L2_DV_1080P59_94 */ };if (info ==NULL || preset >=ARRAY_SIZE (dv_presets))include/linux/videodev2.h +0
-0include/linux/videodev2.h struct v4l2_dv_enum_preset { · line 878
Quoted 7 lines
include/linux/videodev2.h +1
-0@@ -872,6 +872,7 @@ struct v4l2_dv_enum_preset {#define V4L2_DV_1080P30 16/* SMPTE 296M */ #define V4L2_DV_1080P50 17/* BT.1120 */ #define V4L2_DV_1080P60 18/* BT.1120 */ +#define V4L2_DV_1080P59_94 19/* * D V B T T I M I N G S This patch deserves further discussions, as the specs that define the presets are not so clear with respect to 60Hz and 60/1.001 Hz.
Let me summarize the issue.
1) PRESET STANDARDS
====== =========There are 3 specs involved with DV presets: ITU-R BT 709 and BT 1120 and CEA 861.
At ITU-R BT.709, both 60Hz and 60/1.001 Hz are equally called as "60 Hz". BT.1120 follows the same logic, as it uses BT.709 as a reference for video timings.
The CEA-861-E spec says at item 4, that:
A video timing with a vertical frequency that is an integer multiple of 6.00 Hz (i.e. 24.00, 30.00, 60.00, 120.00 or 240.00 Hz) is considered to be the same as a video timing with the equivalent detailed timing information but where the vertical frequency is adjusted by a factor of 1000/1001 (i.e., 24/1.001, 30/1.001, 60/1.001, 120/1.001 or 240/1.001). That is, they are considered two versions of the same video timing but with slightly different pixel clock frequencies. Therefore, a DTV that declares it is capable of displaying a video timing with a vertical frequency that is either an integer multiple of 6 Hz or an integer multiple of 6 Hz adjusted by a factor of 1000/1001 shall be capable of displaying both versions of the video timing.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
At the same item, the table 2 describes several video parameters for each preset, associating the Video Identification Codes (VIC) for each preset.
No, *multiple VICs* are associated with each preset. VIC != preset.
There are two VIC's for several presets, as it is also used at the spec to determine the aspect ratio, but, basically, for one given VIC, there's just one timings preset at the table 2.
Sigh. VIC != video timings. It just gives some additional information regarding aspect ration (duplicated information actually).
The simple fact that you can't use it to determine the pixelclock and thus the vertical frequency means that it is *not* suitable as a way to determine the video timings.
I've been working with HDMI receivers and transmitters for several years now, and it simply is not suitable.
Quoted 3 lines
Quoted 1 line
Also, the VICs do not differentiate between 60 and 59.94 Hz.
Yes, but V4L2 DV timings also don't differentiate.
??? Yes, they do. There is a 720P60 and a 720P59_94. Also 1080I29_97 and 1080I30. The 1080P59_94 is simply missing because nobody needed it yet.
Quoted 32 lines
Quoted 18 lines
Quoted 18 lines
Table 4 associates each VIC with the supported formats. For example, VIC 16 means a resolution of 1920x1080 at 59.94Hz/60Hz. The spec does explicitly allow that all vertical frequencies that are multiple of 6 Hz to accept both 59.94 Hz and 60 Hz, as said at note 3 of table 2:
3. A video timing with a vertical frequency that is an integer multiple of 6.00 Hz (i.e. 24.00, 30.00, 60.00, 120.00 or 240.00 Hz) is considered to be the same as a video timing with the equivalent detailed timing information but where the vertical frequency is adjusted by a factor of 1000/1001 (i.e., 24/1.001, 30/1.001, 60/1.001, 120/1.001 or 240/1.001). That is, they are considered two versions of the same video timing but with slightly different pixel clock frequencies. The vertical frequencies of the 240p, 480p, and 480i video formats are typically adjusted by a factor of exactly 1000/1001 for NTSC video compatibility, while the 576p, 576i, and the HDTV video formats are not. The VESA DMT standard [65] specifies a ± 0.5% pixel clock frequency tolerance. Therefore, the nominally 25.175 MHz pixel clock frequency value given for video identification code 1 may be adjusted to 25.2 MHz to obtain an exact 60 Hz vertical frequency.
In other words, the preset for 1920x1080p@60Hz can be used for both 60Hz and 59.94 Hz, according with the above note, being 59.94 Hz the typical value (e. g. the value that should be used on most places).
Quoted 8 lines
Quoted 3 lines
However, there are some "60 Hz" vertical resolutions that have VIC's with different framerates (like 59.94Hz, 60.054Hz, etc). Those seem to not be covered by the "multiple of 6.00 Hz" rule.
No. A preset identifies one specific modeline (to use the terminology from the GPU world). It defines the front/back porches, sync lengths, active area and pixelclock frequency. Any ambiguities as to the timings of a preset should be resolved by the documentation (which clearly needs a bit more work).
As I pointed before, it is not just documentation. For all the 6.00 Hz multiple standard, CEA defines that, using the same DV timings, it is possible to choose to shift the clock by 1000/1001 to support the "59.94Hz". So, this applies to several VIC's for 60Hz, 120 Hz and 240Hz.
Quoted 5 lines
While it is possible to duplicate the DV timing line for all affected VICs, We'll end by having a very messy API, as there will be two 60 Hz standards, one with the shift and the other without, for the same CEA VIC, plus the CEA standards that are defined for other vertical resolutions like 60.054 Hz, 59.826 Hz, 119.88 Hz, 239.76 Hz and even 59.940 Hz.
So? Different timings, different preset. BTW, as I mentioned earlier, most of the weirder resolution I never see in practice. Just 480, 576, 720 and 1080. Which is why I don't think it is useful to add them unless someone really needs them.
Quoted 4 lines
Part of the problem is the u32 "preset" var, at
v4l2_dv_enum_preset. It requires a namespace to identify the presets, but this can become very confusing with time. How would you distinguish from a CEA-861 60.00 Hz standard with a Vertical frequency shift of 1000/1001 and a CEA-861 59.94 Hz? The current
All CEA-861 59.94 standards have identical timings as the 60 Hz standards, except for the different pixelclock (which is responsible for the frequency shift). So it's unambiguous.
Quoted 19 lines
namespace doesn't allow that, and creating a namespace to accommodate would be weird and would easily be very confusing.
Quoted 16 lines
In general,
though, all the currently defined presets refer to CEA-861. The standards mentioned invideodev2.hall refer to the same things, but CEA-861 is the standard where it all comes together.In practice there are four different standards that the preset API can use:
CEA-861 for all things HDTV (HDMI)
VESA DMT timings for DVI-D (PC) type timings (VGA, XVGA, etc.) VESA GTF timings (officially deprecated, but still quite common algorithm to
calculate timings)
VESA CVT timings (the newer algorithm to calculate timings)GTF and CVT pose there own problems and Cisco will be making a proposal for how to handle this some time this year.
Quoted 6 lines
Quoted 2 lines
VESA DMT timings as easy to add since they are well-defined. We plan on doing that.
Well, try to accomodate all those timings using the current namespace for preset. I bet you'll end by having lots of duplicated names for distinct timings.
We have done that for DMT already. CVT and GTF are a separate issue since presets do not work there. Most likely the VIDIOC_G/S_DV_TIMINGS ioctls will need to be used there.
Quoted 1 line
The API needs to be fixed, and it is better sooner than later.
The API works perfectly well. CEA-861, VESA DMT, no problem at all. There are a few things that need to be added to v4l2_dv_enum_dv_presets such as framerate and interlaced vs progressive. Although I don't want to make changes there until I know how GTF/CVT are going to be handled.
The whole preset API was made to 1) provide a simple way to use the common video formats and 2) handle receivers/transmitters that only provided a limited set of formats. There are quite a few of those that only support the 480/576/720/1080 lines formats.
For more complex timings use VIDIOC_G/S_DV_TIMINGS.
Quoted 88 lines
Quoted 26 lines
Quoted 26 lines
2. V4L2 API
==== ===The V4L2 specs define a DV timing as having those fields:
__u32width Width of the active video in pixels__u32height Height of the active video in lines__u32interlaced Progressive (0) or interlaced (1)__u32polarities This is a bit mask that defines polarities of sync signals.__u64pixelclock Pixel clock in Hz. Ex. 74.25MHz->74250000__u32hfrontporch Horizontal front porch in pixels__u32hsync Horizontal sync length in pixels__u32hbackporch Horizontal back porch in pixels__u32vfrontporch Vertical front porch in lines__u32vsync Vertical sync length in lines__u32vbackporch Vertical back porch in lines__u32il_vfrontporchVertical front porch in lines for bottom field of interlaced field formats__u32il_vsyncVertical sync length in lines for bottom field of interlaced field formats__u32il_vbackporchVertical back porch in lines for bottom field of interlaced field formats[1] http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-g-dv-timings.html
So, it basically allows adjusting the timings for each of the VIC's, but it seems that there is one limitation at the current API:
Quoted 6 lines
Quoted 2 lines
vblank is an integer value, for both frames 0 and 1. So, it doesn't allow to adjust vblanks like 22.5. This prevents specifying presets like VICs 10/11.
vblanks are never halflines. One field is one line longer than the other. As note 1 in table 2
says: "fractional values indicate that the number of blanking lines varies". It's why we have thoseil_fields.OK.
Quoted 33 lines
Quoted 24 lines
The presets ioctl's [2] provide the following fields:
__u32index Number of the DV preset, set by the application.__u32preset This field identifies one of the DV preset values listed in Table A.15, “struct DV Presets”.__u8name[24] Name of the preset, a NUL-terminated ASCII string, for example: "720P-60", "1080I-60". This information is intended for the user.__u32width Width of the active video in pixels for the DV preset.__u32height Height of the active video in lines for the DV preset.[2] http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-enum-dv-presets.html#v4l2-dv-presets-vals
Where "preset" can mean:
V4L2_DV_INVALID0 Invalid preset value.V4L2_DV_480P59_941 720x480 progressive video at 59.94 fps as per BT.1362.V4L2_DV_576P502 720x576 progressive video at 50 fps as per BT.1362.V4L2_DV_720P243 1280x720 progressive video at 24 fps as per SMPTE 296M.V4L2_DV_720P254 1280x720 progressive video at 25 fps as per SMPTE 296M.V4L2_DV_720P305 1280x720 progressive video at 30 fps as per SMPTE 296M.V4L2_DV_720P506 1280x720 progressive video at 50 fps as per SMPTE 296M.V4L2_DV_720P59_947 1280x720 progressive video at 59.94 fps as per SMPTE 274M.V4L2_DV_720P608 1280x720 progressive video at 60 fps as per SMPTE 274M/296M.V4L2_DV_1080I29_979 1920x1080 interlaced video at 29.97 fps as per BT.1120/SMPTE 274M.V4L2_DV_1080I3010 1920x1080 interlaced video at 30 fps as per BT.1120/SMPTE 274M.Quoted 8 lines
V4L2_DV_1080I2511 1920x1080 interlaced video at 25 fps as per BT.1120.V4L2_DV_1080I5012 1920x1080 interlaced video at 50 fps as per SMPTE 296M.V4L2_DV_1080I6013 1920x1080 interlaced video at 60 fps as per SMPTE 296M.V4L2_DV_1080P2414 1920x1080 progressive video at 24 fps as per SMPTE 296M.V4L2_DV_1080P2515 1920x1080 progressive video at 25 fps as per SMPTE 296M.V4L2_DV_1080P3016 1920x1080 progressive video at 30 fps as per SMPTE 296M.V4L2_DV_1080P5017 1920x1080 progressive video at 50 fps as per BT.1120.V4L2_DV_1080P6018 1920x1080 progressive video at 60 fps as per BT.1120.Quoted 1 line
All these standards need to be replaced with CEA-861.
Sorry, but I couldn't understand your proposal here.
Quoted 5 lines
Quoted 5 lines
3. ISSUES AT V4L2 API
====== == ==== ===Quoted 8 lines
Quoted 4 lines
There are some troubles at the way we currently define the presets:
3.1) The preset macros have the name of the active video lines, but this is also present at
the height field;??? While a human can see that
V4L2_DV_1080P60refers to 1080 lines, a computer can't. The macro is a just a number, so you need to communicate the width and height explicitly.Yes, but the namespace is confusing, and developers might code it as:
Quoted 7 lines
if (preset >=
V4L2_DV_1080I29_97|| preset <=V4L2_DV_1080P60)width = 1080;(or doing the same inside a switch, although I've seen several userspace applications
implementing things like above).The above would be valid, and the end result is that a duplicated information is provided.
That's why we have the VIDIOC_DV_ENUM_PRESETS that you can give the preset and get back WxH. How does this differ between v4l2_std_id and ENUMSTD?
Quoted 4 lines
I failed to see what information is provided by the "presets" name. If this were removed from the ioctl, and fps would be added instead, the API would be clearer. The only adjustment would be to use "index" as the preset selection key. Anyway, it is too late for such change. We need to live with that.
Adding the fps solves nothing. Because that still does not give you specific timings. You can have 1920x1080P60 that has quite different timings from the CEA-861 standard and that may not be supported by a TV.
If you are working with HDMI, then you may want to filter all supported presets to those of the CEA standard.
That's one thing that is missing at the moment: that presets belonging to a certain standard get their own range. Since we only do CEA861 right now it hasn't been an issue, but it will.
Quoted 30 lines
Quoted 11 lines
Quoted 2 lines
3.2) The preset macros don't have the name of the active video columns;
For the current set of macros the industry convention is used. 1080P50 always refers to 1920x1080. Anything else should be made explicit.
Quoted 3 lines
3.3) If someone would want to add a preset for some CEA-861-E VICs, namespace conflicts will
happen. For example, a preset for 1440x576@50Hz would have the same name as a preset for 2880x576p at 50 Hz. Both would be called as V4L2_DV_576P50.Obviously that would have to be called
V4L2_DV_2880X576P50(or something similar).So, the namespace will become messy, with will make developers very confused about what they should use. As you've mentioned, there are currently 4 standards with timings that will needed to be supported. So, at the end of the day, we'll have:
V4L2_DV_576P50V4L2_DV_576P50_fooV4L2_DV_576P50_barV4L2_DV_576P50_deltaV4L2_DV_2880X576P50V4L2_DV_2880X576P50_fooV4L2_DV_2880X576P50_barV4L2_DV_2880X576P50_delta
...where foo, bar, and delta would be some othe DV-timings based naming. It will become a nightmare for developers to discover, from the above list, what are the timings from VESA DMT and what are from CEA-861.
Quoted 5 lines
The solution is to associate its name to the standards naming, like:
V4L2_DV_CEA_861_VIC_35_36For the timings associated with VICs 35 and 36.
I've no problem with the CEA_861 prefix. Using VIC is not a good idea for the reasons outlined above.
V4L2_DV_CEA_861_1920X1080P60V4L2_DV_CEA_861_1920X1080P59_94
etc. is fine as far as I am concerned. It's a needed improvement, and the current names are perfectly acceptable as aliases.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
3.4) It doesn't mind what DV timing is used, CEA-861-E and BT.709 allows to use the 60Hz
timings as either 60Hz or 59.94 Hz. That applies to all VIC format timings at table 2 for 60 Hz, 120 Hz and 240 Hz.
Quoted 7 lines
Quoted 3 lines
No, the pixelclock is part of the preset timings. So
V4L2_DV_1080P60andV4L2_DV_1080P59_94are different presets with different timings. Just as they would be different modelines for your graphics card. I really don't see the problem here.Sorry, but the current way that this documented is not clear enough. Also, there's nothing at
VIDIOC_ENUM_DV_PRESETSthat allows checking the fps, except for the preset name, which is confusing enough.
Improving the documentation is always useful. If it wasn't clear enough to you, then other will most likely have the same problem.
Adding some way to determine the fps with ENUM_DV_PRESETS is needed as well. It just needs some careful thinking how this should be done. I don't know whether a v4l2_fract can represent all frequencies. I would need to experiment a bit.
Quoted 30 lines
Quoted 21 lines
Quoted 1 line
3.5) There are lots of format at CEA-861-E without a V4L2 preset.
True. Frankly I have yet to encounter any of the weird ones (i.e. other than 640x480, 480p/i, 576p/i, 720p/i and 1080p/i with their various framerates).
Quoted 16 lines
4. PROPOSED SOLUTION
======== ========In order to fix the issue, we need change the API without breaking the current apps that use the timings ioctls. Also, the vertical rate clock for 60Hz formats needs to allow a fractional adjustment of either 1 or 1000/1001, in order to support the specs.
4.1) Preset renaming
---------------To avoid having duplicated namespace conflicts, the better seems to rename the existing presets to contain both width and height at their macro definitions, like:
#define
V4L2_DV_1920_1080P6018 1920x1080 progressive video at 60 fps as per BT.1120Quoted 8 lines
Quoted 6 lines
(for the sake of simplicity, I just took one value from the table. The same fix is needed
to be applied for the other macro definitions)To avoid breaking userspace, the old names need to be associated with the new ones, with:
#define
V4L2_DV_1080P60V4L2_DV_1920_1080P60I've no problem with that. 1080P60 is still a useful shorthand.
Quoted 8 lines
As I said before, it will be better to change it to explicitly associate with the specs that defined that video timing, with whatever ID code there. So, for CEA-861, it would be, in this case:
#define
V4L2_DV_CEA_861_VIC_1618and the legacy compat macro:
#define V4L2_DV_1080P60 V4L2_DV_CEA_861_VIC_16
I agree with the standard, but not with the VIC part.
Quoted 36 lines
Quoted 24 lines
Quoted 4 lines
This fixes issue 3.2 and 3.3. Unfortunately, fixing 3.1 is not possible anymore, so, we have to keep the same information duplicated on two places (at the macro name and at the width/height).
As I mentioned above, for a program the macro name is useless.
Quoted 2 lines
The question that remains unsolved is what an userspace application would handle a driver that might eventually provide inconsistent data at width/height and at the macro names?
That's a driver bug.
Quoted 11 lines
4.2) Framerate selection for 60Hz preset
-----------------------------------As the spec allows using any format that it is multiple of 6.00 Hz multiplied by either 1 or 1000/1001, the selection betweem them should be done via VIDIOC_G_PARM/VIDIOC_S_PARM. So, V4L2 spec should say, at the "Digital Video (DV) Timings" section:
Devices that implement DV timings shall implement VIDIOC_G_PARM/VIDIOC_S_PARM, in order to allow controlling the vertical frame rate for the presets whose vertical rate is multiple of 6.00 Hz, in order to allow setting the timing between 60 Hz and 59.94 Hz. The default value, at device init, shall be 59.94 Hz.
Quoted 6 lines
NACK.
The pixel clock is part of the video timings and hence defined by the preset.
VIDIOC_S_PARMis used when the desired framerate differs from the actual framerate and the driver can do frame repeating or frameskipping.NO.
VIDIOC_S_PARMis used on all places where the user desires to specify a framerate. All webcams use it to select the desired framerate.Quoted 1 line
At least that's what the V4L2 spec says.
Quoted 8 lines
I'll prepare a patch fixing it. This is one of the parts of the API that got outdated with time.
Quoted 2 lines
In practice it is used to set the framerate for sensors. I'm not sure if there is any driver that actually uses it for frameskipping.
There are some video capture drivers that implement it, so I think that some use it for frameskipping.
G/S_PARM makes sense for sensors, but not for video receivers/transmitters. It simply makes no sense and makes it harder on drivers and applications alike.
Quoted 6 lines
Quoted 2 lines
To my knowledge it is not used at all for video output.
In any case, selecting a DV timing preset with an specific fps is currently confusing, and requires that the userspace application to have a
switch(v4l2_dv_enum_preset.preset)in order to associate a preset macro name with a fps. This is a very bad idea.
Again, that's not how it works. For transmitting the application will enumerate the supported presets and show it to the user who can select from it. For embedded apps it is more likely that the application will hardcode the presets.
For receiving you call QUERY_DV_PRESET and then use it with S_DV_PRESET.
You should never have to do a switch.
And yes, I know that ENUM_DV_PRESETS needs to return the fps. It's on the TODO list.
Quoted 14 lines
I see only two practical solutions for that. The first one is to use
S_PARAM. The other one is to stop providing the frequency inside the macro name, and add a field for that at thev4l2_dv_enum_presetstruct:struct v4l2_dv_enum_preset { __u32 index; __u32 preset; __u8 name[32]; /* Name of the preset timing */ __u32 width; __u32 height; v4l2_fract fps; __u32 reserved[2]; };
Quoted 8 lines
So, for example, a driver that supports only CEA-861 VIC 16 will report 2 presets:
struct v4l2_dv_enum_preset dv[] = { { 0, V4L2_DV_CEA_861_VIC_16__60HZ, "CEA-861 1920x1080p 60Hz", 1920, 1080, {60, 1} }, { 1, V4L2_DV_CEA_861_VIC_16__59_94HZ, "CEA-861 1920x1080p 59.94Hz", 1920, 1080, {60000, 1001} }, };Yet, we should be sure that this will also cover all current VESA standards.
Well, yes, that's the plan. It just needs more research to determine whether v4l2_fract is the best way to specify the fps and how to handle CVT/GTF.
Quoted 26 lines
Quoted 11 lines
Quoted 10 lines
4.3) Add the missing CEA-861-E presets
---------------------------------As those formats are part of the spec that is implemented by this V4L2 API, the better would be to implement all the missing formats at the V4L2 spec. As a generic rule, we don't add support at the Kernel without having a driver using it, but, in this specific case, we want to be able to be compatible with the specs, so, it seems a good idea to implement the remaining ones, or, at least reserve its namespace at the DocBook. This solves issue 3.5.
Quoted 3 lines
I'm not so sure. There are lots of weird resolutions in CEA-861 that I have never seen in use. A better approach IMHO is that whenever we add a resolution to the preset table, then we do that for all variants of that resolution.
This works for me.
Quoted 9 lines
Quoted 8 lines
5) S5P-TV SUPPORT FOR 59.94 HZ
===========================It is not clear, from this patch, if you're really wanting to implement support for VIC 16 format @59.94 Hz, or something else. From CEA-861-E, it seems to be the case, as this is the only 1920x1080p format for 60 Hz. If this is the case, according with my proposal, the driver should be using the 60Hz format, instead, and implement
S_PARMto allow selecting between 60Hz and 59.94Hz.
Quoted 7 lines
Quoted 2 lines
NACK. You need two presets:
V4L2_DV_1080P60and 1080P59_94. Just as is already there for 720P60 and 720P59_94. I really don't see the problem.NACK adding it as "
V4L2_DV_1080P59_94".Let's fix the namespace and provide a way to specify/enumberate the fps first, and then change the patch to follow whatever decided.
So, after all this talk it boils down to:
- Add a CEA_861 namespace
- Add a way to specify the fps in VIDIOC_DV_ENUM_PRESETS
I can work on the proposal this week for that. The only reason the fps hasn't been added yet is that I never had the time to do the research on how to represent the fps reliably for all CEA/VESA formats. Hmm, pixelclock / total_framesize should always work, of course.
We can add a flags field as well (for interlaced vs progressive and perhaps others such as normal vs reduced blanking).
That leaves the problem with GTF/CVT. I'll get back to that tomorrow. I have ideas, but I need to discuss it first.
Regards,
Hans
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Quoted 15 lines · Hans Verkuil
I can work on the proposal this week for that. The only reason the fps hasn't been added
yet is that I never had the time to do the research on how to represent the fps reliably
for all CEA/VESA formats. Hmm, pixelclock /total_framesizeshould always work, of course.We can add a flags field as well (for interlaced vs progressive and perhaps others such as
normal vs reduced blanking).That leaves the problem with GTF/CVT. I'll get back to that tomorrow. I have ideas, but
I need to discuss it first.
Quoted 8 lines
Regards,
Hans
--
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
For fps you could use horizontal_line_freq/lines_per_frame.
However, all of the non-integer fps numbers I have seen in this email chain all seem to be multiples of 29.97002997 Hz. So maybe you could just use the closest integer rate with a flag labeled "ntsc_bw_timing_hack" to indicate the fractional rates. :)
That 29.97 Hz number comes from the NTSC decision in 1953(!) to change the horizontal line freq to 4.5 MHz/286. Note that
(4.5 MHz/286)/525 = 30 * (1000/1001) = 29.97002997 Hz
It is interesting to see one of the most ingenious analog hacks in TV history (to achieve color and B&W backward compatabilty while staying in the 10% tolerance of the old B&W receivers) being codified in digital standards over 50 years later. It boggles the mind...
Regards,
Andy
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Em 05-07-2011 16:02, Andy Walls escreveu:
Quoted 25 lines
Quoted 15 lines · Hans Verkuil
I can work on the proposal this week for that. The only reason the fps hasn't been added
yet is that I never had the time to do the research on how to represent the fps reliably
for all CEA/VESA formats. Hmm, pixelclock /total_framesizeshould always work, of course.We can add a flags field as well (for interlaced vs progressive and perhaps others such as
normal vs reduced blanking).That leaves the problem with GTF/CVT. I'll get back to that tomorrow. I have ideas, but
I need to discuss it first.Quoted 8 lines
Regards,
Hans
--
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
Quoted 3 lines
For fps you could use horizontal_line_freq/lines_per_frame.
However, all of the non-integer fps numbers I have seen in this email chain all seem to be multiples of 29.97002997 Hz. So maybe you could just use the closest integer rate with a flag labeled "
ntsc_bw_timing_hack" to indicate the fractional rates. :)
CEA-861 has some other timings that are not 60 Hz * 1000/1001. Yet, v4l2_fract is capable of handling any of such timings, as, whatever frequency taken, it needs to be a fractional number. Btw, even some userspace libraries prefer to represent fps using a fraction, instead of a float, to avoid rounding issues.
Quoted 4 lines
That 29.97 Hz number comes from the NTSC decision in 1953(!) to change the horizontal line freq to 4.5 MHz/286. Note that
(4.5 MHz/286)/525 = 30 * (1000/1001) = 29.97002997 Hz
One of the rationale for that decision was to avoid flicking issues with cathodic ray monitors and fluorescent lamps.
Quoted 1 line
It is interesting to see one of the most ingenious analog hacks in TV history (to achieve color and B&W backward compatabilty while staying in the 10% tolerance of the old B&W receivers) being codified in digital standards over 50 years later. It boggles the mind...
Yes. Bad (and good) API decisions will stay forever.
Cheers,
Mauro.
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Quoted 57 lines · Mauro Carvalho Chehab
Em 05-07-2011 16:02, Andy Walls escreveu:
Quoted 2 lines
Quoted 1 line · Hans Verkuil
I can work on the proposal this week for that. The only reason the
fps
Quoted 2 lines
Quoted 2 lines
hasn't been added
yet is that I never had the time to do the research on how torepresent
Quoted 9 lines
Quoted 9 lines
the fps reliably
for all CEA/VESA formats. Hmm, pixelclock /total_framesizeshould always work, of course.We can add a flags field as well (for interlaced vs progressive and perhaps others such as
normal vs reduced blanking).That leaves the problem with GTF/CVT. I'll get back to that
tomorrow. I
Quoted 8 lines
Quoted 8 lines
have ideas, but
I need to discuss it first.Regards,
Hans
--
To unsubscribe from this list: send the line "unsubscribelinux-media"
Quoted 7 lines
Quoted 3 lines
in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlFor fps you could use horizontal_line_freq/lines_per_frame.
However, all of the non-integer fps numbers I have seen in this email
chain all seem to be multiples of 29.97002997 Hz. So maybe you could just use the closest integer rate with a flag labeled "
ntsc_bw_timing_hack" to indicate the fractional rates. :)CEA-861 has some other timings that are not 60 Hz * 1000/1001. Yet,
v4l2_fract
is capable of handling any of such timings, as, whatever frequency taken, it
needs to be a fractional number. Btw, even some userspace libraries prefer to
represent fps using a fraction, instead of a float, to avoid rounding issues.Quoted 2 lines
That 29.97 Hz number comes from the NTSC decision in 1953(!) to
change the horizontal line freq to 4.5 MHz/286. Note that
Quoted 2 lines
(4.5 MHz/286)/525 = 30 * (1000/1001) = 29.97002997 Hz
One of the rationale for that decision was to avoid flicking issues with cathodic
ray monitors and fluorescent lamps.Quoted 1 line
It is interesting to see one of the most ingenious analog hacks in TV
Quoted 8 lines
history (to achieve color and B&W backward compatabilty while staying in the 10% tolerance of the old B&W receivers) being codified in digital standards over 50 years later. It boggles the mind...
Yes. Bad (and good) API decisions will stay forever.
Cheers,
Mauro.
Oops, yes I see the 60.054 Hz rate corresponds to a 262 line field (524 line frame) at the standard NTSC line rate.
Weird stuff.
Regards,
Andy
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
In reply to Hans VerkuilEm 05-07-2011 10:20, Hans Verkuil escreveu:
Quoted 9 lines
Quoted 4 lines
I failed to see what information is provided by the "presets" name. If this were removed from the ioctl, and fps would be added instead, the API would be clearer. The only adjustment would be to use "index" as the preset selection key. Anyway, it is too late for such change. We need to live with that.
Adding the fps solves nothing. Because that still does not give you specific timings. You can have 1920x1080P60 that has quite different timings from the CEA-861 standard and that may not be supported by a TV.
Quoted 6 lines
If you are working with HDMI, then you may want to filter all supported presets to those of the CEA standard.
That's one thing that is missing at the moment: that presets belonging to a certain standard get their own range. Since we only do CEA861 right now it hasn't been an issue, but it will.
I prepared a long email about that, but then I realized that we're investing our time into something broken, at the light of all DV timing standards. So, I've dropped it and started from scratch.
Quoted 1 line
From what I've got, there are some hardware that can only do a limited set of DV timings.
If this were not the case, we could simply just use the VIDIOC_S_DV_TIMINGS/VIDIOC_G_DV_TIMINGS, and put the CEA 861 and VESA timings into some userspace library.
In other words, the PRESET API is meant to solve the case where hardware only support a limited set of frequencies, that may or may not be inside the CEA standard.
Let's assume we never added the current API, and discuss how it would properly fulfill the user needs. An API that would likely work is:
struct v4l2_dv_enum_preset2 {
__u32 index;
__u8 name[32]; /* Name of the preset timing */
struct v4l2_fract fps;#define DV_PRESET_IS_PROGRESSIVE 1<<31
#define DV_PRESET_SPEC(flag) (flag && 0xff)
#define DV_PRESET_IS_CEA861 1
#define DV_PRESET_IS_DMT 2
#define DV_PRESET_IS_CVF 3
#define DV_PRESET_IS_GTF 4
#define DV_PRESET_IS_VENDOR_SPECIFIC 5
__u32 flags; /* Interlaced/progressive, DV specs, etc */
__u32 width; /* width in pixels */
__u32 height; /* height in lines */
__u32 polarities; /* Positive or negative polarity */
__u64 pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
__u32 hfrontporch; /* Horizpontal front porch in pixels */
__u32 hsync; /* Horizontal Sync length in pixels */
__u32 hbackporch; /* Horizontal back porch in pixels */
__u32 vfrontporch; /* Vertical front porch in pixels */
__u32 vsync; /* Vertical Sync length in lines */
__u32 vbackporch; /* Vertical back porch in lines */
__u32 il_vfrontporch; /* Vertical front porch for bottom field of
* interlaced field formats */
__u32 il_vsync; /* Vertical sync length for bottom field of
* interlaced field formats */
__u32 il_vbackporch; /* Vertical back porch for bottom field of
* interlaced field formats */
__u32 reserved[4];
};
#define VIDIOC_ENUM_DV_PRESETS2 _IOWR('V', 83, struct v4l2_dv_enum_preset2)
#define VIDIOC_S_DV_PRESET2 _IOWR('V', 84, u32 index)
#define VIDIOC_G_DV_PRESET2 _IOWR('V', 85, u32 index)
Such preset API seems to work for all cases. Userspace can use any DV timing information to select the desired format, and don't need to have a switch for a preset macro to try to guess what the format actually means. Also, there's no need to touch at the API spec every time a new DV timeline is needed.
Also, it should be noticed that, since the size of the data on the above definitions are different than the old ones, _IO macros will provide a different magic number, so, adding these won't break the existing API.
So, I think we should work on this proposal, and mark the existing one as deprecated.
Thanks,
Mauro
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Quoted 98 lines
Em 05-07-2011 10:20, Hans Verkuil escreveu:
Quoted 18 lines
Quoted 7 lines
I failed to see what information is provided by the "presets" name. If this were removed
from the ioctl, and fps would be added instead, the API would be clearer. The only
adjustment would be to use "index" as the preset selection key. Anyway, it is too late
for such change. We need to live with that.Adding the fps solves nothing. Because that still does not give you specific timings.
You can have 1920x1080P60 that has quite different timings from the CEA-861 standard
and that may not be supported by a TV.If you are working with HDMI, then you may want to filter all supported presets to
those of the CEA standard.Quoted 5 lines
That's one thing that is missing at the moment: that presets belonging to a certain
standard get their own range. Since we only do CEA861 right now it hasn't been an
issue, but it will.I prepared a long email about that, but then I realized that we're investing our time into
something broken, at the light of all DV timing standards. So, I've dropped it and
started from scratch.From what I've got, there are some hardware that can only do a limited set of DV timings.
If this were not the case, we could simply just use the VIDIOC_S_DV_TIMINGS/VIDIOC_G_DV_TIMINGS,
and put the CEA 861 and VESA timings into some userspace library.In other words, the PRESET API is meant to solve the case where hardware only support
a limited set of frequencies, that may or may not be inside the CEA standard.Let's assume we never added the current API, and discuss how it would properly fulfill
the user needs. An API that would likely work is:struct v4l2_dv_enum_preset2 { __u32 index; __u8 name[32]; /* Name of the preset timing */ struct v4l2_fract fps;#define
DV_PRESET_IS_PROGRESSIVE1<<31
#defineDV_PRESET_SPEC(flag)(flag &&0xff)
#defineDV_PRESET_IS_CEA8611
#defineDV_PRESET_IS_DMT2
#defineDV_PRESET_IS_CVF3
#defineDV_PRESET_IS_GTF4
#defineDV_PRESET_IS_VENDOR_SPECIFIC5
__u32flags; /* Interlaced/progressive, DV specs, etc */
__u32width; /* width in pixels */
__u32height; /* height in lines */
__u32polarities; /* Positive or negative polarity */
__u64pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
__u32hfrontporch; /* Horizpontal front porch in pixels */
__u32hsync; /* Horizontal Sync length in pixels */
__u32hbackporch; /* Horizontal back porch in pixels */
__u32vfrontporch; /* Vertical front porch in pixels */
__u32vsync; /* Vertical Sync length in lines */
__u32vbackporch; /* Vertical back porch in lines */
__u32il_vfrontporch; /* Vertical front porch for bottom field of
* interlaced field formats */
__u32il_vsync; /* Vertical sync length for bottom field of
* interlaced field formats */
__u32il_vbackporch; /* Vertical back porch for bottom field of
* interlaced field formats */
__u32reserved[4];
};#define
VIDIOC_ENUM_DV_PRESETS2_IOWR('V', 83, structv4l2_dv_enum_preset2)
#defineVIDIOC_S_DV_PRESET2_IOWR('V', 84, u32 index)
#defineVIDIOC_G_DV_PRESET2_IOWR('V', 85, u32 index)Such preset API seems to work for all cases. Userspace can use any DV timing
information to select the desired format, and don't need to have a switch for
a preset macro to try to guess what the format actually means. Also, there's no
need to touch at the API spec every time a new DV timeline is needed.
Quoted 8 lines
Also, it should be noticed that, since the size of the data on the above definitions
are different than the old ones,_IOmacros will provide a different magic number,
so, adding these won't break the existing API.So, I think we should work on this proposal, and mark the existing one as deprecated.
This proposal makes it very hard for applications to directly select a format like 720p50 because the indices can change at any time. I think this is a very desirable feature, particularly for apps running on embedded systems where the hardware is known. This was one of the design considerations at the time this API was made.
But looking at this I wonder if we shouldn't just make a VIDIOC_G_PRESET_TIMINGS function? You give it the preset ID and you get all the timing information back. No need to deprecate anything. I'm not even sure if with this change we need to modify struct v4l2_dv_enum_preset as I proposed in my RFC, although I think we should.
Regards,
Hans
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Em 06-07-2011 08:31, Hans Verkuil escreveu:
Quoted 104 lines
Quoted 104 lines
Em 05-07-2011 10:20, Hans Verkuil escreveu:
Quoted 18 lines
Quoted 7 lines
I failed to see what information is provided by the "presets" name. If this were removed
from the ioctl, and fps would be added instead, the API would be clearer. The only
adjustment would be to use "index" as the preset selection key. Anyway, it is too late
for such change. We need to live with that.Adding the fps solves nothing. Because that still does not give you specific timings.
You can have 1920x1080P60 that has quite different timings from the CEA-861 standard
and that may not be supported by a TV.If you are working with HDMI, then you may want to filter all supported presets to
those of the CEA standard.Quoted 5 lines
That's one thing that is missing at the moment: that presets belonging to a certain
standard get their own range. Since we only do CEA861 right now it hasn't been an
issue, but it will.I prepared a long email about that, but then I realized that we're investing our time into
something broken, at the light of all DV timing standards. So, I've dropped it and
started from scratch.From what I've got, there are some hardware that can only do a limited set of DV timings.
If this were not the case, we could simply just use the VIDIOC_S_DV_TIMINGS/VIDIOC_G_DV_TIMINGS,
and put the CEA 861 and VESA timings into some userspace library.In other words, the PRESET API is meant to solve the case where hardware only support
a limited set of frequencies, that may or may not be inside the CEA standard.Let's assume we never added the current API, and discuss how it would properly fulfill
the user needs. An API that would likely work is:struct v4l2_dv_enum_preset2 { __u32 index; __u8 name[32]; /* Name of the preset timing */ struct v4l2_fract fps;#define
DV_PRESET_IS_PROGRESSIVE1<<31
#defineDV_PRESET_SPEC(flag)(flag &&0xff)
#defineDV_PRESET_IS_CEA8611
#defineDV_PRESET_IS_DMT2
#defineDV_PRESET_IS_CVF3
#defineDV_PRESET_IS_GTF4
#defineDV_PRESET_IS_VENDOR_SPECIFIC5
__u32flags; /* Interlaced/progressive, DV specs, etc */
__u32width; /* width in pixels */
__u32height; /* height in lines */
__u32polarities; /* Positive or negative polarity */
__u64pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
__u32hfrontporch; /* Horizpontal front porch in pixels */
__u32hsync; /* Horizontal Sync length in pixels */
__u32hbackporch; /* Horizontal back porch in pixels */
__u32vfrontporch; /* Vertical front porch in pixels */
__u32vsync; /* Vertical Sync length in lines */
__u32vbackporch; /* Vertical back porch in lines */
__u32il_vfrontporch; /* Vertical front porch for bottom field of
* interlaced field formats */
__u32il_vsync; /* Vertical sync length for bottom field of
* interlaced field formats */
__u32il_vbackporch; /* Vertical back porch for bottom field of
* interlaced field formats */
__u32reserved[4];
};#define
VIDIOC_ENUM_DV_PRESETS2_IOWR('V', 83, structv4l2_dv_enum_preset2)
#defineVIDIOC_S_DV_PRESET2_IOWR('V', 84, u32 index)
#defineVIDIOC_G_DV_PRESET2_IOWR('V', 85, u32 index)Such preset API seems to work for all cases. Userspace can use any DV timing
information to select the desired format, and don't need to have a switch for
a preset macro to try to guess what the format actually means. Also, there's no
need to touch at the API spec every time a new DV timeline is needed.Also, it should be noticed that, since the size of the data on the above definitions
are different than the old ones,_IOmacros will provide a different magic number,
so, adding these won't break the existing API.
Quoted 5 lines
Quoted 2 lines
So, I think we should work on this proposal, and mark the existing one as deprecated.
This proposal makes it very hard for applications to directly select a format like 720p50 because the indices can change at any time.
Why? All the application needs to do is to call VIDIOC_ENUM_DV_PRESETS2, check what line it wants, and do a S_DV_PRESET2, just like any other place where V4L2 defines an ENUM function.
The enum won't change during application runtime, so, they can be stored if the application would need to switch to other formats latter.
Quoted 4 lines
I think
this is a very desirable feature, particularly for apps running on embedded systems where the hardware is known. This was one of the design considerations at the time this API was made.
This is a very weak argument. With just one ENUM loop, the application can quickly get the right format(s), and associate them with any internal namespace.
Quoted 5 lines
But looking at this I wonder if we shouldn't just make a
VIDIOC_G_PRESET_TIMINGSfunction? You give it the preset ID and you get all the timing information back. No need to deprecate anything. I'm not even sure if with this change we need to modify structv4l2_dv_enum_presetas I proposed in my RFC, although I think we should.
Won't solve the issue: one new #define is needed for each video timing, namespaces will be confusing, no support for VESA GVF/ VESA CVT timings (or worse: we'll end by having thousands of formats at the end of the day), instead of just one ENUM ioctl, an extra ioctl will be required for each returned value, etc.
Cheers,
Mauro.
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Quoted 99 lines · On Wednesday 06 July 2011 13:48:35 Mauro Carvalho Chehab wrote:
Em 06-07-2011 08:31, Hans Verkuil escreveu:
Quoted 98 lines
Quoted 97 lines
Em 05-07-2011 10:20, Hans Verkuil escreveu:
Quoted 10 lines
Quoted 5 lines
I failed to see what information is provided by the "presets" name. If this were removed from the ioctl, and fps would be added instead, the API would be clearer. The only adjustment would be to use "index" as the preset selection key. Anyway, it is too late for such change. We need to live with that.
Adding the fps solves nothing. Because that still does not give you specific timings. You can have 1920x1080P60 that has quite different timings from the CEA-861 standard and that may not be supported by a TV.
Quoted 6 lines
If you are working with HDMI, then you may want to filter all supported presets to those of the CEA standard.
That's one thing that is missing at the moment: that presets belonging to a certain standard get their own range. Since we only do CEA861 right now it hasn't been an issue, but it will.
I prepared a long email about that, but then I realized that we're investing our time intosomething broken, at the light of all DV timing standards. So, I've dropped it and started from scratch.
From what I've got, there are some hardware that can only do a limited set of DV timings. If this were not the case, we could simply just use the VIDIOC_S_DV_TIMINGS/VIDIOC_G_DV_TIMINGS, and put the CEA 861 and VESA timings into some userspace library.
In other words, the PRESET API is meant to solve the case where hardware only support a limited set of frequencies, that may or may not be inside the CEA standard.
Let's assume we never added the current API, and discuss how it would properly fulfill the user needs. An API that would likely work is:
struct
v4l2_dv_enum_preset2{__u32 index; __u8 name[32]; /* Name of the preset timing */ struct v4l2_fract fps;#define
DV_PRESET_IS_PROGRESSIVE1<<31
#defineDV_PRESET_SPEC(flag)(flag &&0xff)
#defineDV_PRESET_IS_CEA8611
#defineDV_PRESET_IS_DMT2
#defineDV_PRESET_IS_CVF3
#defineDV_PRESET_IS_GTF4
#defineDV_PRESET_IS_VENDOR_SPECIFIC5
__u32flags; /* Interlaced/progressive, DV specs, etc */
__u32width; /* width in pixels */
__u32height; /* height in lines */
__u32polarities; /* Positive or negative polarity */
__u64pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
__u32hfrontporch; /* Horizpontal front porch in pixels */
__u32hsync; /* Horizontal Sync length in pixels */
__u32hbackporch; /* Horizontal back porch in pixels */
__u32vfrontporch; /* Vertical front porch in pixels */
__u32vsync; /* Vertical Sync length in lines */
__u32vbackporch; /* Vertical back porch in lines */
__u32il_vfrontporch; /* Vertical front porch for bottom field of* interlaced field formats */
__u32il_vsync; /* Vertical sync length for bottom field of* interlaced field formats */
__u32il_vbackporch; /* Vertical back porch for bottom field of* interlaced field formats */
__u32reserved[4];};
#define
VIDIOC_ENUM_DV_PRESETS2_IOWR('V', 83, structv4l2_dv_enum_preset2)
#defineVIDIOC_S_DV_PRESET2_IOWR('V', 84, u32 index)
#defineVIDIOC_G_DV_PRESET2_IOWR('V', 85, u32 index)Such preset API seems to work for all cases. Userspace can use any DV timing information to select the desired format, and don't need to have a switch for a preset macro to try to guess what the format actually means. Also, there's no need to touch at the API spec every time a new DV timeline is needed.
Also, it should be noticed that, since the size of the data on the above definitions are different than the old ones,
_IOmacros will provide a different magic number, so, adding these won't break the existing API.So, I think we should work on this proposal, and mark the existing one as deprecated.
Quoted 6 lines
Quoted 2 lines
This proposal makes it very hard for applications to directly select a format like 720p50 because the indices can change at any time.
Why? All the application needs to do is to call
VIDIOC_ENUM_DV_PRESETS2, check what line it wants, and do aS_DV_PRESET2, just like any other place where V4L2 defines an ENUM function.
Forcing applications to enumerate all presets when they already know what preset they want doesn't seem like a very good solution to me.
Quoted 23 lines
The enum won't change during application runtime, so, they can be stored if the application would need to switch to other formats latter.
Quoted 3 lines
I think this is a very desirable feature, particularly for apps running on embedded systems where the hardware is known. This was one of the design considerations at the time this API was made.
This is a very weak argument. With just one ENUM loop, the application can quickly get the right format(s), and associate them with any internal namespace.
Quoted 5 lines
But looking at this I wonder if we shouldn't just make a
VIDIOC_G_PRESET_TIMINGSfunction? You give it the preset ID and you get all the timing information back. No need to deprecate anything. I'm not even sure if with this change we need to modify structv4l2_dv_enum_presetas I proposed in my RFC, although I think we should.Won't solve the issue: one new #define is needed for each video timing, namespaces will be confusing, no support for VESA GVF/ VESA CVT timings (or worse: we'll end by having thousands of formats at the end of the day), instead of just one ENUM ioctl, an extra ioctl will be required for each returned value, etc.
Signature · 3 lines
Regards, Laurent Pinchart
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Em 06-07-2011 09:03, Laurent Pinchart escreveu:
Quoted 103 lines · On Wednesday 06 July 2011 13:48:35 Mauro Carvalho Chehab wrote:
Quoted 102 lines
Em 06-07-2011 08:31, Hans Verkuil escreveu:
Quoted 100 lines
Quoted 91 lines
Em 05-07-2011 10:20, Hans Verkuil escreveu:
Quoted 10 lines
Quoted 5 lines
I failed to see what information is provided by the "presets" name. If this were removed from the ioctl, and fps would be added instead, the API would be clearer. The only adjustment would be to use "index" as the preset selection key. Anyway, it is too late for such change. We need to live with that.
Adding the fps solves nothing. Because that still does not give you specific timings. You can have 1920x1080P60 that has quite different timings from the CEA-861 standard and that may not be supported by a TV.
Quoted 6 lines
If you are working with HDMI, then you may want to filter all supported presets to those of the CEA standard.
That's one thing that is missing at the moment: that presets belonging to a certain standard get their own range. Since we only do CEA861 right now it hasn't been an issue, but it will.
I prepared a long email about that, but then I realized that we're investing our time intosomething broken, at the light of all DV timing standards. So, I've dropped it and started from scratch.
From what I've got, there are some hardware that can only do a limited set of DV timings. If this were not the case, we could simply just use the VIDIOC_S_DV_TIMINGS/VIDIOC_G_DV_TIMINGS, and put the CEA 861 and VESA timings into some userspace library.
In other words, the PRESET API is meant to solve the case where hardware only support a limited set of frequencies, that may or may not be inside the CEA standard.
Let's assume we never added the current API, and discuss how it would properly fulfill the user needs. An API that would likely work is:
struct
v4l2_dv_enum_preset2{__u32 index; __u8 name[32]; /* Name of the preset timing */ struct v4l2_fract fps;#define
DV_PRESET_IS_PROGRESSIVE1<<31
#defineDV_PRESET_SPEC(flag)(flag &&0xff)
#defineDV_PRESET_IS_CEA8611
#defineDV_PRESET_IS_DMT2
#defineDV_PRESET_IS_CVF3
#defineDV_PRESET_IS_GTF4
#defineDV_PRESET_IS_VENDOR_SPECIFIC5
__u32flags; /* Interlaced/progressive, DV specs, etc */
__u32width; /* width in pixels */
__u32height; /* height in lines */
__u32polarities; /* Positive or negative polarity */
__u64pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
__u32hfrontporch; /* Horizpontal front porch in pixels */
__u32hsync; /* Horizontal Sync length in pixels */
__u32hbackporch; /* Horizontal back porch in pixels */
__u32vfrontporch; /* Vertical front porch in pixels */
__u32vsync; /* Vertical Sync length in lines */
__u32vbackporch; /* Vertical back porch in lines */
__u32il_vfrontporch; /* Vertical front porch for bottom field of* interlaced field formats */
__u32il_vsync; /* Vertical sync length for bottom field of* interlaced field formats */
__u32il_vbackporch; /* Vertical back porch for bottom field of* interlaced field formats */
__u32reserved[4];};
#define
VIDIOC_ENUM_DV_PRESETS2_IOWR('V', 83, structv4l2_dv_enum_preset2)
#defineVIDIOC_S_DV_PRESET2_IOWR('V', 84, u32 index)
#defineVIDIOC_G_DV_PRESET2_IOWR('V', 85, u32 index)Such preset API seems to work for all cases. Userspace can use any DV timing information to select the desired format, and don't need to have a switch for a preset macro to try to guess what the format actually means. Also, there's no need to touch at the API spec every time a new DV timeline is needed.
Quoted 6 lines
Also, it should be noticed that, since the size of the data on the above definitions are different than the old ones,
_IOmacros will provide a different magic number, so, adding these won't break the existing API.So, I think we should work on this proposal, and mark the existing one as deprecated.
This proposal makes it very hard for applications to directly select a format like 720p50 because the indices can change at any time.
Quoted 6 lines
Quoted 3 lines
Why? All the application needs to do is to call
VIDIOC_ENUM_DV_PRESETS2, check what line it wants, and do aS_DV_PRESET2, just like any other place where V4L2 defines an ENUM function.Forcing applications to enumerate all presets when they already know what preset they want doesn't seem like a very good solution to me.
If the app already know, it might simply do VIDIOC_S_DV_PRESET2(index). This would work for an embedded hardware. The only care to be taken is to change the index number if the Kernel changes, or to be sure that, on the embedded tree, that newer DV lines will be added only after the previous one.
Anyway, a broken API cannot be justified by a weak argument that not needing to do an ENUM will save a few nanosseconds for some embedded hardware during application initialization time.
Mauro.
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Quoted 119 lines · On Wednesday 06 July 2011 14:09:38 Mauro Carvalho Chehab wrote:
Em 06-07-2011 09:03, Laurent Pinchart escreveu:
Quoted 105 lines · On Wednesday 06 July 2011 13:48:35 Mauro Carvalho Chehab wrote:
Quoted 104 lines
Em 06-07-2011 08:31, Hans Verkuil escreveu:
Quoted 102 lines
Quoted 92 lines
Em 05-07-2011 10:20, Hans Verkuil escreveu:
Quoted 11 lines
Quoted 5 lines
I failed to see what information is provided by the "presets" name. If this were removed from the ioctl, and fps would be added instead, the API would be clearer. The only adjustment would be to use "index" as the preset selection key. Anyway, it is too late for such change. We need to live with that.
Adding the fps solves nothing. Because that still does not give you specific timings. You can have 1920x1080P60 that has quite different timings from the CEA-861 standard and that may not be supported by a TV.
Quoted 6 lines
If you are working with HDMI, then you may want to filter all supported presets to those of the CEA standard.
That's one thing that is missing at the moment: that presets belonging to a certain standard get their own range. Since we only do CEA861 right now it hasn't been an issue, but it will.
I prepared a long email about that, but then I realized that we're investing our time intosomething broken, at the light of all DV timing standards. So, I've dropped it and started from scratch.
From what I've got, there are some hardware that can only do a limited set of DV timings. If this were not the case, we could simply just use the VIDIOC_S_DV_TIMINGS/VIDIOC_G_DV_TIMINGS, and put the CEA 861 and VESA timings into some userspace library.
In other words, the PRESET API is meant to solve the case where hardware only support a limited set of frequencies, that may or may not be inside the CEA standard.
Let's assume we never added the current API, and discuss how it would properly fulfill the user needs. An API that would likely work is:
struct
v4l2_dv_enum_preset2{__u32 index; __u8 name[32]; /* Name of the preset timing */ struct v4l2_fract fps;#define
DV_PRESET_IS_PROGRESSIVE1<<31
#defineDV_PRESET_SPEC(flag)(flag &&0xff)
#defineDV_PRESET_IS_CEA8611
#defineDV_PRESET_IS_DMT2
#defineDV_PRESET_IS_CVF3
#defineDV_PRESET_IS_GTF4
#defineDV_PRESET_IS_VENDOR_SPECIFIC5
__u32flags; /* Interlaced/progressive, DV specs, etc */
__u32width; /* width in pixels */
__u32height; /* height in lines */
__u32polarities; /* Positive or negative polarity */
__u64pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
__u32hfrontporch; /* Horizpontal front porch in pixels */
__u32hsync; /* Horizontal Sync length in pixels */
__u32hbackporch; /* Horizontal back porch in pixels */
__u32vfrontporch; /* Vertical front porch in pixels */
__u32vsync; /* Vertical Sync length in lines */
__u32vbackporch; /* Vertical back porch in lines */
__u32il_vfrontporch; /* Vertical front porch for bottom field of* interlaced field formats */
__u32il_vsync; /* Vertical sync length for bottom field of* interlaced field formats */
__u32il_vbackporch; /* Vertical back porch for bottom field of* interlaced field formats */
__u32reserved[4];};
#define
VIDIOC_ENUM_DV_PRESETS2_IOWR('V', 83, structv4l2_dv_enum_preset2)
#defineVIDIOC_S_DV_PRESET2_IOWR('V', 84, u32 index)
#defineVIDIOC_G_DV_PRESET2_IOWR('V', 85, u32 index)Such preset API seems to work for all cases. Userspace can use any DV timing information to select the desired format, and don't need to have a switch for a preset macro to try to guess what the format actually means. Also, there's no need to touch at the API spec every time a new DV timeline is needed.
Quoted 7 lines
Also, it should be noticed that, since the size of the data on the above definitions are different than the old ones,
_IOmacros will provide a different magic number, so, adding these won't break the existing API.So, I think we should work on this proposal, and mark the existing one as deprecated.
This proposal makes it very hard for applications to directly select a format like 720p50 because the indices can change at any time.
Quoted 6 lines
Quoted 3 lines
Why? All the application needs to do is to call
VIDIOC_ENUM_DV_PRESETS2, check what line it wants, and do aS_DV_PRESET2, just like any other place where V4L2 defines an ENUM function.Forcing applications to enumerate all presets when they already know what preset they want doesn't seem like a very good solution to me.
If the app already know, it might simply do
VIDIOC_S_DV_PRESET2(index). This would work for an embedded hardware. The only care to be taken is to change the index number if the Kernel changes, or to be sure that, on the embedded tree, that newer DV lines will be added only after the previous one.
Quoted 3 lines
Anyway, a broken API cannot be justified by a weak argument that not needing to do an ENUM will save a few nanosseconds for some embedded hardware during application initialization time.
We're talking about dozens of syscalls, not a couple of nanoseconds.
Signature · 3 lines
Regards, Laurent Pinchart
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Em 06-07-2011 09:13, Laurent Pinchart escreveu:
Quoted 120 lines · On Wednesday 06 July 2011 14:09:38 Mauro Carvalho Chehab wrote:
Quoted 119 lines
Em 06-07-2011 09:03, Laurent Pinchart escreveu:
Quoted 105 lines · On Wednesday 06 July 2011 13:48:35 Mauro Carvalho Chehab wrote:
Quoted 104 lines
Em 06-07-2011 08:31, Hans Verkuil escreveu:
Quoted 102 lines
Quoted 92 lines
Em 05-07-2011 10:20, Hans Verkuil escreveu:
Quoted 11 lines
Quoted 5 lines
I failed to see what information is provided by the "presets" name. If this were removed from the ioctl, and fps would be added instead, the API would be clearer. The only adjustment would be to use "index" as the preset selection key. Anyway, it is too late for such change. We need to live with that.
Adding the fps solves nothing. Because that still does not give you specific timings. You can have 1920x1080P60 that has quite different timings from the CEA-861 standard and that may not be supported by a TV.
Quoted 6 lines
If you are working with HDMI, then you may want to filter all supported presets to those of the CEA standard.
That's one thing that is missing at the moment: that presets belonging to a certain standard get their own range. Since we only do CEA861 right now it hasn't been an issue, but it will.
I prepared a long email about that, but then I realized that we're investing our time intosomething broken, at the light of all DV timing standards. So, I've dropped it and started from scratch.
From what I've got, there are some hardware that can only do a limited set of DV timings. If this were not the case, we could simply just use the VIDIOC_S_DV_TIMINGS/VIDIOC_G_DV_TIMINGS, and put the CEA 861 and VESA timings into some userspace library.
In other words, the PRESET API is meant to solve the case where hardware only support a limited set of frequencies, that may or may not be inside the CEA standard.
Let's assume we never added the current API, and discuss how it would properly fulfill the user needs. An API that would likely work is:
struct
v4l2_dv_enum_preset2{__u32 index; __u8 name[32]; /* Name of the preset timing */ struct v4l2_fract fps;#define
DV_PRESET_IS_PROGRESSIVE1<<31
#defineDV_PRESET_SPEC(flag)(flag &&0xff)
#defineDV_PRESET_IS_CEA8611
#defineDV_PRESET_IS_DMT2
#defineDV_PRESET_IS_CVF3
#defineDV_PRESET_IS_GTF4
#defineDV_PRESET_IS_VENDOR_SPECIFIC5
__u32flags; /* Interlaced/progressive, DV specs, etc */
__u32width; /* width in pixels */
__u32height; /* height in lines */
__u32polarities; /* Positive or negative polarity */
__u64pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
__u32hfrontporch; /* Horizpontal front porch in pixels */
__u32hsync; /* Horizontal Sync length in pixels */
__u32hbackporch; /* Horizontal back porch in pixels */
__u32vfrontporch; /* Vertical front porch in pixels */
__u32vsync; /* Vertical Sync length in lines */
__u32vbackporch; /* Vertical back porch in lines */
__u32il_vfrontporch; /* Vertical front porch for bottom field of* interlaced field formats */
__u32il_vsync; /* Vertical sync length for bottom field of* interlaced field formats */
__u32il_vbackporch; /* Vertical back porch for bottom field of* interlaced field formats */
__u32reserved[4];};
#define
VIDIOC_ENUM_DV_PRESETS2_IOWR('V', 83, structv4l2_dv_enum_preset2)
#defineVIDIOC_S_DV_PRESET2_IOWR('V', 84, u32 index)
#defineVIDIOC_G_DV_PRESET2_IOWR('V', 85, u32 index)Such preset API seems to work for all cases. Userspace can use any DV timing information to select the desired format, and don't need to have a switch for a preset macro to try to guess what the format actually means. Also, there's no need to touch at the API spec every time a new DV timeline is needed.
Quoted 7 lines
Also, it should be noticed that, since the size of the data on the above definitions are different than the old ones,
_IOmacros will provide a different magic number, so, adding these won't break the existing API.So, I think we should work on this proposal, and mark the existing one as deprecated.
This proposal makes it very hard for applications to directly select a format like 720p50 because the indices can change at any time.
Quoted 6 lines
Quoted 3 lines
Why? All the application needs to do is to call
VIDIOC_ENUM_DV_PRESETS2, check what line it wants, and do aS_DV_PRESET2, just like any other place where V4L2 defines an ENUM function.Forcing applications to enumerate all presets when they already know what preset they want doesn't seem like a very good solution to me.
If the app already know, it might simply do
VIDIOC_S_DV_PRESET2(index). This would work for an embedded hardware. The only care to be taken is to change the index number if the Kernel changes, or to be sure that, on the embedded tree, that newer DV lines will be added only after the previous one.
Quoted 5 lines
Quoted 3 lines
Anyway, a broken API cannot be justified by a weak argument that not needing to do an ENUM will save a few nanosseconds for some embedded hardware during application initialization time.
We're talking about dozens of syscalls, not a couple of nanoseconds.
hundreds of nanoseconds? Those systemcalls are just reading a table, and, once the right standard is selected, application can stop the loop. The current tables have up to 18 DV formats. I doubt that it would affect application performance on any way.
The old ir-keytable used to do 128.000 system calls to cleanup the IR table and add a new one, due to an API limitation. It were capable of doing that on fractions of a second.
Mauro.
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
In reply to Mauro Carvalho ChehabQuoted 117 lines
Em 06-07-2011 08:31, Hans Verkuil escreveu:
Quoted 116 lines
Quoted 115 lines
Em 05-07-2011 10:20, Hans Verkuil escreveu:
Quoted 21 lines
Quoted 9 lines
I failed to see what information is provided by the "presets" name. If
this were removed
from the ioctl, and fps would be added instead, the API would be clearer. The only
adjustment would be to use "index" as the preset selection key. Anyway,
it is too late
for such change. We need to live with that.Adding the fps solves nothing. Because that still does not give you specific timings.
You can have 1920x1080P60 that has quite different timings from the CEA-861 standard
and that may not be supported by a TV.If you are working with HDMI, then you may want to filter all supported
presets to
those of the CEA standard.Quoted 5 lines
That's one thing that is missing at the moment: that presets belonging to a certain
standard get their own range. Since we only do CEA861 right now it hasn't been an
issue, but it will.I prepared a long email about that, but then I realized that we're investing our time into
something broken, at the light of all DV timing standards. So, I've dropped it and
started from scratch.From what I've got, there are some hardware that can only do a limited set
of DV timings.
If this were not the case, we could simply just use the VIDIOC_S_DV_TIMINGS/VIDIOC_G_DV_TIMINGS,
and put the CEA 861 and VESA timings into some userspace library.In other words, the PRESET API is meant to solve the case where hardware
only support
a limited set of frequencies, that may or may not be inside the CEA standard.Let's assume we never added the current API, and discuss how it would properly fulfill
the user needs. An API that would likely work is:struct v4l2_dv_enum_preset2 { __u32 index; __u8 name[32]; /* Name of the preset timing */ struct v4l2_fract fps;#define
DV_PRESET_IS_PROGRESSIVE1<<31
#defineDV_PRESET_SPEC(flag)(flag &&0xff)
#defineDV_PRESET_IS_CEA8611
#defineDV_PRESET_IS_DMT2
#defineDV_PRESET_IS_CVF3
#defineDV_PRESET_IS_GTF4
#defineDV_PRESET_IS_VENDOR_SPECIFIC5
__u32flags; /* Interlaced/progressive, DV specs, etc */
__u32width; /* width in pixels */
__u32height; /* height in lines */
__u32polarities; /* Positive or negative polarity */
__u64pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
__u32hfrontporch; /* Horizpontal front porch in pixels */
__u32hsync; /* Horizontal Sync length in pixels */
__u32hbackporch; /* Horizontal back porch in pixels */
__u32vfrontporch; /* Vertical front porch in pixels */
__u32vsync; /* Vertical Sync length in lines */
__u32vbackporch; /* Vertical back porch in lines */
__u32il_vfrontporch; /* Vertical front porch for bottom field of
* interlaced field formats */
__u32il_vsync; /* Vertical sync length for bottom field of
* interlaced field formats */
__u32il_vbackporch; /* Vertical back porch for bottom field of
* interlaced field formats */
__u32reserved[4];
};#define
VIDIOC_ENUM_DV_PRESETS2_IOWR('V', 83, structv4l2_dv_enum_preset2)
#defineVIDIOC_S_DV_PRESET2_IOWR('V', 84, u32 index)
#defineVIDIOC_G_DV_PRESET2_IOWR('V', 85, u32 index)Such preset API seems to work for all cases. Userspace can use any DV timing
information to select the desired format, and don't need to have a switch
for
a preset macro to try to guess what the format actually means. Also, there's no
need to touch at the API spec every time a new DV timeline is needed.Also, it should be noticed that, since the size of the data on the above
definitions
are different than the old ones,_IOmacros will provide a different magic
number,
so, adding these won't break the existing API.So, I think we should work on this proposal, and mark the existing one as
deprecated.
Quoted 5 lines
Quoted 2 lines
This proposal makes it very hard for applications to directly select a format like 720p50 because the indices can change at any time.
Why? All the application needs to do is to call
VIDIOC_ENUM_DV_PRESETS2, check what line it wants,
It's not so easy as you think to find the right timings: you have to check many parameters to be certain you have the right one and not some subtle variation.
Quoted 6 lines
and do a
S_DV_PRESET2, just like any other place
where V4L2 defines an ENUM function.The enum won't change during application runtime, so, they can be stored if the application would need to switch to other formats latter.
Quoted 8 lines
Quoted 4 lines
I think
this is a very desirable feature, particularly for apps running on embedded systems where the hardware is known. This was one of the design considerations at the time this API was made.This is a very weak argument. With just one ENUM loop, the application can quickly get the right format(s), and associate them with any internal namespace.
That actually isn't easy at all.
Quoted 7 lines
Quoted 6 lines
But looking at this I wonder if we shouldn't just make a
VIDIOC_G_PRESET_TIMINGSfunction? You give it the preset ID and you get all the timing information back. No need to deprecate anything. I'm not even sure if with this change we need to modify structv4l2_dv_enum_preset
as I proposed in my RFC, although I think we should.
Quoted 6 lines
Won't solve the issue: one new #define is needed for each video timing, namespaces will be confusing, no support for VESA GVF/ VESA CVT timings (or worse: we'll end by having thousands of formats at the end of the day),
instead of just one ENUM ioctl, an extra ioctl will be required for each returned value, etc.
Presets for GTF/CVT are useless (and I have never seen hardware that has such presets). In practice you have CEA and DMT presets and nothing else.
We may need to add PRESET_PRIVATE (just like we do for controls) should we get non-CEA/DMT formats as well. There is no point in having specific preset defines for those IMHO.
I see very little advantage in throwing away an API that works quite well in practice only to add a new one that isn't much better IMO. Instead we can easily improve the existing API.
I *want* to be able to specify the most common CEA/DMT standards directly and unambiguously through presets. It is very easy and nice to use in practice. Once you go into the realm of GTF/CVT, then the preset API is too limited and G/S_DV_TIMINGS need to be used, but that requires much more effort on the part of the application.
I hope others will pitch in as well with their opinions.
Regards,
Hans
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Em 06-07-2011 09:14, Hans Verkuil escreveu:
Quoted 120 lines
Quoted 120 lines
Em 06-07-2011 08:31, Hans Verkuil escreveu:
Quoted 118 lines
Quoted 112 lines
Em 05-07-2011 10:20, Hans Verkuil escreveu:
Quoted 21 lines
Quoted 9 lines
I failed to see what information is provided by the "presets" name. If
this were removed
from the ioctl, and fps would be added instead, the API would be clearer. The only
adjustment would be to use "index" as the preset selection key. Anyway,
it is too late
for such change. We need to live with that.Adding the fps solves nothing. Because that still does not give you specific timings.
You can have 1920x1080P60 that has quite different timings from the CEA-861 standard
and that may not be supported by a TV.If you are working with HDMI, then you may want to filter all supported
presets to
those of the CEA standard.Quoted 5 lines
That's one thing that is missing at the moment: that presets belonging to a certain
standard get their own range. Since we only do CEA861 right now it hasn't been an
issue, but it will.I prepared a long email about that, but then I realized that we're investing our time into
something broken, at the light of all DV timing standards. So, I've dropped it and
started from scratch.From what I've got, there are some hardware that can only do a limited set
of DV timings.
If this were not the case, we could simply just use the VIDIOC_S_DV_TIMINGS/VIDIOC_G_DV_TIMINGS,
and put the CEA 861 and VESA timings into some userspace library.In other words, the PRESET API is meant to solve the case where hardware
only support
a limited set of frequencies, that may or may not be inside the CEA standard.Let's assume we never added the current API, and discuss how it would properly fulfill
the user needs. An API that would likely work is:struct v4l2_dv_enum_preset2 { __u32 index; __u8 name[32]; /* Name of the preset timing */ struct v4l2_fract fps;#define
DV_PRESET_IS_PROGRESSIVE1<<31
#defineDV_PRESET_SPEC(flag)(flag &&0xff)
#defineDV_PRESET_IS_CEA8611
#defineDV_PRESET_IS_DMT2
#defineDV_PRESET_IS_CVF3
#defineDV_PRESET_IS_GTF4
#defineDV_PRESET_IS_VENDOR_SPECIFIC5
__u32flags; /* Interlaced/progressive, DV specs, etc */
__u32width; /* width in pixels */
__u32height; /* height in lines */
__u32polarities; /* Positive or negative polarity */
__u64pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
__u32hfrontporch; /* Horizpontal front porch in pixels */
__u32hsync; /* Horizontal Sync length in pixels */
__u32hbackporch; /* Horizontal back porch in pixels */
__u32vfrontporch; /* Vertical front porch in pixels */
__u32vsync; /* Vertical Sync length in lines */
__u32vbackporch; /* Vertical back porch in lines */
__u32il_vfrontporch; /* Vertical front porch for bottom field of
* interlaced field formats */
__u32il_vsync; /* Vertical sync length for bottom field of
* interlaced field formats */
__u32il_vbackporch; /* Vertical back porch for bottom field of
* interlaced field formats */
__u32reserved[4];
};#define
VIDIOC_ENUM_DV_PRESETS2_IOWR('V', 83, structv4l2_dv_enum_preset2)
#defineVIDIOC_S_DV_PRESET2_IOWR('V', 84, u32 index)
#defineVIDIOC_G_DV_PRESET2_IOWR('V', 85, u32 index)Such preset API seems to work for all cases. Userspace can use any DV timing
information to select the desired format, and don't need to have a switch
for
a preset macro to try to guess what the format actually means. Also, there's no
need to touch at the API spec every time a new DV timeline is needed.Also, it should be noticed that, since the size of the data on the above
definitions
are different than the old ones,_IOmacros will provide a different magic
number,
so, adding these won't break the existing API.Quoted 3 lines
So, I think we should work on this proposal, and mark the existing one as
deprecated.This proposal makes it very hard for applications to directly select a format like 720p50 because the indices can change at any time.
Quoted 6 lines
Quoted 2 lines
Why? All the application needs to do is to call
VIDIOC_ENUM_DV_PRESETS2, check what line it wants,It's not so easy as you think to find the right timings: you have to check many parameters to be certain you have the right one and not some subtle variation.
Or you can do a strcmp(v4l2_dv_enum_preset2.name,"my preset").
Quoted 11 lines
Quoted 11 lines
and do a
S_DV_PRESET2, just like any other place
where V4L2 defines an ENUM function.The enum won't change during application runtime, so, they can be stored if the application would need to switch to other formats latter.
Quoted 4 lines
I think
this is a very desirable feature, particularly for apps running on embedded systems where the hardware is known. This was one of the design considerations at the time this API was made.
Quoted 5 lines
Quoted 3 lines
This is a very weak argument. With just one ENUM loop, the application can quickly get the right format(s), and associate them with any internal namespace.
That actually isn't easy at all.
???
Quoted 14 lines
Quoted 7 lines
Quoted 6 lines
But looking at this I wonder if we shouldn't just make a
VIDIOC_G_PRESET_TIMINGSfunction? You give it the preset ID and you get all the timing information back. No need to deprecate anything. I'm not even sure if with this change we need to modify structv4l2_dv_enum_preset
as I proposed in my RFC, although I think we should.Quoted 6 lines
Won't solve the issue: one new #define is needed for each video timing, namespaces will be confusing, no support for VESA GVF/ VESA CVT timings (or worse: we'll end by having thousands of formats at the end of the day),
instead of just one ENUM ioctl, an extra ioctl will be required for each returned value, etc.
Quoted 6 lines
Presets for GTF/CVT are useless (and I have never seen hardware that has such presets). In practice you have CEA and DMT presets and nothing else.
We may need to add
PRESET_PRIVATE(just like we do for controls) should we get non-CEA/DMT formats as well. There is no point in having specific preset defines for those IMHO.
A PRESET_PRIVATE would mean just one DV timing, as the "preset" is the index to get data. So, this won't fix the API.
Quoted 7 lines
I see very little advantage in throwing away an API that works quite well in practice only to add a new one that isn't much better IMO. Instead we can easily improve the existing API.
I *want* to be able to specify the most common CEA/DMT standards directly and unambiguously through presets.
With my proposal, you can do it.
Quoted 4 lines
It is very easy and nice to use in
practice. Once you go into the realm of GTF/CVT, then the preset API is too limited and G/S_DV_TIMINGS need to be used, but that requires much more effort on the part of the application.
The usage of G/S_DV_TIMINGS require an extra care: in the past, old VGA hardware (and/or monitors) could be damaged if it is programed with some parameters. It used to have some viruses that damaged hardware using it. So, any driver implementing it will need to validate the timings, to be sure that they are on an acceptable range and won't damage the hardware in any way, or it will need to require some special capability (root access) to avoid that an userspace program to damage the hardware.
The timings on a preset table should be ok, so it is safer to implement the *PRESET ioctls than the *TIMINGS one.
Quoted 1 line
I hope others will pitch in as well with their opinions.
Agreed.
Thanks,
Mauro.
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Quoted 128 lines
Em 06-07-2011 09:14, Hans Verkuil escreveu:
Quoted 127 lines
Quoted 126 lines
Em 06-07-2011 08:31, Hans Verkuil escreveu:
Quoted 114 lines
Quoted 114 lines
Em 05-07-2011 10:20, Hans Verkuil escreveu:
Quoted 21 lines
Quoted 9 lines
I failed to see what information is provided by the "presets" name. If
this were removed
from the ioctl, and fps would be added instead, the API would be clearer. The only
adjustment would be to use "index" as the preset selection key. Anyway,
it is too late
for such change. We need to live with that.Adding the fps solves nothing. Because that still does not give you specific timings.
You can have 1920x1080P60 that has quite different timings from the CEA-861 standard
and that may not be supported by a TV.If you are working with HDMI, then you may want to filter all supported
presets to
those of the CEA standard.Quoted 6 lines
That's one thing that is missing at the moment: that presets belonging
to a certain
standard get their own range. Since we only do CEA861 right now it hasn't been an
issue, but it will.I prepared a long email about that, but then I realized that we're investing our time into
something broken, at the light of all DV timing standards. So, I've dropped it and
started from scratch.From what I've got, there are some hardware that can only do a limited
set
of DV timings.
If this were not the case, we could simply just use the VIDIOC_S_DV_TIMINGS/VIDIOC_G_DV_TIMINGS,
and put the CEA 861 and VESA timings into some userspace library.In other words, the PRESET API is meant to solve the case where hardware
only support
a limited set of frequencies, that may or may not be inside the CEA standard.Let's assume we never added the current API, and discuss how it would properly fulfill
the user needs. An API that would likely work is:struct v4l2_dv_enum_preset2 { __u32 index; __u8 name[32]; /* Name of the preset timing */ struct v4l2_fract fps;#define
DV_PRESET_IS_PROGRESSIVE1<<31
#defineDV_PRESET_SPEC(flag)(flag &&0xff)
#defineDV_PRESET_IS_CEA8611
#defineDV_PRESET_IS_DMT2
#defineDV_PRESET_IS_CVF3
#defineDV_PRESET_IS_GTF4
#defineDV_PRESET_IS_VENDOR_SPECIFIC5
__u32flags; /* Interlaced/progressive, DV specs, etc */
__u32width; /* width in pixels */
__u32height; /* height in lines */
__u32polarities; /* Positive or negative polarity */
__u64pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
__u32hfrontporch; /* Horizpontal front porch in pixels */
__u32hsync; /* Horizontal Sync length in pixels */
__u32hbackporch; /* Horizontal back porch in pixels */
__u32vfrontporch; /* Vertical front porch in pixels */
__u32vsync; /* Vertical Sync length in lines */
__u32vbackporch; /* Vertical back porch in lines */
__u32il_vfrontporch; /* Vertical front porch for bottom field of
* interlaced field formats */
__u32il_vsync; /* Vertical sync length for bottom field of
* interlaced field formats */
__u32il_vbackporch; /* Vertical back porch for bottom field of
* interlaced field formats */
__u32reserved[4];
};#define
VIDIOC_ENUM_DV_PRESETS2_IOWR('V', 83, structv4l2_dv_enum_preset2)
#defineVIDIOC_S_DV_PRESET2_IOWR('V', 84, u32 index)
#defineVIDIOC_G_DV_PRESET2_IOWR('V', 85, u32 index)Such preset API seems to work for all cases. Userspace can use any DV timing
information to select the desired format, and don't need to have a switch
for
a preset macro to try to guess what the format actually means. Also, there's no
need to touch at the API spec every time a new DV timeline is needed.Also, it should be noticed that, since the size of the data on the above
definitions
are different than the old ones,_IOmacros will provide a different magic
number,
so, adding these won't break the existing API.Quoted 7 lines
Quoted 4 lines
So, I think we should work on this proposal, and mark the existing one
as
deprecated.This proposal makes it very hard for applications to directly select a format like 720p50 because the indices can change at any time.
Why? All the application needs to do is to call
VIDIOC_ENUM_DV_PRESETS2,
check what line it wants,
Quoted 6 lines
Quoted 4 lines
It's not so easy as you think to find the right timings: you have to check
many parameters to be certain you have the right one and not some subtle variation.Or you can do a
strcmp(v4l2_dv_enum_preset2.name,"my preset").
Yuck. Then you also need to define the names so you know what name to match on. Since once you allow this you can never modify the names again.
Quoted 44 lines
Quoted 14 lines
Quoted 14 lines
and do a
S_DV_PRESET2, just like any other place
where V4L2 defines an ENUM function.The enum won't change during application runtime, so, they can be stored
if the application would need to switch to other formats latter.Quoted 5 lines
I think
this is a very desirable feature, particularly for apps running on embedded systems where the hardware is known. This was one of the design
considerations at the time this API was made.Quoted 6 lines
Quoted 4 lines
This is a very weak argument. With just one ENUM loop, the application can
quickly get the right format(s), and associate them with any internal namespace.That actually isn't easy at all.
???
Quoted 21 lines
Quoted 9 lines
Quoted 8 lines
But looking at this I wonder if we shouldn't just make a
VIDIOC_G_PRESET_TIMINGSfunction? You give it the preset ID and you get
all the timing information back. No need to deprecate anything. I'm not
even sure if with this change we need to modify structv4l2_dv_enum_preset
as I proposed in my RFC, although I think we should.Quoted 7 lines
Won't solve the issue: one new #define is needed for each video timing, namespaces will be confusing, no support for VESA GVF/ VESA CVT timings (or worse: we'll end by having thousands of formats at the end of the day),
instead of just one ENUM ioctl, an extra ioctl will be required for each
returned value, etc.Presets for GTF/CVT are useless (and I have never seen hardware that has such presets). In practice you have CEA and DMT presets and nothing else.
Quoted 8 lines
Quoted 4 lines
We may need to add
PRESET_PRIVATE(just like we do for controls) should we
get non-CEA/DMT formats as well. There is no point in having specific preset defines for those IMHO.A
PRESET_PRIVATEwould mean just one DV timing, as the "preset" is the index
to get data. So, this won't fix the API.
PRESET_PRIVATE, PRESET_PRIVATE+1, +2, etc. Just as is done in other places.
Quoted 18 lines
Quoted 10 lines
I see very little advantage in throwing away an API that works quite well
in practice only to add a new one that isn't much better IMO. Instead we can easily improve the existing API.I *want* to be able to specify the most common CEA/DMT standards directly
and unambiguously through presets.With my proposal, you can do it.
Quoted 4 lines
It is very easy and nice to use in
practice. Once you go into the realm of GTF/CVT, then the preset API is too limited and G/S_DV_TIMINGS need to be used, but that requires much more effort on the part of the application.
Quoted 13 lines
The usage of G/S_DV_TIMINGS require an extra care: in the past, old VGA hardware
(and/or monitors) could be damaged if it is programed with some parameters.
It used to have some viruses that damaged hardware using it. So, any driver
implementing it will need to validate the timings, to be sure that they are
on an acceptable range and won't damage the hardware in any way, or it will
need to require some special capability (root access) to avoid that an userspace
program to damage the hardware.
Drivers need to validate if necessary, of course.
Quoted 3 lines
The timings on a preset table should be ok, so it is safer to implement the *PRESET
ioctls than the *TIMINGS one.
You will need the TIMINGS ioctls if you want to handle GTF/CVT formats. Those are calculated so the preset API is a poor fit.
Regards,
Hans
Quoted 11 lines
Quoted 1 line
I hope others will pitch in as well with their opinions.
Agreed.
Thanks,
Mauro.
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Em 06-07-2011 09:56, Hans Verkuil escreveu:
Quoted 133 lines
Quoted 133 lines
Em 06-07-2011 09:14, Hans Verkuil escreveu:
Quoted 131 lines
Quoted 120 lines
Em 06-07-2011 08:31, Hans Verkuil escreveu:
Quoted 119 lines
Quoted 118 lines
Em 05-07-2011 10:20, Hans Verkuil escreveu:
Quoted 21 lines
Quoted 9 lines
I failed to see what information is provided by the "presets" name. If
this were removed
from the ioctl, and fps would be added instead, the API would be clearer. The only
adjustment would be to use "index" as the preset selection key. Anyway,
it is too late
for such change. We need to live with that.Adding the fps solves nothing. Because that still does not give you specific timings.
You can have 1920x1080P60 that has quite different timings from the CEA-861 standard
and that may not be supported by a TV.If you are working with HDMI, then you may want to filter all supported
presets to
those of the CEA standard.Quoted 6 lines
That's one thing that is missing at the moment: that presets belonging
to a certain
standard get their own range. Since we only do CEA861 right now it hasn't been an
issue, but it will.I prepared a long email about that, but then I realized that we're investing our time into
something broken, at the light of all DV timing standards. So, I've dropped it and
started from scratch.From what I've got, there are some hardware that can only do a limited
set
of DV timings.
If this were not the case, we could simply just use the VIDIOC_S_DV_TIMINGS/VIDIOC_G_DV_TIMINGS,
and put the CEA 861 and VESA timings into some userspace library.In other words, the PRESET API is meant to solve the case where hardware
only support
a limited set of frequencies, that may or may not be inside the CEA standard.Let's assume we never added the current API, and discuss how it would properly fulfill
the user needs. An API that would likely work is:struct v4l2_dv_enum_preset2 { __u32 index; __u8 name[32]; /* Name of the preset timing */ struct v4l2_fract fps;#define
DV_PRESET_IS_PROGRESSIVE1<<31
#defineDV_PRESET_SPEC(flag)(flag &&0xff)
#defineDV_PRESET_IS_CEA8611
#defineDV_PRESET_IS_DMT2
#defineDV_PRESET_IS_CVF3
#defineDV_PRESET_IS_GTF4
#defineDV_PRESET_IS_VENDOR_SPECIFIC5
__u32flags; /* Interlaced/progressive, DV specs, etc */
__u32width; /* width in pixels */
__u32height; /* height in lines */
__u32polarities; /* Positive or negative polarity */
__u64pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
__u32hfrontporch; /* Horizpontal front porch in pixels */
__u32hsync; /* Horizontal Sync length in pixels */
__u32hbackporch; /* Horizontal back porch in pixels */
__u32vfrontporch; /* Vertical front porch in pixels */
__u32vsync; /* Vertical Sync length in lines */
__u32vbackporch; /* Vertical back porch in lines */
__u32il_vfrontporch; /* Vertical front porch for bottom field of
* interlaced field formats */
__u32il_vsync; /* Vertical sync length for bottom field of
* interlaced field formats */
__u32il_vbackporch; /* Vertical back porch for bottom field of
* interlaced field formats */
__u32reserved[4];
};#define
VIDIOC_ENUM_DV_PRESETS2_IOWR('V', 83, structv4l2_dv_enum_preset2)
#defineVIDIOC_S_DV_PRESET2_IOWR('V', 84, u32 index)
#defineVIDIOC_G_DV_PRESET2_IOWR('V', 85, u32 index)Such preset API seems to work for all cases. Userspace can use any DV timing
information to select the desired format, and don't need to have a switch
for
a preset macro to try to guess what the format actually means. Also, there's no
need to touch at the API spec every time a new DV timeline is needed.Also, it should be noticed that, since the size of the data on the above
definitions
are different than the old ones,_IOmacros will provide a different magic
number,
so, adding these won't break the existing API.So, I think we should work on this proposal, and mark the existing one
as
deprecated.Quoted 6 lines
Quoted 2 lines
This proposal makes it very hard for applications to directly select a format like 720p50 because the indices can change at any time.
Why? All the application needs to do is to call
VIDIOC_ENUM_DV_PRESETS2,
check what line it wants,It's not so easy as you think to find the right timings: you have to check
many parameters to be certain you have the right one and not some subtle variation.
Quoted 4 lines
Quoted 1 line
Or you can do a
strcmp(v4l2_dv_enum_preset2.name,"my preset").Yuck. Then you also need to define the names so you know what name to match on. Since once you allow this you can never modify the names again.
Once you add names to the API, the above is allowed, as the name is part of the API. So, names can't be changed, as changing them can break things.
The alternative is to remove the names from the new API.
Quoted 48 lines
Quoted 48 lines
Quoted 13 lines
Quoted 13 lines
and do a
S_DV_PRESET2, just like any other place
where V4L2 defines an ENUM function.The enum won't change during application runtime, so, they can be stored
if the application would need to switch to other formats latter.Quoted 5 lines
I think
this is a very desirable feature, particularly for apps running on embedded systems where the hardware is known. This was one of the design
considerations at the time this API was made.Quoted 6 lines
Quoted 4 lines
This is a very weak argument. With just one ENUM loop, the application can
quickly get the right format(s), and associate them with any internal namespace.That actually isn't easy at all.
???
Quoted 25 lines
Quoted 9 lines
Quoted 8 lines
But looking at this I wonder if we shouldn't just make a
VIDIOC_G_PRESET_TIMINGSfunction? You give it the preset ID and you get
all the timing information back. No need to deprecate anything. I'm not
even sure if with this change we need to modify structv4l2_dv_enum_preset
as I proposed in my RFC, although I think we should.Quoted 7 lines
Won't solve the issue: one new #define is needed for each video timing, namespaces will be confusing, no support for VESA GVF/ VESA CVT timings (or worse: we'll end by having thousands of formats at the end of the day),
instead of just one ENUM ioctl, an extra ioctl will be required for each
returned value, etc.Presets for GTF/CVT are useless (and I have never seen hardware that has such presets). In practice you have CEA and DMT presets and nothing else.
We may need to add
PRESET_PRIVATE(just like we do for controls) should we
get non-CEA/DMT formats as well. There is no point in having specific preset defines for those IMHO.
Quoted 5 lines
Quoted 3 lines
A
PRESET_PRIVATEwould mean just one DV timing, as the "preset" is the index
to get data. So, this won't fix the API.
PRESET_PRIVATE, PRESET_PRIVATE+1, +2, etc. Just as is done in other places.
Yuck. This is very ugly. NACK.
Quoted 30 lines
Quoted 16 lines
Quoted 8 lines
I see very little advantage in throwing away an API that works quite well
in practice only to add a new one that isn't much better IMO. Instead we can easily improve the existing API.I *want* to be able to specify the most common CEA/DMT standards directly
and unambiguously through presets.With my proposal, you can do it.
Quoted 4 lines
It is very easy and nice to use in
practice. Once you go into the realm of GTF/CVT, then the preset API is too limited and G/S_DV_TIMINGS need to be used, but that requires much more effort on the part of the application.Quoted 13 lines
The usage of G/S_DV_TIMINGS require an extra care: in the past, old VGA hardware
(and/or monitors) could be damaged if it is programed with some parameters.
It used to have some viruses that damaged hardware using it. So, any driver
implementing it will need to validate the timings, to be sure that they are
on an acceptable range and won't damage the hardware in any way, or it will
need to require some special capability (root access) to avoid that an userspace
program to damage the hardware.
Quoted 8 lines
Drivers need to validate if necessary, of course.
Quoted 3 lines
The timings on a preset table should be ok, so it is safer to implement the *PRESET
ioctls than the *TIMINGS one.You will need the TIMINGS ioctls if you want to handle GTF/CVT formats. Those are calculated so the preset API is a poor fit.
If you want full support for it, yes. But, if all it is needed are the common resolutions/fps (1024x768p60, 1920x1080p50, ...), GTF/CVT format presets may fit well.
Regards,
Mauro.
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
In reply to Hans VerkuilEm 06-07-2011 09:14, Hans Verkuil escreveu:
Quoted 138 lines
Quoted 117 lines
Em 06-07-2011 08:31, Hans Verkuil escreveu:
Quoted 116 lines
Quoted 115 lines
Em 05-07-2011 10:20, Hans Verkuil escreveu:
Quoted 21 lines
Quoted 9 lines
I failed to see what information is provided by the "presets" name. If
this were removed
from the ioctl, and fps would be added instead, the API would be clearer. The only
adjustment would be to use "index" as the preset selection key. Anyway,
it is too late
for such change. We need to live with that.Adding the fps solves nothing. Because that still does not give you specific timings.
You can have 1920x1080P60 that has quite different timings from the CEA-861 standard
and that may not be supported by a TV.If you are working with HDMI, then you may want to filter all supported
presets to
those of the CEA standard.Quoted 5 lines
That's one thing that is missing at the moment: that presets belonging to a certain
standard get their own range. Since we only do CEA861 right now it hasn't been an
issue, but it will.I prepared a long email about that, but then I realized that we're investing our time into
something broken, at the light of all DV timing standards. So, I've dropped it and
started from scratch.From what I've got, there are some hardware that can only do a limited set
of DV timings.
If this were not the case, we could simply just use the VIDIOC_S_DV_TIMINGS/VIDIOC_G_DV_TIMINGS,
and put the CEA 861 and VESA timings into some userspace library.In other words, the PRESET API is meant to solve the case where hardware
only support
a limited set of frequencies, that may or may not be inside the CEA standard.Let's assume we never added the current API, and discuss how it would properly fulfill
the user needs. An API that would likely work is:struct v4l2_dv_enum_preset2 { __u32 index; __u8 name[32]; /* Name of the preset timing */ struct v4l2_fract fps;#define
DV_PRESET_IS_PROGRESSIVE1<<31
#defineDV_PRESET_SPEC(flag)(flag &&0xff)
#defineDV_PRESET_IS_CEA8611
#defineDV_PRESET_IS_DMT2
#defineDV_PRESET_IS_CVF3
#defineDV_PRESET_IS_GTF4
#defineDV_PRESET_IS_VENDOR_SPECIFIC5
__u32flags; /* Interlaced/progressive, DV specs, etc */
__u32width; /* width in pixels */
__u32height; /* height in lines */
__u32polarities; /* Positive or negative polarity */
__u64pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
__u32hfrontporch; /* Horizpontal front porch in pixels */
__u32hsync; /* Horizontal Sync length in pixels */
__u32hbackporch; /* Horizontal back porch in pixels */
__u32vfrontporch; /* Vertical front porch in pixels */
__u32vsync; /* Vertical Sync length in lines */
__u32vbackporch; /* Vertical back porch in lines */
__u32il_vfrontporch; /* Vertical front porch for bottom field of
* interlaced field formats */
__u32il_vsync; /* Vertical sync length for bottom field of
* interlaced field formats */
__u32il_vbackporch; /* Vertical back porch for bottom field of
* interlaced field formats */
__u32reserved[4];
};#define
VIDIOC_ENUM_DV_PRESETS2_IOWR('V', 83, structv4l2_dv_enum_preset2)
#defineVIDIOC_S_DV_PRESET2_IOWR('V', 84, u32 index)
#defineVIDIOC_G_DV_PRESET2_IOWR('V', 85, u32 index)Such preset API seems to work for all cases. Userspace can use any DV timing
information to select the desired format, and don't need to have a switch
for
a preset macro to try to guess what the format actually means. Also, there's no
need to touch at the API spec every time a new DV timeline is needed.Also, it should be noticed that, since the size of the data on the above
definitions
are different than the old ones,_IOmacros will provide a different magic
number,
so, adding these won't break the existing API.So, I think we should work on this proposal, and mark the existing one as
deprecated.Quoted 5 lines
Quoted 2 lines
This proposal makes it very hard for applications to directly select a format like 720p50 because the indices can change at any time.
Why? All the application needs to do is to call
VIDIOC_ENUM_DV_PRESETS2, check what line it wants,It's not so easy as you think to find the right timings: you have to check many parameters to be certain you have the right one and not some subtle variation.
Quoted 11 lines
and do a
S_DV_PRESET2, just like any other place
where V4L2 defines an ENUM function.The enum won't change during application runtime, so, they can be stored if the application would need to switch to other formats latter.
Quoted 4 lines
I think
this is a very desirable feature, particularly for apps running on embedded systems where the hardware is known. This was one of the design considerations at the time this API was made.
Quoted 5 lines
Quoted 3 lines
This is a very weak argument. With just one ENUM loop, the application can quickly get the right format(s), and associate them with any internal namespace.
That actually isn't easy at all.
For the trivial case where the application just wants one of the CEA861 standard (or VESA DMT), the check is trivial.
The speed of the test can even be improved if the order at the struct would be changed to be:
struct v4l2_dv_enum_preset2 {
__u32 index;
__u32 flags;
struct v4l2_fract fps; __u32 width; /* width in pixels */
__u32 height; /* height in lines */
... }
The dv preset seek routine at the application can then be coded as:
struct seek_preset { /* Need to follow the same order/arguments as v4l2_dv_enum_preset2 */
struct v4l2_fract fps;
__u32 width;
__u32 height;
};
struct myapp_preset {
__u32 flags;
struct seek_preset preset;
};struct myapp_preset cea861_vic16 = {
.flags = DV_PRESET_IS_PROGRESSIVE | DV_PRESET_IS_CEA861,
.width = 1920,
.height = 1080,
};int return_dv_preset_index(fp, struct myapp_preset *needed)
{
int found = -1;
struct v4l2_dv_enum_preset2 preset;
do {
rc = ioctl(fp, VIDIOC_ENUM_DV_PRESETS, &preset);
if (rc == -1)
break;
if ((preset.flags & needed->flags) != needed->flags)
continue;
if (!memcmp(&preset.fps, &needed->preset)) {
found = preset->index;
break;
}
} while (!rc && found < 0);
}void main(void) {
...
index = return_dv_preset_index(fp, cea861_vic16);
...
}
Cheers,
Mauro
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Quoted 200 lines · On Wednesday, July 06, 2011 21:39:46 Mauro Carvalho Chehab wrote:
Em 06-07-2011 09:14, Hans Verkuil escreveu:
Quoted 138 lines
Quoted 117 lines
Em 06-07-2011 08:31, Hans Verkuil escreveu:
Quoted 116 lines
Quoted 115 lines
Em 05-07-2011 10:20, Hans Verkuil escreveu:
Quoted 21 lines
Quoted 9 lines
I failed to see what information is provided by the "presets" name. If
this were removed
from the ioctl, and fps would be added instead, the API would be clearer. The only
adjustment would be to use "index" as the preset selection key. Anyway,
it is too late
for such change. We need to live with that.Adding the fps solves nothing. Because that still does not give you specific timings.
You can have 1920x1080P60 that has quite different timings from the CEA-861 standard
and that may not be supported by a TV.If you are working with HDMI, then you may want to filter all supported
presets to
those of the CEA standard.Quoted 5 lines
That's one thing that is missing at the moment: that presets belonging to a certain
standard get their own range. Since we only do CEA861 right now it hasn't been an
issue, but it will.I prepared a long email about that, but then I realized that we're investing our time into
something broken, at the light of all DV timing standards. So, I've dropped it and
started from scratch.From what I've got, there are some hardware that can only do a limited set
of DV timings.
If this were not the case, we could simply just use the VIDIOC_S_DV_TIMINGS/VIDIOC_G_DV_TIMINGS,
and put the CEA 861 and VESA timings into some userspace library.In other words, the PRESET API is meant to solve the case where hardware
only support
a limited set of frequencies, that may or may not be inside the CEA standard.Let's assume we never added the current API, and discuss how it would properly fulfill
the user needs. An API that would likely work is:struct v4l2_dv_enum_preset2 { __u32 index; __u8 name[32]; /* Name of the preset timing */ struct v4l2_fract fps;#define
DV_PRESET_IS_PROGRESSIVE1<<31
#defineDV_PRESET_SPEC(flag)(flag &&0xff)
#defineDV_PRESET_IS_CEA8611
#defineDV_PRESET_IS_DMT2
#defineDV_PRESET_IS_CVF3
#defineDV_PRESET_IS_GTF4
#defineDV_PRESET_IS_VENDOR_SPECIFIC5
__u32flags; /* Interlaced/progressive, DV specs, etc */
__u32width; /* width in pixels */
__u32height; /* height in lines */
__u32polarities; /* Positive or negative polarity */
__u64pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
__u32hfrontporch; /* Horizpontal front porch in pixels */
__u32hsync; /* Horizontal Sync length in pixels */
__u32hbackporch; /* Horizontal back porch in pixels */
__u32vfrontporch; /* Vertical front porch in pixels */
__u32vsync; /* Vertical Sync length in lines */
__u32vbackporch; /* Vertical back porch in lines */
__u32il_vfrontporch; /* Vertical front porch for bottom field of
* interlaced field formats */
__u32il_vsync; /* Vertical sync length for bottom field of
* interlaced field formats */
__u32il_vbackporch; /* Vertical back porch for bottom field of
* interlaced field formats */
__u32reserved[4];
};#define
VIDIOC_ENUM_DV_PRESETS2_IOWR('V', 83, structv4l2_dv_enum_preset2)
#defineVIDIOC_S_DV_PRESET2_IOWR('V', 84, u32 index)
#defineVIDIOC_G_DV_PRESET2_IOWR('V', 85, u32 index)Such preset API seems to work for all cases. Userspace can use any DV timing
information to select the desired format, and don't need to have a switch
for
a preset macro to try to guess what the format actually means. Also, there's no
need to touch at the API spec every time a new DV timeline is needed.Also, it should be noticed that, since the size of the data on the above
definitions
are different than the old ones,_IOmacros will provide a different magic
number,
so, adding these won't break the existing API.So, I think we should work on this proposal, and mark the existing one as
deprecated.Quoted 5 lines
Quoted 2 lines
This proposal makes it very hard for applications to directly select a format like 720p50 because the indices can change at any time.
Why? All the application needs to do is to call
VIDIOC_ENUM_DV_PRESETS2, check what line it wants,It's not so easy as you think to find the right timings: you have to check many parameters to be certain you have the right one and not some subtle variation.
Quoted 11 lines
and do a
S_DV_PRESET2, just like any other place
where V4L2 defines an ENUM function.The enum won't change during application runtime, so, they can be stored if the application would need to switch to other formats latter.
Quoted 4 lines
I think
this is a very desirable feature, particularly for apps running on embedded systems where the hardware is known. This was one of the design considerations at the time this API was made.Quoted 5 lines
Quoted 3 lines
This is a very weak argument. With just one ENUM loop, the application can quickly get the right format(s), and associate them with any internal namespace.
That actually isn't easy at all.
For the trivial case where the application just wants one of the CEA861 standard (or VESA DMT), the check is trivial.
The speed of the test can even be improved if the order at the struct would be changed to be:
struct v4l2_dv_enum_preset2 { __u32 index; __u32 flags; struct v4l2_fract fps;(quoted diff) +0
-0__u32 width; /* width in pixels */ __u32 height; /* height in lines */}
The dv preset seek routine at the application can then be coded as:
struct
seek_preset{ /* Need to follow the same order/arguments asv4l2_dv_enum_preset2*/struct v4l2_fract fps;(quoted diff) +0
-0__u32 width; __u32 height;};
struct myapp_preset { __u32 flags; struct seek_preset preset; };struct myapp_preset cea861_vic16 = { .flags = DV_PRESET_IS_PROGRESSIVE | DV_PRESET_IS_CEA861, .width = 1920, .height = 1080, };int
return_dv_preset_index(fp, struct myapp_preset *needed){ int found = -1; struct v4l2_dv_enum_preset2 preset; do { rc = ioctl(fp, VIDIOC_ENUM_DV_PRESETS, &preset); if (rc == -1) break; if ((preset.flags & needed->flags) != needed->flags) continue; if (!memcmp(&preset.fps, &needed->preset)) { found = preset->index; break; } } while (!rc && found < 0); }
Quoted 5 lines
void main(void) {
...index = return_dv_preset_index(fp, cea861_vic16);...
}
And the current equivalent is:
struct v4l_dv_preset preset = { V4L2_DV_1080P60 };
ioctl(f, VIDIOC_S_DV_PRESET, &preset);You want a whole new API that in my view makes things only more complicated and misses existing functionality (such as the one above).
Whereas with a few tweaks and possibly a new VIDIOC_G_PRESET_TIMINGS ioctl you can offer the same functionality with the existing API.
So, once again my proposal:
ENUM_DV_PRESETS is extended with a flags field and a fps v4l2_fract (or frame_period, whatever works best). Flags give you progressive vs interlaced, and I've no problem adding things like IS_CEA861 or similar flags to that.
The current set of presets remain in use (but get renamed with the old ones as aliases) for CEA861 and (in the near future) VESA DMT timings. Note that all the hardware I know that has predefined timings does so only for those two standards. Makes sense
too: only the consumer electronic standards for SDTV/HDTV and the VGA-like PC monitor standards are typical standards.
For presets not related to those standards the easiest method I see is just to assign a preset like (0x80000000 | index).
We may need to add a VIDIOC_G_PRESET_TIMINGS, but I am not certain we really need that. ENUM_DV_PRESETS may give sufficient information already.
Based on my experience with GTF/CVT formats I strongly suspect that drivers will need to implement a VIDIOC_QUERY_DV_TIMINGS ioctl and let a userspace library detect the GTF/CVT standard. This is surprisingly complex (mostly due to extremely shoddy standards). For GTF/CVT output you want to use VIDIOC_S_DV_TIMINGS anyway. The reason there is no GTF/CVT support yet is simply because I don't want to make proposals unless I actually implemented it and worked with it for some time to see what works best.
Everything you can do with your proposal you can do with mine, and mine doesn't deprecate anything.
BTW, in the case of HD-SDI transmitters/receivers the CEA-861 standard does not apply, strictly speaking. That standard is covered by SMPTE 292M. It does support most of the usual SDTV/HDTV formats as are defined in CEA-861, except that things like front/back porch etc. do not apply to this serial interface. The idea behind the presets is that it defines industry standard resolution/framerate combinations, but the standards behind those differ per interface type. You don't really care about those in an application. The user (or developer) just wants to select 1080P60 or WUXGA. I am frankly not certain anymore if we want to have the standard as part of the macro name. Something like V4L2_DV_HDTV_1920X1080P60 might be more appropriate, with comments next to it referring to the relevant standards depending on the physical interface type.
And instead of using flags to denote the used standard, it might be better to reserve a u16 for the standard.
History has shown that video formats stay around for a looong time, but the standards describing them evolve continuously.
Regards,
Hans
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Em 07-07-2011 08:33, Hans Verkuil escreveu:
Quoted 207 lines · On Wednesday, July 06, 2011 21:39:46 Mauro Carvalho Chehab wrote:
Quoted 200 lines
Em 06-07-2011 09:14, Hans Verkuil escreveu:
Quoted 138 lines
Quoted 117 lines
Em 06-07-2011 08:31, Hans Verkuil escreveu:
Quoted 116 lines
Quoted 115 lines
Em 05-07-2011 10:20, Hans Verkuil escreveu:
Quoted 21 lines
Quoted 9 lines
I failed to see what information is provided by the "presets" name. If
this were removed
from the ioctl, and fps would be added instead, the API would be clearer. The only
adjustment would be to use "index" as the preset selection key. Anyway,
it is too late
for such change. We need to live with that.Adding the fps solves nothing. Because that still does not give you specific timings.
You can have 1920x1080P60 that has quite different timings from the CEA-861 standard
and that may not be supported by a TV.If you are working with HDMI, then you may want to filter all supported
presets to
those of the CEA standard.Quoted 5 lines
That's one thing that is missing at the moment: that presets belonging to a certain
standard get their own range. Since we only do CEA861 right now it hasn't been an
issue, but it will.I prepared a long email about that, but then I realized that we're investing our time into
something broken, at the light of all DV timing standards. So, I've dropped it and
started from scratch.From what I've got, there are some hardware that can only do a limited set
of DV timings.
If this were not the case, we could simply just use the VIDIOC_S_DV_TIMINGS/VIDIOC_G_DV_TIMINGS,
and put the CEA 861 and VESA timings into some userspace library.In other words, the PRESET API is meant to solve the case where hardware
only support
a limited set of frequencies, that may or may not be inside the CEA standard.Let's assume we never added the current API, and discuss how it would properly fulfill
the user needs. An API that would likely work is:struct v4l2_dv_enum_preset2 { __u32 index; __u8 name[32]; /* Name of the preset timing */ struct v4l2_fract fps;#define
DV_PRESET_IS_PROGRESSIVE1<<31
#defineDV_PRESET_SPEC(flag)(flag &&0xff)
#defineDV_PRESET_IS_CEA8611
#defineDV_PRESET_IS_DMT2
#defineDV_PRESET_IS_CVF3
#defineDV_PRESET_IS_GTF4
#defineDV_PRESET_IS_VENDOR_SPECIFIC5
__u32flags; /* Interlaced/progressive, DV specs, etc */
__u32width; /* width in pixels */
__u32height; /* height in lines */
__u32polarities; /* Positive or negative polarity */
__u64pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
__u32hfrontporch; /* Horizpontal front porch in pixels */
__u32hsync; /* Horizontal Sync length in pixels */
__u32hbackporch; /* Horizontal back porch in pixels */
__u32vfrontporch; /* Vertical front porch in pixels */
__u32vsync; /* Vertical Sync length in lines */
__u32vbackporch; /* Vertical back porch in lines */
__u32il_vfrontporch; /* Vertical front porch for bottom field of
* interlaced field formats */
__u32il_vsync; /* Vertical sync length for bottom field of
* interlaced field formats */
__u32il_vbackporch; /* Vertical back porch for bottom field of
* interlaced field formats */
__u32reserved[4];
};#define
VIDIOC_ENUM_DV_PRESETS2_IOWR('V', 83, structv4l2_dv_enum_preset2)
#defineVIDIOC_S_DV_PRESET2_IOWR('V', 84, u32 index)
#defineVIDIOC_G_DV_PRESET2_IOWR('V', 85, u32 index)Such preset API seems to work for all cases. Userspace can use any DV timing
information to select the desired format, and don't need to have a switch
for
a preset macro to try to guess what the format actually means. Also, there's no
need to touch at the API spec every time a new DV timeline is needed.Also, it should be noticed that, since the size of the data on the above
definitions
are different than the old ones,_IOmacros will provide a different magic
number,
so, adding these won't break the existing API.So, I think we should work on this proposal, and mark the existing one as
deprecated.Quoted 5 lines
Quoted 2 lines
This proposal makes it very hard for applications to directly select a format like 720p50 because the indices can change at any time.
Why? All the application needs to do is to call
VIDIOC_ENUM_DV_PRESETS2, check what line it wants,It's not so easy as you think to find the right timings: you have to check many parameters to be certain you have the right one and not some subtle variation.
Quoted 11 lines
and do a
S_DV_PRESET2, just like any other place
where V4L2 defines an ENUM function.The enum won't change during application runtime, so, they can be stored if the application would need to switch to other formats latter.
Quoted 4 lines
I think
this is a very desirable feature, particularly for apps running on embedded systems where the hardware is known. This was one of the design considerations at the time this API was made.Quoted 5 lines
Quoted 3 lines
This is a very weak argument. With just one ENUM loop, the application can quickly get the right format(s), and associate them with any internal namespace.
That actually isn't easy at all.
For the trivial case where the application just wants one of the CEA861 standard (or VESA DMT), the check is trivial.
The speed of the test can even be improved if the order at the struct would be changed to be:
struct v4l2_dv_enum_preset2 { __u32 index; __u32 flags; struct v4l2_fract fps;(quoted diff) +0
-0__u32 width; /* width in pixels */ __u32 height; /* height in lines */}
The dv preset seek routine at the application can then be coded as:
struct
seek_preset{ /* Need to follow the same order/arguments asv4l2_dv_enum_preset2*/struct v4l2_fract fps;(quoted diff) +0
-0__u32 width; __u32 height;};
struct myapp_preset { __u32 flags; struct seek_preset preset; };struct myapp_preset cea861_vic16 = { .flags = DV_PRESET_IS_PROGRESSIVE | DV_PRESET_IS_CEA861, .width = 1920, .height = 1080, };int
return_dv_preset_index(fp, struct myapp_preset *needed){ int found = -1; struct v4l2_dv_enum_preset2 preset; do { rc = ioctl(fp, VIDIOC_ENUM_DV_PRESETS, &preset); if (rc == -1) break; if ((preset.flags & needed->flags) != needed->flags) continue; if (!memcmp(&preset.fps, &needed->preset)) { found = preset->index; break; } } while (!rc && found < 0); }Quoted 5 lines
void main(void) {
...index = return_dv_preset_index(fp, cea861_vic16);...
}
Quoted 4 lines
And the current equivalent is:
struct v4l_dv_preset preset = { V4L2_DV_1080P60 }; ioctl(f, VIDIOC_S_DV_PRESET, &preset);
Yes, except for the fact that:
- API spec needs addition for every new preset that we standardize;
- It doesn't support a vendor-specific preset, as there's no way to discover what are the timing constants for the preset;
- Namespacing is broken.
Quoted 2 lines
You want a whole new API that in my view makes things only more complicated and misses existing functionality (such as the one above).
I prefer to fix the API, if it is possible/doable on a non-messy way. Yet, as this API is currently used only by two drivers (DaVinci and tvp7002), it is better to fix it sooner than later, to avoid more efforts on fixing it.
Quoted 2 lines
Whereas with a few tweaks and possibly a new
VIDIOC_G_PRESET_TIMINGSioctl you can offer the same functionality with the existing API.
You're proposing a new "enum" preset timings that would present the missing info that VIDIOC_S_DV_PRESET doesn't present, except that an application will need to call 2 ioctl's in order to enumerate the presets, instead of one.
Quoted 6 lines
So, once again my proposal:
ENUM_DV_PRESETSis extended with a flags field and a fpsv4l2_fract(orframe_period, whatever works best). Flags give you progressive vs interlaced, and I've no problem adding things likeIS_CEA861or similar flags to that.
Quoted 8 lines
The current set of presets remain in use (but get renamed with the old ones as aliases) for CEA861 and (in the near future) VESA DMT timings.
Note that all the hardware I
know that has predefined timings does so only for those two standards. Makes sense
too: only the consumer electronic standards for SDTV/HDTV and the VGA-like PC monitor standards are typical standards.
We need a further investigation about that. What are the predefined timings defined for Samgung hardware?
Also, one possible implementation for output devices would be to use EDID to retrieve the timings acceptable by the monitor/TV and compare to its internal capabilities. This is probably the only way to avoid requiring CAP_SYS_ADMIN for the DV calls, as a bad timing may damage the monitor and/or the V4L device.
If a vendor decides to implement something like that (either in firmware or on Kernel), then the list of presets will likely have a mix with all standards.
Quoted 2 lines
For presets not related to those standards the easiest method I see is just to assign a preset like (
0x80000000| index).
I've thinked about that already. Yeah, this would fix part of the problem, allowing the implementation of vendor-specific timings and the support for other standards not covered yet. There are, however, some issues:
1) the API will be messier;
2) Imagine that a new timing were added as a vendor-specific timing. Later,
that standard got recognized by some forum and were added at some standard. In that case, the vendor cannot simply change the preset index, as it will break the API. Also, duplicating the information is not a good idea. With the preset standards as flags, when this happens, all the driver needs is to add a new flag, without breaking the API.
Quoted 2 lines
We may need to add a
VIDIOC_G_PRESET_TIMINGS, but I am not certain we really need that.ENUM_DV_PRESETSmay give sufficient information already.
This will only work if there aren't two timings with the same fps/resolution, including on the vendor-specific timings. Let's suppose that there are two non-DMT, non-CEA standars, from two different vendors, that have different timings. With the current API, there's no way to differentiate them.
Quoted 4 lines
Based on my experience with GTF/CVT formats I strongly suspect that drivers will need to implement a
VIDIOC_QUERY_DV_TIMINGSioctl and let a userspace library detect the GTF/CVT standard. This is surprisingly complex (mostly due to extremely shoddy standards).
Maybe, but I bet that there are a few GTF/CVT standards that are implemented on a large amount of TV/monitors. It may make sense to have those added as presets. I'd love to get some feedback from other developers about that. Samsung?
The issue with S_DV_TIMINGS is that we likely need to request for CAP_SYS_ADMIN, as a bad timing may damage the hardware.
Currently, there's not such requirement for DaVinci/tvp7002, nor v4l2-ioctl enforces that, but this needs a fix.
Quoted 1 line
For GTF/CVT output you want to use
VIDIOC_S_DV_TIMINGSanyway.
True.
Quoted 7 lines
The reason
there is no GTF/CVT support yet is simply because I don't want to make proposals unless I actually implemented it and worked with it for some time to see what works best.Everything you can do with your proposal you can do with mine, and mine doesn't deprecate anything.
See above.
Quoted 8 lines
BTW, in the case of HD-SDI transmitters/receivers the CEA-861 standard does not apply, strictly speaking. That standard is covered by SMPTE 292M. It does support most of the usual SDTV/HDTV formats as are defined in CEA-861, except that things like front/back porch etc. do not apply to this serial interface. The idea behind the presets is that it defines industry standard resolution/framerate combinations, but the standards behind those differ per interface type. You don't really care about those in an application. The user (or developer) just wants to select 1080P60 or WUXGA.
Ok.
Quoted 4 lines
I am frankly not certain anymore if we want to have the standard as part of the macro name. Something like
V4L2_DV_HDTV_1920X1080P60might be more appropriate, with comments next to it referring to the relevant standards depending on the physical interface type.
That's the problem with the namespace. I think that that's basically the reason why Xorg never created a macro naming for the resolutions. Whatever namespace we choose, we'll have troubles. I bet that, with your proposal, we'll end by having conflicts between two different standards that implement the same resolution/fps/"progressiveness".
Quoted 2 lines
And instead of using flags to denote the used standard, it might be better to reserve a u16 for the standard.
It seems that a standards bitmask may work better, as, eventually, the same timing may be defined by more than one standard.
Quoted 2 lines
History has shown that video formats stay around for a looong time, but the standards describing them evolve continuously.
True. We might end to have some timings that are different on a new standard revision, in order to fix some issue. That's why I think we need to expose all the timings at the DV enum ioctl. This gives more flexibility to the application to reject an specific standard if needed for whatever reason.
Regards,
Mauro
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Quoted 208 lines · On Thursday, July 07, 2011 15:52:53 Mauro Carvalho Chehab wrote:
Em 07-07-2011 08:33, Hans Verkuil escreveu:
Quoted 207 lines · On Wednesday, July 06, 2011 21:39:46 Mauro Carvalho Chehab wrote:
Quoted 205 lines
Em 06-07-2011 09:14, Hans Verkuil escreveu:
Quoted 138 lines
Quoted 117 lines
Em 06-07-2011 08:31, Hans Verkuil escreveu:
Quoted 116 lines
Quoted 115 lines
Em 05-07-2011 10:20, Hans Verkuil escreveu:
Quoted 21 lines
Quoted 9 lines
I failed to see what information is provided by the "presets" name. If
this were removed
from the ioctl, and fps would be added instead, the API would be clearer. The only
adjustment would be to use "index" as the preset selection key. Anyway,
it is too late
for such change. We need to live with that.Adding the fps solves nothing. Because that still does not give you specific timings.
You can have 1920x1080P60 that has quite different timings from the CEA-861 standard
and that may not be supported by a TV.If you are working with HDMI, then you may want to filter all supported
presets to
those of the CEA standard.Quoted 5 lines
That's one thing that is missing at the moment: that presets belonging to a certain
standard get their own range. Since we only do CEA861 right now it hasn't been an
issue, but it will.I prepared a long email about that, but then I realized that we're investing our time into
something broken, at the light of all DV timing standards. So, I've dropped it and
started from scratch.From what I've got, there are some hardware that can only do a limited set
of DV timings.
If this were not the case, we could simply just use the VIDIOC_S_DV_TIMINGS/VIDIOC_G_DV_TIMINGS,
and put the CEA 861 and VESA timings into some userspace library.In other words, the PRESET API is meant to solve the case where hardware
only support
a limited set of frequencies, that may or may not be inside the CEA standard.Let's assume we never added the current API, and discuss how it would properly fulfill
the user needs. An API that would likely work is:struct v4l2_dv_enum_preset2 { __u32 index; __u8 name[32]; /* Name of the preset timing */ struct v4l2_fract fps;#define
DV_PRESET_IS_PROGRESSIVE1<<31
#defineDV_PRESET_SPEC(flag)(flag &&0xff)
#defineDV_PRESET_IS_CEA8611
#defineDV_PRESET_IS_DMT2
#defineDV_PRESET_IS_CVF3
#defineDV_PRESET_IS_GTF4
#defineDV_PRESET_IS_VENDOR_SPECIFIC5
__u32flags; /* Interlaced/progressive, DV specs, etc */
__u32width; /* width in pixels */
__u32height; /* height in lines */
__u32polarities; /* Positive or negative polarity */
__u64pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
__u32hfrontporch; /* Horizpontal front porch in pixels */
__u32hsync; /* Horizontal Sync length in pixels */
__u32hbackporch; /* Horizontal back porch in pixels */
__u32vfrontporch; /* Vertical front porch in pixels */
__u32vsync; /* Vertical Sync length in lines */
__u32vbackporch; /* Vertical back porch in lines */
__u32il_vfrontporch; /* Vertical front porch for bottom field of
* interlaced field formats */
__u32il_vsync; /* Vertical sync length for bottom field of
* interlaced field formats */
__u32il_vbackporch; /* Vertical back porch for bottom field of
* interlaced field formats */
__u32reserved[4];
};#define
VIDIOC_ENUM_DV_PRESETS2_IOWR('V', 83, structv4l2_dv_enum_preset2)
#defineVIDIOC_S_DV_PRESET2_IOWR('V', 84, u32 index)
#defineVIDIOC_G_DV_PRESET2_IOWR('V', 85, u32 index)Such preset API seems to work for all cases. Userspace can use any DV timing
information to select the desired format, and don't need to have a switch
for
a preset macro to try to guess what the format actually means. Also, there's no
need to touch at the API spec every time a new DV timeline is needed.Also, it should be noticed that, since the size of the data on the above
definitions
are different than the old ones,_IOmacros will provide a different magic
number,
so, adding these won't break the existing API.So, I think we should work on this proposal, and mark the existing one as
deprecated.Quoted 5 lines
Quoted 2 lines
This proposal makes it very hard for applications to directly select a format like 720p50 because the indices can change at any time.
Why? All the application needs to do is to call
VIDIOC_ENUM_DV_PRESETS2, check what line it wants,It's not so easy as you think to find the right timings: you have to check many parameters to be certain you have the right one and not some subtle variation.
Quoted 11 lines
and do a
S_DV_PRESET2, just like any other place
where V4L2 defines an ENUM function.The enum won't change during application runtime, so, they can be stored if the application would need to switch to other formats latter.
Quoted 4 lines
I think
this is a very desirable feature, particularly for apps running on embedded systems where the hardware is known. This was one of the design considerations at the time this API was made.Quoted 5 lines
Quoted 3 lines
This is a very weak argument. With just one ENUM loop, the application can quickly get the right format(s), and associate them with any internal namespace.
That actually isn't easy at all.
For the trivial case where the application just wants one of the CEA861 standard (or VESA DMT), the check is trivial.
The speed of the test can even be improved if the order at the struct would be changed to be:
struct v4l2_dv_enum_preset2 { __u32 index; __u32 flags; struct v4l2_fract fps;(quoted diff) +0
-0__u32 width; /* width in pixels */ __u32 height; /* height in lines */}
The dv preset seek routine at the application can then be coded as:
struct
seek_preset{ /* Need to follow the same order/arguments asv4l2_dv_enum_preset2*/struct v4l2_fract fps;(quoted diff) +0
-0__u32 width; __u32 height;};
struct myapp_preset { __u32 flags; struct seek_preset preset; };struct myapp_preset cea861_vic16 = { .flags = DV_PRESET_IS_PROGRESSIVE | DV_PRESET_IS_CEA861, .width = 1920, .height = 1080, };int
return_dv_preset_index(fp, struct myapp_preset *needed){ int found = -1; struct v4l2_dv_enum_preset2 preset; do { rc = ioctl(fp, VIDIOC_ENUM_DV_PRESETS, &preset); if (rc == -1) break; if ((preset.flags & needed->flags) != needed->flags) continue; if (!memcmp(&preset.fps, &needed->preset)) { found = preset->index; break; } } while (!rc && found < 0); }void main(void) {
...index = return_dv_preset_index(fp, cea861_vic16);...
}
Quoted 7 lines
Quoted 4 lines
And the current equivalent is:
struct v4l_dv_preset preset = { V4L2_DV_1080P60 }; ioctl(f, VIDIOC_S_DV_PRESET, &preset);Yes, except for the fact that:
- API spec needs addition for every new preset that we standardize;
True. But I believe that it is very useful to have such standardized presets.
Quoted 2 lines
- It doesn't support a vendor-specific preset, as there's no way to discover what are the timing constants for the preset;
That's why I propose a G_PRESET_TIMINGS.
In my experience most applications do not care about such timings unless you want to support a wide range of formats, in which case you are more likely to use the DV_TIMINGS API (if supported by the hardware). Note that the fps+flags fields should certainly be added to v4l2_enum_dv_preset. No doubt about that.
Quoted 1 line
- Namespacing is broken.
That could be improved, indeed. Deciding on a right namespace isn't that easy, though.
Quoted 8 lines
Quoted 3 lines
You want a whole new API that in my view makes things only more complicated and misses existing functionality (such as the one above).
I prefer to fix the API, if it is possible/doable on a non-messy way. Yet, as this API is currently used only by two drivers (DaVinci and tvp7002), it is better to fix it sooner than later, to avoid more efforts on fixing it.
Quoted 6 lines
Quoted 2 lines
Whereas with a few tweaks and possibly a new
VIDIOC_G_PRESET_TIMINGSioctl you can offer the same functionality with the existing API.You're proposing a new "enum" preset timings that would present the missing info that
VIDIOC_S_DV_PRESETdoesn't present, except that an application will need to call 2 ioctl's in order to enumerate the presets, instead of one.
Very few applications actually need such precise information. Resolution, fps and interlaced/progressive is enough for most.
Quoted 15 lines
Quoted 6 lines
So, once again my proposal:
ENUM_DV_PRESETSis extended with a flags field and a fpsv4l2_fract(orframe_period, whatever works best). Flags give you progressive vs interlaced, and I've no problem adding things likeIS_CEA861or similar flags to that.Quoted 8 lines
The current set of presets remain in use (but get renamed with the old ones as aliases) for CEA861 and (in the near future) VESA DMT timings.
Note that all the hardware I
know that has predefined timings does so only for those two standards. Makes sense
too: only the consumer electronic standards for SDTV/HDTV and the VGA-like PC monitor standards are typical standards.
Quoted 7 lines
We need a further investigation about that. What are the predefined timings defined for Samgung hardware?
Also, one possible implementation for output devices would be to use EDID to retrieve the timings acceptable by the monitor/TV and compare to its internal capabilities. This is probably the only way to avoid requiring
CAP_SYS_ADMINfor the DV calls, as a bad timing may damage the monitor and/or the V4L device.
Is CAP_SYS_ADMIN needed today to set graphics modelines? I am not aware of any checks being done (other than probably against EDID information, if present).
To my (limited) knowledge hardware that can be broken that way is very, very old and very unlikely to have EDID capabilities.
Quoted 2 lines
If a vendor decides to implement something like that (either in firmware or on Kernel), then the list of presets will likely have a mix with all standards.
The EDID does not make the list of presets, that is based on the capabilities of the transmitter (or receiver, for that matter). The EDID may be used to filter the list of presets, though.
Quoted 10 lines
Quoted 2 lines
For presets not related to those standards the easiest method I see is just to assign a preset like (
0x80000000| index).I've thinked about that already. Yeah, this would fix part of the problem, allowing the implementation of vendor-specific timings and the support for other standards not covered yet. There are, however, some issues:
1) the API will be messier;
2) Imagine that a new timing were added as a vendor-specific timing. Later,
that standard got recognized by some forum and were added at some standard. In that case, the vendor cannot simply change the preset index, as it will break the API.
Why would that break the API? The preset was 0x80000000 | 42 (or whatever), now it becomes V4L2_DV_FOO_WXHP50. You couldn't rely on the first preset to stay the same anyway.
Quoted 11 lines
Also, duplicating the information is not a good idea. With the preset standards as flags, when this happens, all the driver needs is to add a new flag, without breaking the API.
Quoted 2 lines
We may need to add a
VIDIOC_G_PRESET_TIMINGS, but I am not certain we really need that.ENUM_DV_PRESETSmay give sufficient information already.This will only work if there aren't two timings with the same fps/resolution, including on the vendor-specific timings. Let's suppose that there are two non-DMT, non-CEA standars, from two different vendors, that have different timings. With the current API, there's no way to differentiate them.
That's why G_PRESET_TIMINGS may be necessary. I'm just doubtful that applications will know what to do with that information.
Quoted 7 lines
Quoted 4 lines
Based on my experience with GTF/CVT formats I strongly suspect that drivers will need to implement a
VIDIOC_QUERY_DV_TIMINGSioctl and let a userspace library detect the GTF/CVT standard. This is surprisingly complex (mostly due to extremely shoddy standards).Maybe, but I bet that there are a few GTF/CVT standards that are implemented on a large amount of TV/monitors. It may make sense to have those added as presets.
Sure, many TVs and monitors support GTF and CVT, but they are not presets as such but algorithms to allow almost all possible combinations of resolution and fps.
CVT formats can be detected based on hsync and vsync polarities and the vertical sync width. GTF is much harder to detect, unfortunately.
The CEA standard has only positive hsync+vsync or negative hsync+vsync polarities. Except for one single timing (VIC 39). Which @#$^%@@ imbecile came up with that bright idea?!
Quoted 4 lines
I'd love to get some feedback from other developers about that. Samsung?
The issue with
S_DV_TIMINGSis that we likely need to request forCAP_SYS_ADMIN, as a bad timing may damage the hardware.
How would this help? Changing my graphics card resolution today doesn't require me to be root either. The only time this might conceivably be an issue is for analog video transmitters. I would need to do more research on this. Does anyone else know much about what constitutes a bad timing and how it might damage hardware?
Quoted 38 lines
Currently, there's not such requirement for DaVinci/tvp7002, nor v4l2-ioctl enforces that, but this needs a fix.
Quoted 1 line
For GTF/CVT output you want to use
VIDIOC_S_DV_TIMINGSanyway.True.
Quoted 7 lines
The reason
there is no GTF/CVT support yet is simply because I don't want to make proposals unless I actually implemented it and worked with it for some time to see what works best.Everything you can do with your proposal you can do with mine, and mine doesn't deprecate anything.
See above.
Quoted 8 lines
BTW, in the case of HD-SDI transmitters/receivers the CEA-861 standard does not apply, strictly speaking. That standard is covered by SMPTE 292M. It does support most of the usual SDTV/HDTV formats as are defined in CEA-861, except that things like front/back porch etc. do not apply to this serial interface. The idea behind the presets is that it defines industry standard resolution/framerate combinations, but the standards behind those differ per interface type. You don't really care about those in an application. The user (or developer) just wants to select 1080P60 or WUXGA.
Ok.
Quoted 4 lines
I am frankly not certain anymore if we want to have the standard as part of the macro name. Something like
V4L2_DV_HDTV_1920X1080P60might be more appropriate, with comments next to it referring to the relevant standards depending on the physical interface type.That's the problem with the namespace. I think that that's basically the reason why Xorg never created a macro naming for the resolutions. Whatever namespace we choose, we'll have troubles. I bet that, with your proposal, we'll end by having conflicts between two different standards that implement the same resolution/fps/"progressiveness".
Quoted 5 lines
Quoted 2 lines
And instead of using flags to denote the used standard, it might be better to reserve a u16 for the standard.
It seems that a standards bitmask may work better, as, eventually, the same timing may be defined by more than one standard.
That's makes the interesting assumption that there will be no more than 32 standards :-)
Quoted 7 lines
Quoted 2 lines
History has shown that video formats stay around for a looong time, but the standards describing them evolve continuously.
True. We might end to have some timings that are different on a new standard revision, in order to fix some issue. That's why I think we need to expose all the timings at the DV enum ioctl. This gives more flexibility to the application to reject an specific standard if needed for whatever reason.
Let's stop discussing this for a bit until we get some feedback from others. It's more a ping-pong match between us right now and I would really like to hear the opinions of others (Samsung in particular).
Regards,
Hans
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
Em 07-07-2011 11:58, Hans Verkuil escreveu:
Quoted 211 lines · On Thursday, July 07, 2011 15:52:53 Mauro Carvalho Chehab wrote:
Quoted 210 lines
Em 07-07-2011 08:33, Hans Verkuil escreveu:
Quoted 209 lines · On Wednesday, July 06, 2011 21:39:46 Mauro Carvalho Chehab wrote:
Quoted 200 lines
Em 06-07-2011 09:14, Hans Verkuil escreveu:
Quoted 138 lines
Quoted 117 lines
Em 06-07-2011 08:31, Hans Verkuil escreveu:
Quoted 116 lines
Quoted 115 lines
Em 05-07-2011 10:20, Hans Verkuil escreveu:
Quoted 21 lines
Quoted 9 lines
I failed to see what information is provided by the "presets" name. If
this were removed
from the ioctl, and fps would be added instead, the API would be clearer. The only
adjustment would be to use "index" as the preset selection key. Anyway,
it is too late
for such change. We need to live with that.Adding the fps solves nothing. Because that still does not give you specific timings.
You can have 1920x1080P60 that has quite different timings from the CEA-861 standard
and that may not be supported by a TV.If you are working with HDMI, then you may want to filter all supported
presets to
those of the CEA standard.Quoted 5 lines
That's one thing that is missing at the moment: that presets belonging to a certain
standard get their own range. Since we only do CEA861 right now it hasn't been an
issue, but it will.I prepared a long email about that, but then I realized that we're investing our time into
something broken, at the light of all DV timing standards. So, I've dropped it and
started from scratch.From what I've got, there are some hardware that can only do a limited set
of DV timings.
If this were not the case, we could simply just use the VIDIOC_S_DV_TIMINGS/VIDIOC_G_DV_TIMINGS,
and put the CEA 861 and VESA timings into some userspace library.In other words, the PRESET API is meant to solve the case where hardware
only support
a limited set of frequencies, that may or may not be inside the CEA standard.Let's assume we never added the current API, and discuss how it would properly fulfill
the user needs. An API that would likely work is:struct v4l2_dv_enum_preset2 { __u32 index; __u8 name[32]; /* Name of the preset timing */ struct v4l2_fract fps;#define
DV_PRESET_IS_PROGRESSIVE1<<31
#defineDV_PRESET_SPEC(flag)(flag &&0xff)
#defineDV_PRESET_IS_CEA8611
#defineDV_PRESET_IS_DMT2
#defineDV_PRESET_IS_CVF3
#defineDV_PRESET_IS_GTF4
#defineDV_PRESET_IS_VENDOR_SPECIFIC5
__u32flags; /* Interlaced/progressive, DV specs, etc */
__u32width; /* width in pixels */
__u32height; /* height in lines */
__u32polarities; /* Positive or negative polarity */
__u64pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
__u32hfrontporch; /* Horizpontal front porch in pixels */
__u32hsync; /* Horizontal Sync length in pixels */
__u32hbackporch; /* Horizontal back porch in pixels */
__u32vfrontporch; /* Vertical front porch in pixels */
__u32vsync; /* Vertical Sync length in lines */
__u32vbackporch; /* Vertical back porch in lines */
__u32il_vfrontporch; /* Vertical front porch for bottom field of
* interlaced field formats */
__u32il_vsync; /* Vertical sync length for bottom field of
* interlaced field formats */
__u32il_vbackporch; /* Vertical back porch for bottom field of
* interlaced field formats */
__u32reserved[4];
};#define
VIDIOC_ENUM_DV_PRESETS2_IOWR('V', 83, structv4l2_dv_enum_preset2)
#defineVIDIOC_S_DV_PRESET2_IOWR('V', 84, u32 index)
#defineVIDIOC_G_DV_PRESET2_IOWR('V', 85, u32 index)Such preset API seems to work for all cases. Userspace can use any DV timing
information to select the desired format, and don't need to have a switch
for
a preset macro to try to guess what the format actually means. Also, there's no
need to touch at the API spec every time a new DV timeline is needed.Also, it should be noticed that, since the size of the data on the above
definitions
are different than the old ones,_IOmacros will provide a different magic
number,
so, adding these won't break the existing API.So, I think we should work on this proposal, and mark the existing one as
deprecated.Quoted 5 lines
Quoted 2 lines
This proposal makes it very hard for applications to directly select a format like 720p50 because the indices can change at any time.
Why? All the application needs to do is to call
VIDIOC_ENUM_DV_PRESETS2, check what line it wants,It's not so easy as you think to find the right timings: you have to check many parameters to be certain you have the right one and not some subtle variation.
Quoted 11 lines
and do a
S_DV_PRESET2, just like any other place
where V4L2 defines an ENUM function.The enum won't change during application runtime, so, they can be stored if the application would need to switch to other formats latter.
Quoted 4 lines
I think
this is a very desirable feature, particularly for apps running on embedded systems where the hardware is known. This was one of the design considerations at the time this API was made.Quoted 5 lines
Quoted 3 lines
This is a very weak argument. With just one ENUM loop, the application can quickly get the right format(s), and associate them with any internal namespace.
That actually isn't easy at all.
For the trivial case where the application just wants one of the CEA861 standard (or VESA DMT), the check is trivial.
The speed of the test can even be improved if the order at the struct would be changed to be:
struct v4l2_dv_enum_preset2 { __u32 index; __u32 flags; struct v4l2_fract fps;(quoted diff) +0
-0__u32 width; /* width in pixels */ __u32 height; /* height in lines */}
The dv preset seek routine at the application can then be coded as:
struct
seek_preset{ /* Need to follow the same order/arguments asv4l2_dv_enum_preset2*/struct v4l2_fract fps;(quoted diff) +0
-0__u32 width; __u32 height;};
struct myapp_preset { __u32 flags; struct seek_preset preset; };struct myapp_preset cea861_vic16 = { .flags = DV_PRESET_IS_PROGRESSIVE | DV_PRESET_IS_CEA861, .width = 1920, .height = 1080, };int
return_dv_preset_index(fp, struct myapp_preset *needed){ int found = -1; struct v4l2_dv_enum_preset2 preset; do { rc = ioctl(fp, VIDIOC_ENUM_DV_PRESETS, &preset); if (rc == -1) break; if ((preset.flags & needed->flags) != needed->flags) continue; if (!memcmp(&preset.fps, &needed->preset)) { found = preset->index; break; } } while (!rc && found < 0); }Quoted 5 lines
void main(void) {
...index = return_dv_preset_index(fp, cea861_vic16);...
}And the current equivalent is:
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
struct v4l_dv_preset preset = { V4L2_DV_1080P60 }; ioctl(f, VIDIOC_S_DV_PRESET, &preset);Yes, except for the fact that:
- API spec needs addition for every new preset that we standardize;True. But I believe that it is very useful to have such standardized presets.
Here is one of the points that we disagree. I think that a proper seek mechanism is preferred, providing more information for the userspace to do the right choice.
Quoted 10 lines
Quoted 3 lines
- It doesn't support a vendor-specific preset, as there's no way to discover what are the timing constants for the preset;That's why I propose a
G_PRESET_TIMINGS.In my experience most applications do not care about such timings unless you want to support a wide range of formats, in which case you are more likely to use the
DV_TIMINGSAPI (if supported by the hardware). Note that the fps+flags fields should certainly be added tov4l2_enum_dv_preset. No doubt about that.
If hardware or driver doesn't support, apps need to use the preset API.
Quoted 3 lines
Quoted 1 line
- Namespacing is broken.
That could be improved, indeed. Deciding on a right namespace isn't that easy, though.
I seriously doubt that we could find a proper future-proof namespacing. Standards will add more things, and might eventually review a few badly-specified timings.
Quoted 10 lines
Quoted 10 lines
Quoted 2 lines
You want a whole new API that in my view makes things only more complicated and misses existing functionality (such as the one above).
I prefer to fix the API, if it is possible/doable on a non-messy way. Yet, as this API is currently used only by two drivers (DaVinci and tvp7002), it is better to fix it sooner than later, to avoid more efforts on fixing it.
Quoted 2 lines
Whereas with a few tweaks and possibly a new
VIDIOC_G_PRESET_TIMINGSioctl you can offer the same functionality with the existing API.
Quoted 6 lines
Quoted 3 lines
You're proposing a new "enum" preset timings that would present the missing info that
VIDIOC_S_DV_PRESETdoesn't present, except that an application will need to call 2 ioctl's in order to enumerate the presets, instead of one.Very few applications actually need such precise information. Resolution, fps and interlaced/progressive is enough for most.
most =! all. Removing the amount of provided information due to the assumption that applications may not want is a wrong decision for such API. There's no big deal on providing all preset parameters to userspace. This is not a time-critical API, and will be called once at the application runtime.
If, on some particular application, a developer found that this might actually represent a significant amount of time for whatever reason (with I seriously doubt), it could just code a "cache" file that will be filled the first time the application boots with a new kernel, replicating exactly the same mechanism as you've conceived before: once the association is found, it will just use the index discovered at the first run.
Quoted 18 lines
Quoted 18 lines
Quoted 6 lines
So, once again my proposal:
ENUM_DV_PRESETSis extended with a flags field and a fpsv4l2_fract(orframe_period, whatever works best). Flags give you progressive vs interlaced, and I've no problem adding things likeIS_CEA861or similar flags to that.Quoted 8 lines
The current set of presets remain in use (but get renamed with the old ones as aliases) for CEA861 and (in the near future) VESA DMT timings.
Note that all the hardware I
know that has predefined timings does so only for those two standards. Makes sense
too: only the consumer electronic standards for SDTV/HDTV and the VGA-like PC monitor standards are typical standards.We need a further investigation about that. What are the predefined timings defined for Samgung hardware?
Quoted 7 lines
Quoted 4 lines
Also, one possible implementation for output devices would be to use EDID to retrieve the timings acceptable by the monitor/TV and compare to its internal capabilities. This is probably the only way to avoid requiring
CAP_SYS_ADMINfor the DV calls, as a bad timing may damage the monitor and/or the V4L device.Is
CAP_SYS_ADMINneeded today to set graphics modelines? I am not aware of any checks being done (other than probably against EDID information, if present).
With great power comes great responsibility. The VESA FB driver explicitly checks for CAP_SYS_ADMIN. Xorg process runs as root, as almost all resources required for controlling the video display requires root, and a non-root access may damage the hardware and/or BIOS. The security solution used there is to lock things like /dev/mem to be accessible only by root (e. g. the entire char device is protected).
In the case of V4L, we need to provide an ioctl-based security mechanism, as only a very few set of ioctl's can be dangerous.
Quoted 2 lines
To my (limited) knowledge hardware that can be broken that way is very, very old and very unlikely to have EDID capabilities.
A quick Google search for "permanent damage lcd due to wrong video settings" hits 5.380.000 pages. A look at those two specs:
http://www.viewsonic.com.au/support/manuals/files/LCD/Series%20X/VX510-1%20User%20Guide%20English.pdf http://pt.scribd.com/doc/20791522/VA2226w-LCD-Display
Both have the same kind of warning:
WARNING: Do not set the graphics card in your computer to exceed the
maximum refresh rate of 85Hz/ 1024 x 768@75Hz; doing so may result in permanent damage to your LCD display.
(VX510 manual, page 7. A similar text is at page 8 of VA2226w manual)
The VA2226w manual was written in 2008, so it is very likely that it supports EDID.
So, AFAIK, your assumption is wrong. Monitors can be damaged if a wrong DV timing is selected.
We need to restrict the DV S_ preset/timings calls for output devices with CAP_SYS_ADMIN, except if the driver or firmware provides some other explicit mechanism to protect such damages.
Quoted 6 lines
Quoted 2 lines
If a vendor decides to implement something like that (either in firmware or on Kernel), then the list of presets will likely have a mix with all standards.
The EDID does not make the list of presets, that is based on the capabilities of the transmitter (or receiver, for that matter). The EDID may be used to filter the list of presets, though.
Yes, that's what I meant to say. Setting to a timing that is compatible with EDID information doesn't need to require root access, but it there's no such check in kernel/hardware/firmware, then userspace calls need protection mechanisms.
Quoted 11 lines
Quoted 10 lines
Quoted 2 lines
For presets not related to those standards the easiest method I see is just to assign a preset like (
0x80000000| index).I've thinked about that already. Yeah, this would fix part of the problem, allowing the implementation of vendor-specific timings and the support for other standards not covered yet. There are, however, some issues:
1) the API will be messier;
2) Imagine that a new timing were added as a vendor-specific timing. Later,
that standard got recognized by some forum and were added at some standard. In that case, the vendor cannot simply change the preset index, as it will break the API.
Quoted 3 lines
Why would that break the API? The preset was
0x80000000| 42 (or whatever), now it becomesV4L2_DV_FOO_WXHP50. You couldn't rely on the first preset to stay the same anyway.
Because the preset index is a sequential number. V4L2_DV_FOO_WXHP50 is index #42 on driver foo, but it may have index #10 on other drivers.
See the issue? Using a preset macro for seek is not flexible.
An implementation like G_PRESET_FOR_STD that will return the index for a macro name and a full-featured preset ENUM would be better than the current mechanism.
Yet, I fail to see that seeking for a preset internally at the driver (either with the current G/S PRESET ioctl's or with a newly G_PRESET_FOR_STD) would really bring and significant performance improvement to justify not implementing an ENUM loop in userspace.
Quoted 33 lines
Quoted 11 lines
Also, duplicating the information is not a good idea. With the preset standards as flags, when this happens, all the driver needs is to add a new flag, without breaking the API.
Quoted 2 lines
We may need to add a
VIDIOC_G_PRESET_TIMINGS, but I am not certain we really need that.ENUM_DV_PRESETSmay give sufficient information already.This will only work if there aren't two timings with the same fps/resolution, including on the vendor-specific timings. Let's suppose that there are two non-DMT, non-CEA standars, from two different vendors, that have different timings. With the current API, there's no way to differentiate them.
That's why
G_PRESET_TIMINGSmay be necessary. I'm just doubtful that applications will know what to do with that information.Quoted 7 lines
Quoted 4 lines
Based on my experience with GTF/CVT formats I strongly suspect that drivers will need to implement a
VIDIOC_QUERY_DV_TIMINGSioctl and let a userspace library detect the GTF/CVT standard. This is surprisingly complex (mostly due to extremely shoddy standards).Maybe, but I bet that there are a few GTF/CVT standards that are implemented on a large amount of TV/monitors. It may make sense to have those added as presets.
Sure, many TVs and monitors support GTF and CVT, but they are not presets as such but algorithms to allow almost all possible combinations of resolution and fps.
CVT formats can be detected based on hsync and vsync polarities and the vertical sync width. GTF is much harder to detect, unfortunately.
The CEA standard has only positive hsync+vsync or negative hsync+vsync polarities. Except for one single timing (VIC 39). Which @#$^%@@ imbecile came up with that bright idea?!
Quoted 7 lines
Quoted 4 lines
I'd love to get some feedback from other developers about that. Samsung?
The issue with
S_DV_TIMINGSis that we likely need to request forCAP_SYS_ADMIN, as a bad timing may damage the hardware.How would this help? Changing my graphics card resolution today doesn't require me to be root either.
It does requre. Xorg runs as root:
$ ls -la /usr/bin/Xorg -rws--x--x 1 root root 1932152 Abr 7 18:46 /usr/bin/Xorg
This type of permission was ever required since XFree86 old days.
Quoted 42 lines
The only time this might conceivably be an issue is for analog
video transmitters. I would need to do more research on this. Does anyone else know much about what constitutes a bad timing and how it might damage hardware?Quoted 38 lines
Currently, there's not such requirement for DaVinci/tvp7002, nor v4l2-ioctl enforces that, but this needs a fix.
Quoted 1 line
For GTF/CVT output you want to use
VIDIOC_S_DV_TIMINGSanyway.True.
Quoted 7 lines
The reason
there is no GTF/CVT support yet is simply because I don't want to make proposals unless I actually implemented it and worked with it for some time to see what works best.Everything you can do with your proposal you can do with mine, and mine doesn't deprecate anything.
See above.
Quoted 8 lines
BTW, in the case of HD-SDI transmitters/receivers the CEA-861 standard does not apply, strictly speaking. That standard is covered by SMPTE 292M. It does support most of the usual SDTV/HDTV formats as are defined in CEA-861, except that things like front/back porch etc. do not apply to this serial interface. The idea behind the presets is that it defines industry standard resolution/framerate combinations, but the standards behind those differ per interface type. You don't really care about those in an application. The user (or developer) just wants to select 1080P60 or WUXGA.
Ok.
Quoted 4 lines
I am frankly not certain anymore if we want to have the standard as part of the macro name. Something like
V4L2_DV_HDTV_1920X1080P60might be more appropriate, with comments next to it referring to the relevant standards depending on the physical interface type.That's the problem with the namespace. I think that that's basically the reason why Xorg never created a macro naming for the resolutions. Whatever namespace we choose, we'll have troubles. I bet that, with your proposal, we'll end by having conflicts between two different standards that implement the same resolution/fps/"progressiveness".
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
And instead of using flags to denote the used standard, it might be better to reserve a u16 for the standard.
It seems that a standards bitmask may work better, as, eventually, the same timing may be defined by more than one standard.
That's makes the interesting assumption that there will be no more than 32 standards :-)
:) Well, we may use u64 ;)
I'm in doubt between using u16 or a bitmask, as we may have the same timings defined on two or more standards.
Quoted 11 lines
Quoted 7 lines
Quoted 2 lines
History has shown that video formats stay around for a looong time, but the standards describing them evolve continuously.
True. We might end to have some timings that are different on a new standard revision, in order to fix some issue. That's why I think we need to expose all the timings at the DV enum ioctl. This gives more flexibility to the application to reject an specific standard if needed for whatever reason.
Let's stop discussing this for a bit until we get some feedback from others. It's more a ping-pong match between us right now and I would really like to hear the opinions of others (Samsung in particular).
Agreed.
Thanks,
Mauro
Re: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset
In reply to Mauro Carvalho ChehabHi Mauro, Hans,
I am really surprised by the havoc caused by the little 2-line patch.
Let me sum up what I (don't) like in Hans' and Mauro's approaches:
Hans approach:
- extend v4l2_enum_dv_preset with fps and flags fields,
- allow enumerating presets by both index and preset code
- add standard to macro names for presets
Pros:
- backward compatible with existing api
- very simple and effective. Setting desired preset using only 2 lines of code
- easy to add unfortunate 1080p59_94
- easy to differentiate 1080p59_94 from 1080p60 using VIDIOC_ENUM_DV_PRESET
Cons:
- number of existing macros must increase extensionally with number of features. Height, progressiveness, frequency are already present. Standard family is added in Hans' RFC. Some presets involve width. Therefore multiple holes are expected making usage of macros very unreliable.
- it is not possible to use VIDIOC_S_DV_PRESET to handle case when application just wants a preset that has 720 height. The application has to enumerate all existing/possible presets (number of possible combinations may be large) to find a preset that suits to the application's needs.
- unnecessary redundancy, preset is nothing more than a standardized index
Mauro's approach:
- enumerate all possible presets using VIDIOC_ENUM_DV_PRESETS2
- choose suitable preset using index field from
Pros:
- consistency: preset can only be addressed by index field,
- no preset macros
Cons:
- structure v4l2_dv_enum_preset2 contains BT.656/BT.1120 timing related data, the structure should be more general. Most application would not use timing fields, so maybe there is no need of adding them to the structure.
- applications still has to enumerate through all possible combinations to find a suitable preset
- not compatible with existing API, two way to configure DV hardware
I propose following requirements for DV preset api basing on pros and cons from overmentioned approaches.
- an application should be able to choose a preset with desired parameters using single ioctl call
- preset should be accessed using single key. I prefer to use index as a key because it gives more flexibility to a driver.
- compatible with existing api as much as possible
What do you think about approach similar to S_FMT? Please look at the code below.
struct v4l2_dv_preset2 {
u16 width;
u16 height;
v4l2_fract fps;
u32 flags; /* progressiveness, standard hints, rounding constraints */ u32 reserved[];
};
/* Values for the standard field */
#define V4L2_DV_BT_656_1120 0 /* BT.656/1120 timing type */
struct v4l2_enum_dv_preset2 {
u32 index;
char name[32];
struct v4l2_dv_preset2 preset;
struct v4l2_dv_timings timings; /* to be removed ? */ u32 reserved[];
};
#define VIDIOC_ENUM_DV_PRESETS2 _IOWR('V', 83, struct v4l2_dv_enum_preset2)
#define VIDIOC_S_DV_PRESET2 _IOWR('V', 84, struct v4l2_dv_preset2)
#define VIDIOC_G_DV_PRESET2 _IOWR('V', 85, struct v4l2_dv_preset2)
#define VIDIOC_TRY_DV_PRESET2 _IOWR('V', 86, struct v4l2_dv_preset2)To set a mode with height 720 lines the applications would execute code below:
struct v4l2_dv_preset2 preset = { .height = 720 };ioctl(fd, VIDIOC_S_DV_PRESET2, &preset);
The preset is selected using the most interesting features like width/height/frequency and progressiveness. The driver would find the preset with vertical resolution as close as possible to 720.
The width and fps is zero so driver is free to choose suitable/default ones.
The field flags may contain hind about choosing preset that belong to specific DV standard family.
I do not feel competent in the field of DV standard. Could give me more ideas about flags?
The flags could contain constraint bits similar to ones presented in SELECTION api.
Maybe structures v4l2_dv_preset and v4l2_enum_dv_presets could be utilized for purpose of presented api. Maybe using some union/structure align magic it would be possible to keep binary compatibility with existing programs.
For now, I have removed unfortunate 1080P59_94 format from S5P-TV driver. I would be very happy if the driver was merged into 3.1.
I think that it would be not possible due to 1080p59_94 issue.
The driver did not lose much of its functionality because it still supports 1080p60. Moreover, adding 1080p59_94 is relatively trivial.
I hope you find this information useful.
Regards,
Tomasz Stanislawski
PATCH v6 2/8 v4l: add g_tvnorms_output callback to V4L2 subdev
In reply to Tomasz StanislawskiCallback is used to acquire TV norms supported by a subdev. It is used to avoid having standards in top-level driver.
--- include/media/v4l2-subdev.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
include/media/v4l2-subdev.h +4 -0
@@ -225,6 +225,9 @@ struct v4l2_subdev_audio_ops { s_std_output: set v4l2_std_id for video OUTPUT devices. This is ignored by video input devices. + g_tvnorms_output: get v4l2_std_id with all standards supported by video + OUTPUT device. This is ignored by video input devices. + s_crystal_freq: sets the frequency of the crystal used to generate the clocks in Hz. An extra flags field allows device specific configuration regarding clock frequency dividers, etc. If not used, then set flags
@@ -261,6 +264,7 @@ struct v4l2_subdev_video_ops {int (*s_crystal_freq)(struct v4l2_subdev *sd,u32 freq,u32 flags);int (*s_std_output)(struct v4l2_subdev *sd,v4l2_std_id std);int (*querystd)(struct v4l2_subdev *sd,v4l2_std_id *std); +int (*g_tvnorms_output)(struct v4l2_subdev *sd,v4l2_std_id *std);int (*g_input_status)(struct v4l2_subdev *sd,u32 *status);int (*s_stream)(struct v4l2_subdev *sd,int enable);int (*cropcap)(struct v4l2_subdev *sd,struct v4l2_cropcap *cc);
Signature · 1 line
1.7.5.4
PATCH v6 3/8 v4l: add g_dv_preset callback to V4L2 subdev
In reply to Tomasz StanislawskiCallback is used to acquire current digital video preset from a subdev. It is used to avoid keeping dv preset in top-level driver.
--- include/media/v4l2-subdev.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
include/media/v4l2-subdev.h +4 -0
@@ -242,6 +242,8 @@ struct v4l2_subdev_audio_ops { s_dv_preset: set dv (Digital Video) preset in the sub device. Similar to s_std() + g_dv_preset: get current dv (Digital Video) preset in the sub device. + query_dv_preset: query dv preset in the sub device. This is similar to querystd()
@@ -282,6 +284,8 @@ struct v4l2_subdev_video_ops { struct v4l2_dv_enum_preset *preset);int (*s_dv_preset)(struct v4l2_subdev *sd,struct v4l2_dv_preset *preset); +int (*g_dv_preset)(struct v4l2_subdev *sd, +struct v4l2_dv_preset *preset);int (*query_dv_preset)(struct v4l2_subdev *sd,struct v4l2_dv_preset *preset); int (*s_dv_timings)(struct v4l2_subdev *sd,
Signature · 1 line
1.7.5.4
PATCH v6 4/8 v4l: add g_std_output callback to V4L2 subdev
In reply to Tomasz StanislawskiCallback is used to acquire current analog TV standard from a subdev. It is used to avoid keeping current standard in top-level driver.
--- include/media/v4l2-subdev.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
include/media/v4l2-subdev.h +4 -0
@@ -225,6 +225,9 @@ struct v4l2_subdev_audio_ops { s_std_output: set v4l2_std_id for video OUTPUT devices. This is ignored by video input devices. + g_std_output: get current standard for video OUTPUT devices. This is ignored + by video input devices. + g_tvnorms_output: get v4l2_std_id with all standards supported by video OUTPUT device. This is ignored by video input devices.
@@ -265,6 +268,7 @@ struct v4l2_subdev_video_ops {int (*s_routing)(struct v4l2_subdev *sd,u32 input,u32 output,u32 config);int (*s_crystal_freq)(struct v4l2_subdev *sd,u32 freq,u32 flags);int (*s_std_output)(struct v4l2_subdev *sd,v4l2_std_id std); +int (*g_std_output)(struct v4l2_subdev *sd,v4l2_std_id *std);int (*querystd)(struct v4l2_subdev *sd,v4l2_std_id *std);int (*g_tvnorms_output)(struct v4l2_subdev *sd,v4l2_std_id *std);int (*g_input_status)(struct v4l2_subdev *sd,u32 *status);
Signature · 1 line
1.7.5.4
PATCH v6 5/8 v4l: fix v4l_fill_dv_preset_info function
In reply to Tomasz StanislawskiThe function fills struct v4l2_dv_enum_preset with appropriate preset parameters but it forgets to zero field named reserved. This patch fixes this bug.
--- drivers/media/video/v4l2-common.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/media/video/v4l2-common.c +2 -0
@@ -592,6 +592,8 @@ int v4l_fill_dv_preset_info(u32 preset, struct v4l2_dv_enum_preset *info) info->width = dv_presets[preset].width; info->height = dv_presets[preset].height;strlcpy (info->name, dv_presets[preset].name,sizeof (info->name)); +/* assure that reserved fields are zeroed */ +memset (info->reserved,0 ,sizeof (info->reserved));return 0 ; }EXPORT_SYMBOL_GPL (v4l_fill_dv_preset_info);
Signature · 1 line
1.7.5.4
Re: [PATCH 5/8] v4l: fix v4l_fill_dv_preset_info function
Em 29-06-2011 09:51, Tomasz Stanislawski escreveu:
Quoted 14 lines
The function fills struct
v4l2_dv_enum_presetwith appropriate preset parameters but it forgets to zero field named reserved. This patch fixes this bug.Signed-off-by Tomasz Stanislawski <[email protected]>--- drivers/media/video/v4l2-common.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/media/video/v4l2-common.c +0
-0
drivers/media/video/v4l2-common.c int v4l_fill_dv_preset_info(u32 preset, struct v4l2_dv_enum_preset *info) · line 599
Quoted 8 lines
drivers/media/video/v4l2-common.c +2
-0@@ -592,6 +592,8 @@ int v4l_fill_dv_preset_info(u32 preset, struct v4l2_dv_enum_preset *info) info->width = dv_presets[preset].width; info->height = dv_presets[preset].height;strlcpy (info->name, dv_presets[preset].name,sizeof (info->name)); +/* assure that reserved fields are zeroed */ +memset (info->reserved,0 ,sizeof (info->reserved));return 0 ; }EXPORT_SYMBOL_GPL (v4l_fill_dv_preset_info);
This patch is not needed, except if you're doing a different logic. v4l2-ioctl makes sure of cleaning the reserved and write fields from the structs before passing the syscall to the drivers.
So, if you're filling data from an userspace call, you don't need to use. If you're instead allocating data, use *zalloc calls.
Cheers,
Mauro
PATCH v6 6/8 v4l: s5p-tv: add drivers for HDMI on Samsung S5P platform
In reply to Tomasz StanislawskiAdd drivers for HDMI outputs on Samsung platforms from S5P family.
- HDMIPHY - auxiliary I2C driver need by HDMI driver
- HDMI - generation and control of streaming by HDMI output
Drivers are using:
- v4l2 framework
- runtime PM
--- drivers/media/video/Kconfig | 2 + drivers/media/video/Makefile | 1 + drivers/media/video/s5p-tv/Kconfig | 49 ++ drivers/media/video/s5p-tv/Makefile | 13 + drivers/media/video/s5p-tv/hdmi_drv.c | 1043 ++++++++++++++++++++++++++++++ drivers/media/video/s5p-tv/hdmiphy_drv.c | 196 ++++++ drivers/media/video/s5p-tv/regs-hdmi.h | 141 ++++ 7 files changed, 1445 insertions(+), 0 deletions(-) create mode 100644 drivers/media/video/s5p-tv/Kconfig create mode 100644 drivers/media/video/s5p-tv/Makefile create mode 100644 drivers/media/video/s5p-tv/hdmi_drv.c create mode 100644 drivers/media/video/s5p-tv/hdmiphy_drv.c create mode 100644 drivers/media/video/s5p-tv/regs-hdmi.h
drivers/media/video/Kconfig +2 -0
@@ -954,6 +954,8 @@ config VIDEO_S5P_MIPI_CSIS To compile this driver as a module, choose M here: the module will be called s5p-csis. +source "drivers/media/video/s5p-tv/Kconfig" + # # USB Multimedia device configuration #
drivers/media/video/Makefile +1 -0
@@ -169,6 +169,7 @@ 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_TV) += s5p-tv/ obj-$(CONFIG_ARCH_DAVINCI) += davinci/
drivers/media/video/s5p-tv/Kconfig new file +49 -0
49 lines not on this page · raw message
drivers/media/video/s5p-tv/Makefile new file +13 -0
@@ -0,0 +1,13 @@ +# drivers/media/video/samsung/tvout/Makefile +# +# Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. +# http://www.samsung.com/ +# Tomasz Stanislawski <[email protected]> +# +# Licensed under GPL + +obj-$(CONFIG_VIDEO_SAMSUNG_S5P_HDMIPHY) += s5p-hdmiphy.o +s5p-hdmiphy-y += hdmiphy_drv.o +obj-$(CONFIG_VIDEO_SAMSUNG_S5P_HDMI) += s5p-hdmi.o +s5p-hdmi-y += hdmi_drv.o +
drivers/media/video/s5p-tv/hdmi_drv.c new file +1043 -0
1,043 lines not on this page · raw message
drivers/media/video/s5p-tv/hdmiphy_drv.c new file +196 -0
196 lines not on this page · raw message
drivers/media/video/s5p-tv/regs-hdmi.h new file +141 -0
141 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH v6 7/8 v4l: s5p-tv: add SDO driver for Samsung S5P platform
In reply to Tomasz StanislawskiAdd drivers for Standard Definition output (SDO) on Samsung platforms from S5P family. The driver provides control over streaming analog TV via Composite connector.
Driver is using:
- v4l2 framework
- runtime PM
--- drivers/media/video/s5p-tv/Kconfig | 11 + drivers/media/video/s5p-tv/Makefile | 2 + drivers/media/video/s5p-tv/regs-sdo.h | 63 +++++ drivers/media/video/s5p-tv/sdo_drv.c | 479 +++++++++++++++++++++++++++++++++ 4 files changed, 555 insertions(+), 0 deletions(-) create mode 100644 drivers/media/video/s5p-tv/regs-sdo.h create mode 100644 drivers/media/video/s5p-tv/sdo_drv.c
drivers/media/video/s5p-tv/Kconfig +11 -0
@@ -46,4 +46,15 @@ config VIDEO_SAMSUNG_S5P_HDMIPHY as module. It is an I2C driver, that exposes a V4L2 subdev for use by other drivers. +config VIDEO_SAMSUNG_S5P_SDO + tristate "Samsung Analog TV Driver" + depends on VIDEO_DEV && VIDEO_V4L2 + depends on VIDEO_SAMSUNG_S5P_TV + help + Say Y here if you want support for the analog TV output + interface in S5P Samsung SoC. The driver can be compiled + as module. It is an auxiliary driver, that exposes a V4L2 + subdev for use by other drivers. This driver requires + hdmiphy driver to work correctly. + endif # VIDEO_SAMSUNG_S5P_TV
drivers/media/video/s5p-tv/Makefile +2 -0
@@ -10,4 +10,6 @@ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_HDMIPHY) += s5p-hdmiphy.o s5p-hdmiphy-y += hdmiphy_drv.o obj-$(CONFIG_VIDEO_SAMSUNG_S5P_HDMI) += s5p-hdmi.o s5p-hdmi-y += hdmi_drv.o +obj-$(CONFIG_VIDEO_SAMSUNG_S5P_SDO) += s5p-sdo.o +s5p-sdo-y += sdo_drv.o
drivers/media/video/s5p-tv/regs-sdo.h new file +63 -0
63 lines not on this page · raw message
drivers/media/video/s5p-tv/sdo_drv.c new file +479 -0
479 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH v6 8/8 v4l: s5p-tv: add TV Mixer driver for Samsung S5P platform
In reply to Tomasz StanislawskiAdd driver for TV Mixer on Samsung platforms from S5P family. Mixer is responsible for merging images from three layers and passing result to the output.
Interface:
- 3 video nodes with output queues
- support for multi plane API
- each nodes has up to 2 outputs (HDMI and SDO)
- outputs are controlled by S_STD and S_DV_PRESET ioctls
Drivers are using:
- v4l2 framework
- videobuf2
- videobuf2-dma-contig as memory allocator
- runtime PM
--- drivers/media/video/s5p-tv/Kconfig | 16 + drivers/media/video/s5p-tv/Makefile | 2 + drivers/media/video/s5p-tv/mixer.h | 354 +++++++++ drivers/media/video/s5p-tv/mixer_drv.c | 487 +++++++++++++ drivers/media/video/s5p-tv/mixer_grp_layer.c | 185 +++++ drivers/media/video/s5p-tv/mixer_reg.c | 541 ++++++++++++++ drivers/media/video/s5p-tv/mixer_video.c | 1006 ++++++++++++++++++++++++++ drivers/media/video/s5p-tv/mixer_vp_layer.c | 211 ++++++ drivers/media/video/s5p-tv/regs-mixer.h | 121 +++ drivers/media/video/s5p-tv/regs-vp.h | 88 +++ 10 files changed, 3011 insertions(+), 0 deletions(-) create mode 100644 drivers/media/video/s5p-tv/mixer.h create mode 100644 drivers/media/video/s5p-tv/mixer_drv.c create mode 100644 drivers/media/video/s5p-tv/mixer_grp_layer.c create mode 100644 drivers/media/video/s5p-tv/mixer_reg.c create mode 100644 drivers/media/video/s5p-tv/mixer_video.c create mode 100644 drivers/media/video/s5p-tv/mixer_vp_layer.c create mode 100644 drivers/media/video/s5p-tv/regs-mixer.h create mode 100644 drivers/media/video/s5p-tv/regs-vp.h
drivers/media/video/s5p-tv/Kconfig +16 -0
@@ -57,4 +57,20 @@ config VIDEO_SAMSUNG_S5P_SDO subdev for use by other drivers. This driver requires hdmiphy driver to work correctly. +config VIDEO_SAMSUNG_S5P_MIXER + tristate "Samsung Mixer and Video Processor Driver" + depends on VIDEO_DEV && VIDEO_V4L2 + depends on VIDEO_SAMSUNG_S5P_TV + select VIDEOBUF2_DMA_CONTIG + help + Say Y here if you want support for the Mixer in Samsung S5P SoCs. + This device produce image data to one of output interfaces. + +config VIDEO_SAMSUNG_S5P_MIXER_DEBUG + bool "Enable debug for Mixer Driver" + depends on VIDEO_SAMSUNG_S5P_MIXER + default n + help + Enables debugging for Mixer driver. + endif # VIDEO_SAMSUNG_S5P_TV
drivers/media/video/s5p-tv/Makefile +2 -0
@@ -12,4 +12,6 @@ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_HDMI) += s5p-hdmi.o s5p-hdmi-y += hdmi_drv.o obj-$(CONFIG_VIDEO_SAMSUNG_S5P_SDO) += s5p-sdo.o s5p-sdo-y += sdo_drv.o +obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MIXER) += s5p-mixer.o +s5p-mixer-y += mixer_drv.o mixer_video.o mixer_reg.o mixer_grp_layer.o mixer_vp_layer.o
drivers/media/video/s5p-tv/mixer.h new file +354 -0
354 lines not on this page · raw message
drivers/media/video/s5p-tv/mixer_drv.c new file +487 -0
487 lines not on this page · raw message
drivers/media/video/s5p-tv/mixer_grp_layer.c new file +185 -0
185 lines not on this page · raw message
drivers/media/video/s5p-tv/mixer_reg.c new file +541 -0
541 lines not on this page · raw message
drivers/media/video/s5p-tv/mixer_video.c new file +1006 -0
1,006 lines not on this page · raw message
drivers/media/video/s5p-tv/mixer_vp_layer.c new file +211 -0
211 lines not on this page · raw message
drivers/media/video/s5p-tv/regs-mixer.h new file +121 -0
121 lines not on this page · raw message
drivers/media/video/s5p-tv/regs-vp.h new file +88 -0
69 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.5.4
Part of the diff is not shown here. View the raw message.