Re: [PATCH v2 1/2] v4l: Add new alpha component control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Friday 25 November 2011 16:39:31 Sylwester Nawrocki wrote:
> This control is intended for the video capture or memory-to-memory devices
> that are capable of setting up a per-pixel alpha component to some
> arbitrary value. The V4L2_CID_ALPHA_COMPONENT control allows to set the
> alpha component for all pixels to a value in range from 0 to 255.
> 
> Signed-off-by: Sylwester Nawrocki <s.nawrocki@xxxxxxxxxxx>
> Signed-off-by: Kyungmin Park <kyungmin.park@xxxxxxxxxxx>
> ---
>  Documentation/DocBook/media/v4l/compat.xml         |   11 ++++++++
>  Documentation/DocBook/media/v4l/controls.xml       |   25
> +++++++++++++++---- .../DocBook/media/v4l/pixfmt-packed-rgb.xml        |  
>  7 ++++-
>  drivers/media/video/v4l2-ctrls.c                   |    7 +++++
>  include/linux/videodev2.h                          |    6 ++--
>  5 files changed, 45 insertions(+), 11 deletions(-)
> 
> diff --git a/Documentation/DocBook/media/v4l/compat.xml
> b/Documentation/DocBook/media/v4l/compat.xml index b68698f..0adda43 100644
> --- a/Documentation/DocBook/media/v4l/compat.xml
> +++ b/Documentation/DocBook/media/v4l/compat.xml
> @@ -2379,6 +2379,17 @@ that used it. It was originally scheduled for
> removal in 2.6.35. </orderedlist>
>      </section>
> 
> +    <section>
> +      <title>V4L2 in Linux 3.3</title>
> +      <orderedlist>
> +        <listitem>
> +	  <para>Added <constant>V4L2_CID_ALPHA_COMPONENT</constant> control
> +	    to the <link linkend="control">User controls class</link>.
> +	  </para>
> +        </listitem>
> +      </orderedlist>
> +    </section>
> +
>      <section id="other">
>        <title>Relation of V4L2 to other Linux multimedia APIs</title>
> 
> diff --git a/Documentation/DocBook/media/v4l/controls.xml
> b/Documentation/DocBook/media/v4l/controls.xml index 3bc5ee8..4fd83c0
> 100644
> --- a/Documentation/DocBook/media/v4l/controls.xml
> +++ b/Documentation/DocBook/media/v4l/controls.xml
> @@ -324,12 +324,6 @@ minimum value disables backlight compensation.</entry>
>  		(usually a microscope).</entry>
>  	  </row>
>  	  <row>
> -	    <entry><constant>V4L2_CID_LASTP1</constant></entry>
> -	    <entry></entry>
> -	    <entry>End of the predefined control IDs (currently
> -<constant>V4L2_CID_ILLUMINATORS_2</constant> + 1).</entry>
> -	  </row>
> -	  <row>
>  	    
<entry><constant>V4L2_CID_MIN_BUFFERS_FOR_CAPTURE</constant></entry>
>  	    <entry>integer</entry>
>  	    <entry>This is a read-only control that can be read by the
> application @@ -345,6 +339,25 @@ and used as a hint to determine the
> number of OUTPUT buffers to pass to REQBUFS. The value is the minimum
> number of OUTPUT buffers that is necessary for hardware to work.</entry>
>  	  </row>
> +	  <row id="v4l2-alpha-component">
> +	    <entry><constant>V4L2_CID_ALPHA_COMPONENT</constant></entry>
> +	    <entry>integer</entry>
> +	    <entry> Sets the alpha color component on the capture device or on
> +	    the capture buffer queue of a mem-to-mem device. When a mem-to-mem
> +	    device produces frame format that includes an alpha component
> +	    (e.g. <link linkend="rgb-formats">packed RGB image formats</link>)
> +	    and the alpha value is not defined by the mem-to-mem input data
> +	    this control lets you select the alpha component value of all
> +	    pixels. It is applicable to any pixel format that contains an 
alpha
> +	    component.
> +	    </entry>
> +	  </row>
> +	  <row>
> +	    <entry><constant>V4L2_CID_LASTP1</constant></entry>
> +	    <entry></entry>
> +	    <entry>End of the predefined control IDs (currently
> +	      <constant>V4L2_CID_ALPHA_COMPONENT</constant> + 1).</entry>
> +	  </row>
>  	  <row>
>  	    <entry><constant>V4L2_CID_PRIVATE_BASE</constant></entry>
>  	    <entry></entry>
> diff --git a/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml
> b/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml index
> 4db272b..c13278b 100644
> --- a/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml
> +++ b/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml
> @@ -428,8 +428,11 @@ colorspace
> <constant>V4L2_COLORSPACE_SRGB</constant>.</para> <para>Bit 7 is the most
> significant bit. The value of a = alpha bits is undefined when reading
> from the driver, ignored when writing to the driver, except when alpha
> blending has been negotiated for a -<link linkend="overlay">Video
> Overlay</link> or <link
> -linkend="osd">Video Output Overlay</link>.</para>
> +<link linkend="overlay">Video Overlay</link> or <link linkend="osd">
> +Video Output Overlay</link> or when alpha component has been configured
> +for a <link linkend="capture">Video Capture</link> by means of <link
> +linkend="v4l2-alpha-component"> <constant>V4L2_CID_ALPHA_COMPONENT
> +</constant> </link> control.</para>
> 
>      <example>
>        <title><constant>V4L2_PIX_FMT_BGR24</constant> 4 &times; 4 pixel
> diff --git a/drivers/media/video/v4l2-ctrls.c
> b/drivers/media/video/v4l2-ctrls.c index 5552f81..882cc84 100644
> --- a/drivers/media/video/v4l2-ctrls.c
> +++ b/drivers/media/video/v4l2-ctrls.c
> @@ -466,6 +466,7 @@ const char *v4l2_ctrl_get_name(u32 id)
>  	case V4L2_CID_ILLUMINATORS_2:		return "Illuminator 2";
>  	case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE:	return "Minimum Number of 
Capture
> Buffers"; case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT:	return "Minimum Number 
of
> Output Buffers"; +	case V4L2_CID_ALPHA_COMPONENT:		return "Alpha
> Component";
> 
>  	/* MPEG controls */
>  	/* Keep the order of the 'case's the same as in videodev2.h! */
> @@ -714,6 +715,12 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum
> v4l2_ctrl_type *type, /* Max is calculated as RGB888 that is 2^24 */
>  		*max = 0xFFFFFF;
>  		break;
> +	case V4L2_CID_ALPHA_COMPONENT:
> +		*type = V4L2_CTRL_TYPE_INTEGER;
> +		*step = 1;
> +		*min = 0;
> +		*max = 0xff;
> +		break;

Hmm. Do we really want to fix the max value to 0xff? The bits assigned to the
alpha component will vary between 1 (V4L2_PIX_FMT_RGB555X), 4 
(V4L2_PIX_FMT_RGB444) or 8 (V4L2_PIX_FMT_RGB32). It wouldn't surprise me to
see larger sizes as well in the future (e.g. 16 bits).

I think the max value should be the largest alpha value the hardware can 
support. The application has to set it to the right value that corresponds
to the currently chosen pixel format. The driver just copies the first N bits 
into the alpha value where N depends on the pixel format.

what do you think?

	Hans

>  	case V4L2_CID_FLASH_FAULT:
>  		*type = V4L2_CTRL_TYPE_BITMASK;
>  		break;
> diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
> index 4b752d5..fdda200 100644
> --- a/include/linux/videodev2.h
> +++ b/include/linux/videodev2.h
> @@ -1204,10 +1204,10 @@ enum v4l2_colorfx {
>  #define V4L2_CID_MIN_BUFFERS_FOR_CAPTURE	(V4L2_CID_BASE+39)
>  #define V4L2_CID_MIN_BUFFERS_FOR_OUTPUT		(V4L2_CID_BASE+40)
> 
> -/* last CID + 1 */
> -#define V4L2_CID_LASTP1                         (V4L2_CID_BASE+41)
> +#define V4L2_CID_ALPHA_COMPONENT		(V4L2_CID_BASE+41)
> 
> -/* Minimum number of buffer neede by the device */
> +/* last CID + 1 */
> +#define V4L2_CID_LASTP1                         (V4L2_CID_BASE+42)
> 
>  /*  MPEG-class control IDs defined by V4L2 */
>  #define V4L2_CID_MPEG_BASE 			(V4L2_CTRL_CLASS_MPEG | 0x900)
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux