[PATCH] v4l: Add simple packed Bayer raw12 pixel formats

2018-08-23 Thread Edgar Thier


These formats are compressed 12-bit raw bayer formats with four different
pixel orders. They are similar to 10-bit bayer formats 'IPU3'.
The formats added by this patch are

V4L2_PIX_FMT_SBGGR12SP
V4L2_PIX_FMT_SGBRG12SP
V4L2_PIX_FMT_SGRBG12SP
V4L2_PIX_FMT_SRGGB12SP

Signed-off-by: Edgar Thier 
---
Documentation/media/uapi/v4l/pixfmt-rgb.rst   |   1 +
.../media/uapi/v4l/pixfmt-srggb12sp.rst   | 123 ++
drivers/media/usb/uvc/uvc_driver.c|  20 +++
drivers/media/usb/uvc/uvcvideo.h  |  14 +-
include/uapi/linux/videodev2.h|   7 +
5 files changed, 164 insertions(+), 1 deletion(-)
create mode 100644 Documentation/media/uapi/v4l/pixfmt-srggb12sp.rst

diff --git a/Documentation/media/uapi/v4l/pixfmt-rgb.rst 
b/Documentation/media/uapi/v4l/pixfmt-rgb.rst
index 1f9a7e3a07c9..5da00bd085f1 100644
--- a/Documentation/media/uapi/v4l/pixfmt-rgb.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-rgb.rst
@@ -19,5 +19,6 @@ RGB Formats
pixfmt-srggb10-ipu3
pixfmt-srggb12
pixfmt-srggb12p
+pixfmt-srggb12sp
pixfmt-srggb14p
pixfmt-srggb16
diff --git a/Documentation/media/uapi/v4l/pixfmt-srggb12sp.rst
b/Documentation/media/uapi/v4l/pixfmt-srggb12sp.rst
new file mode 100644
index ..e99359709c90
--- /dev/null
+++ b/Documentation/media/uapi/v4l/pixfmt-srggb12sp.rst
@@ -0,0 +1,123 @@
+.. -*- coding: utf-8; mode: rst -*-
+
+.. _v4l2-pix-fmt-sbggr12sp:
+.. _v4l2-pix-fmt-sgbrg12sp:
+.. _v4l2-pix-fmt-sgrbg12sp:
+.. _v4l2-pix-fmt-srggb12sp:
+
+**
+V4L2_PIX_FMT_SBGGR12SP ('SRGGB12SP'), V4L2_PIX_FMT_SGBRG12SP ('SGBRG12SP'), 
V4L2_PIX_FMT_SGRBG12SP
('SGRBG12SP'), V4L2_PIX_FMT_SRGGB12SP ('SRGGB12SP')
+**
+
+12-bit Bayer formats
+
+Description
+===
+
+These four pixel formats are used by Intel IPU3 driver, they are raw
+sRGB / Bayer formats with 12 bits per sample with every 8 pixels packed
+to 24 bytes.
+The format is little endian.
+
+In other respects this format is similar to :ref:`V4L2-PIX-FMT-SRGGB10-IPU3`.
+Below is an example of a small image in V4L2_PIX_FMT_SBGGR12SP format.
+
+**Byte Order.**
+Each cell is one byte.
+
+.. tabularcolumns:: |p{0.8cm}|p{4.0cm}|p{4.0cm}|p{4.0cm}|p{4.0cm}|
+
+.. flat-table::
+
+* - start + 0:
+  - B\ :sub:`low`
+  - G\ :sub:`0001low`\ (bits 7--4)
+
+B\ :sub:`high`\ (bits 0--3)
+
+  - G\ :sub:`0001high`\
+  - B\ :sub:`0002low`
+
+* - start + 4:
+  - G\ :sub:`0003low`\ (bits 7--4)
+
+B\ :sub:`0002high`\ (bits 0--3)
+  - G\ :sub:`0003high`
+  - B\ :sub:`0004low`
+  - G\ :sub:`0005low`\ (bits 7--2)
+
+B\ :sub:`0004high`\ (bits 1--0)
+
+* - start + 8:
+  - G\ :sub:`0005high`
+  - B\ :sub:`0006low`
+  - G\ :sub:`0007low`\ (bits 7--4)
+B\ :sub:`0006high`\ (bits 3--0)
+  - G\ :sub:`0007high`
+
+* - start + 12:
+  - G\ :sub:`0008low`
+  - R\ :sub:`0009low`\ (bits 7--4)
+
+G\ :sub:`0008high`\ (bits 3--0)
+  - R\ :sub:`0009high`
+  - G\ :sub:`0010low`
+
+* - start + 16:
+  - R\ :sub:`0011low`\ (bits 7--4)
+G\ :sub:`00010high`\ (bits 3--0)
+  - R\ :sub:`0011high`
+  - G\ :sub:`0012low`
+  - R\ :sub:`0013low`\ (bits 7--4)
+G\ :sub:`0012high`\ (bits 3--0)
+
+* - start + 20
+  - R\ :sub:`0013high`
+  - G\ :sub:`0014low`
+  - R\ :sub:`0015low`\ (bits 7--4)
+G\ :sub:`0014high`\ (bits 3--0)
+  - R\ :sub:`0015high`
+
+* - start + 24:
+  - B\ :sub:`0016low`
+  - G\ :sub:`0017low`\ (bits 7--4)
+B\ :sub:`0016high`\ (bits 0--3)
+  - G\ :sub:`0017high`\
+  - B\ :sub:`0018low`
+
+* - start + 28:
+  - G\ :sub:`0019low`\ (bits 7--4)
+B\ :sub:`00018high`\ (bits 0--3)
+  - G\ :sub:`0019high`
+  - B\ :sub:`0020low`
+  - G\ :sub:`0021low`\ (bits 7--2)
+B\ :sub:`0020high`\ (bits 1--0)
+
+* - start + 32:
+  - G\ :sub:`0021high`
+  - B\ :sub:`0022low`
+  - G\ :sub:`0023low`\ (bits 7--4)
+B\ :sub:`0022high`\ (bits 3--0)
+  - G\ :sub:`0024high`
+
+* - start + 36:
+  - G\ :sub:`0025low`
+  - R\ :sub:`0026low`\ (bits 7--4)
+G\ :sub:`0025high`\ (bits 3--0)
+  - R\ :sub:`0026high`
+  - G\ :sub:`0027low`
+
+* - start + 40:
+  - R\ :sub:`0028low`\ (bits 7--4)
+G\ :sub:`00027high`\ (bits 3--0)
+  - R\ :sub:`0028high`
+  - G\ :sub:`0029low`
+  - R\ :sub:`0030low`\ (bits 7--4)
+G\ :sub:`0029high`\ (bits 3--0)
+
+* - start + 44:
+  - R\ :sub:`0030high`
+  - G\ :sub:`0031low`
+  - R\ :sub:`0033low`\ (bits 7--4)
+G\ :sub:`0032high`\ (bits 3--0)
+  - R\ :sub:`0033high`
diff --git a/drivers/media/usb/uvc/uvc_driver.c

Re: [PATCH] uvcvideo: Apply flags from device to actual properties

2018-01-02 Thread Edgar Thier
Hi Emmanuel,

>>> +   int flags = 0;
>>> +
>>> +   data = kmalloc(2, GFP_KERNEL);
> 
> Isn't 1 byte enough ?
> 

To quote from Kieran further up this thread:
>> kmalloc seems a bit of an overhead for 2 bytes (only one of which is used).
>> Can this use local stack storage?
>>
>> (Laurent, looks like you originally wrote the code that did that, was there a
>> reason for the kmalloc for 2 bytes?)
> Aha - OK, Just spoke with Laurent and - yes this is needed, as we can't DMA to
> the stack  - I hadn't realised the 'data' was being DMA'd ..

>>
>> All these are small issues. Let me try to address them, I'll send you an
>> updated patch shortly.

I'll be waiting.

Regards,

Edgar



Re: [PATCH] uvcvideo: Apply flags from device to actual properties

2017-12-14 Thread Edgar Thier
Hi,

Another month, another mail. Are there still issues keeping this from being 
merged?

Regards,

Edgar

On 11/15/2017 12:54 PM, Kieran Bingham wrote:
> Hi Edgar,
> 
> Thanks for addressing my concerns in this updated patch.
> 
> On 12/10/17 08:54, Edgar Thier wrote:
>>
>> Use flags the device exposes for UVC controls.
>> This allows the device to define which property flags are set.
>>
>> Since some cameras offer auto-adjustments for properties (e.g. auto-gain),
>> the values of other properties (e.g. gain) can change in the camera.
>> Examining the flags ensures that the driver is aware of such properties.
>>
>> Signed-off-by: Edgar Thier <i...@edgarthier.net>
> 
> Reviewed-by: Kieran Bingham <kieran.bingham+rene...@ideasonboard.com>
> 
>> ---
>>  drivers/media/usb/uvc/uvc_ctrl.c | 64 
>> ++--
>>  1 file changed, 49 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/media/usb/uvc/uvc_ctrl.c 
>> b/drivers/media/usb/uvc/uvc_ctrl.c
>> index 20397aba..8f902a41 100644
>> --- a/drivers/media/usb/uvc/uvc_ctrl.c
>> +++ b/drivers/media/usb/uvc/uvc_ctrl.c
>> @@ -1629,6 +1629,40 @@ static void uvc_ctrl_fixup_xu_info(struct uvc_device 
>> *dev,
>>  }
>>  }
>>
>> +/*
>> + * Retrieve flags for a given control
>> + */
>> +static int uvc_ctrl_get_flags(struct uvc_device *dev, const struct 
>> uvc_control *ctrl,
>> +const struct uvc_control_info *info)
>> +{
>> +u8 *data;
>> +int ret = 0;
>> +int flags = 0;
>> +
>> +data = kmalloc(2, GFP_KERNEL);
>> +if (data == NULL)
>> +return -ENOMEM;
>> +
>> +ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
>> + info->selector, data, 1);
>> +if (ret < 0) {
>> +uvc_trace(UVC_TRACE_CONTROL,
>> +  "GET_INFO failed on control %pUl/%u (%d).\n",
>> +  info->entity, info->selector, ret);
>> +} else {
>> +flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
>> +| UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
>> +| (data[0] & UVC_CONTROL_CAP_GET ?
>> +   UVC_CTRL_FLAG_GET_CUR : 0)
>> +| (data[0] & UVC_CONTROL_CAP_SET ?
>> +   UVC_CTRL_FLAG_SET_CUR : 0)
>> +| (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
>> +   UVC_CTRL_FLAG_AUTO_UPDATE : 0);
>> +}
>> +kfree(data);
>> +return flags;
>> +}
>> +
>>  /*
>>   * Query control information (size and flags) for XU controls.
>>   */
>> @@ -1636,6 +1670,7 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device 
>> *dev,
>>  const struct uvc_control *ctrl, struct uvc_control_info *info)
>>  {
>>  u8 *data;
>> +int flags;
>>  int ret;
>>
>>  data = kmalloc(2, GFP_KERNEL);
>> @@ -1659,24 +1694,15 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device 
>> *dev,
>>
>>  info->size = le16_to_cpup((__le16 *)data);
>>
>> -/* Query the control information (GET_INFO) */
>> -ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
>> - info->selector, data, 1);
>> -if (ret < 0) {
>> +flags = uvc_ctrl_get_flags(dev, ctrl, info);
>> +
>> +if (flags < 0) {
>>  uvc_trace(UVC_TRACE_CONTROL,
>> -  "GET_INFO failed on control %pUl/%u (%d).\n",
>> -  info->entity, info->selector, ret);
>> +  "Failed to retrieve flags (%d).\n", ret);
>> +ret = flags;
>>  goto done;
>>  }
>> -
>> -info->flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
>> -| UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
>> -| (data[0] & UVC_CONTROL_CAP_GET ?
>> -   UVC_CTRL_FLAG_GET_CUR : 0)
>> -| (data[0] & UVC_CONTROL_CAP_SET ?
>> -   UVC_CTRL_FLAG_SET_CUR : 0)
>> -| (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
>> -   UVC_CTRL_FLAG_AUTO_UPDATE : 0);
>> +info->flags = flags;
>>
>>  uvc_ctrl_fixup_xu_info(dev, ctrl, info);
>>
>> @@ -1890,6 +1916,7 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, 
>> struct uvc_control *ctrl,
>>  const struct uvc_control_info *info)
>>  {
>>  int ret = 0;
>> +int flags = 0;
>>
>>  ctrl->info = *info;
>>  INIT_LIST_HEAD(>info.mappings);
>> @@ -1902,6 +1929,13 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, 
>> struct uvc_control *ctrl,
>>  goto done;
>>  }
>>
>> +flags = uvc_ctrl_get_flags(dev, ctrl, info);
>> +if (flags < 0)
>> +uvc_trace(UVC_TRACE_CONTROL,
>> +  "Failed to retrieve flags (%d).\n", ret);
>> +else
>> +ctrl->info.flags = flags;
>> +
>>  ctrl->initialized = 1;
>>
>>  uvc_trace(UVC_TRACE_CONTROL, "Added control %pUl/%u to device %s "
>>


Re: [PATCH] uvcvideo: Apply flags from device to actual properties

2017-11-15 Thread Edgar Thier
Hi Kieran,

> I think it's easier to see updated patches if they are posted as a new thread,
> with an increased version number. [PATCH v2], [PATCH v3] etc...
>
> Not a problem now - but might help your updated patches get seen next time.

I will keep that in mind for next time. :)

> Looks like my concerns were addressed, so that's a Reviewed-by: tag from me.

Thanks!

Regards,

Edgar


Re: [PATCH] uvcvideo: Apply flags from device to actual properties

2017-11-15 Thread Edgar Thier
Hi,

I was wondering if there are any problems with my latest patch or if it simply 
slipped through.

Regards,

Edgar

On 10/12/2017 09:54 AM, Edgar Thier wrote:
> 
> Use flags the device exposes for UVC controls.
> This allows the device to define which property flags are set.
> 
> Since some cameras offer auto-adjustments for properties (e.g. auto-gain),
> the values of other properties (e.g. gain) can change in the camera.
> Examining the flags ensures that the driver is aware of such properties.
> 
> Signed-off-by: Edgar Thier <i...@edgarthier.net>
> ---
>  drivers/media/usb/uvc/uvc_ctrl.c | 64 
> ++--
>  1 file changed, 49 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_ctrl.c 
> b/drivers/media/usb/uvc/uvc_ctrl.c
> index 20397aba..8f902a41 100644
> --- a/drivers/media/usb/uvc/uvc_ctrl.c
> +++ b/drivers/media/usb/uvc/uvc_ctrl.c
> @@ -1629,6 +1629,40 @@ static void uvc_ctrl_fixup_xu_info(struct uvc_device 
> *dev,
>   }
>  }
> 
> +/*
> + * Retrieve flags for a given control
> + */
> +static int uvc_ctrl_get_flags(struct uvc_device *dev, const struct 
> uvc_control *ctrl,
> + const struct uvc_control_info *info)
> +{
> + u8 *data;
> + int ret = 0;
> + int flags = 0;
> +
> + data = kmalloc(2, GFP_KERNEL);
> + if (data == NULL)
> + return -ENOMEM;
> +
> + ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
> +  info->selector, data, 1);
> + if (ret < 0) {
> + uvc_trace(UVC_TRACE_CONTROL,
> +   "GET_INFO failed on control %pUl/%u (%d).\n",
> +   info->entity, info->selector, ret);
> + } else {
> + flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
> + | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
> + | (data[0] & UVC_CONTROL_CAP_GET ?
> +UVC_CTRL_FLAG_GET_CUR : 0)
> + | (data[0] & UVC_CONTROL_CAP_SET ?
> +UVC_CTRL_FLAG_SET_CUR : 0)
> + | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
> +UVC_CTRL_FLAG_AUTO_UPDATE : 0);
> + }
> + kfree(data);
> + return flags;
> +}
> +
>  /*
>   * Query control information (size and flags) for XU controls.
>   */
> @@ -1636,6 +1670,7 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,
>   const struct uvc_control *ctrl, struct uvc_control_info *info)
>  {
>   u8 *data;
> + int flags;
>   int ret;
> 
>   data = kmalloc(2, GFP_KERNEL);
> @@ -1659,24 +1694,15 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device 
> *dev,
> 
>   info->size = le16_to_cpup((__le16 *)data);
> 
> - /* Query the control information (GET_INFO) */
> - ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
> -  info->selector, data, 1);
> - if (ret < 0) {
> + flags = uvc_ctrl_get_flags(dev, ctrl, info);
> +
> + if (flags < 0) {
>   uvc_trace(UVC_TRACE_CONTROL,
> -   "GET_INFO failed on control %pUl/%u (%d).\n",
> -   info->entity, info->selector, ret);
> +   "Failed to retrieve flags (%d).\n", ret);
> + ret = flags;
>   goto done;
>   }
> -
> - info->flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
> - | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
> - | (data[0] & UVC_CONTROL_CAP_GET ?
> -UVC_CTRL_FLAG_GET_CUR : 0)
> - | (data[0] & UVC_CONTROL_CAP_SET ?
> -UVC_CTRL_FLAG_SET_CUR : 0)
> - | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
> -UVC_CTRL_FLAG_AUTO_UPDATE : 0);
> + info->flags = flags;
> 
>   uvc_ctrl_fixup_xu_info(dev, ctrl, info);
> 
> @@ -1890,6 +1916,7 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, 
> struct uvc_control *ctrl,
>   const struct uvc_control_info *info)
>  {
>   int ret = 0;
> + int flags = 0;
> 
>   ctrl->info = *info;
>   INIT_LIST_HEAD(>info.mappings);
> @@ -1902,6 +1929,13 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, 
> struct uvc_control *ctrl,
>   goto done;
>   }
> 
> + flags = uvc_ctrl_get_flags(dev, ctrl, info);
> + if (flags < 0)
> + uvc_trace(UVC_TRACE_CONTROL,
> +   "Failed to retrieve flags (%d).\n", ret);
> + else
> + ctrl->info.flags = flags;
> +
>   ctrl->initialized = 1;
> 
>   uvc_trace(UVC_TRACE_CONTROL, "Added control %pUl/%u to device %s "
> 


Re: [PATCH] uvcvideo: Apply flags from device to actual properties

2017-10-12 Thread Edgar Thier

Use flags the device exposes for UVC controls.
This allows the device to define which property flags are set.

Since some cameras offer auto-adjustments for properties (e.g. auto-gain),
the values of other properties (e.g. gain) can change in the camera.
Examining the flags ensures that the driver is aware of such properties.

Signed-off-by: Edgar Thier <i...@edgarthier.net>
---
 drivers/media/usb/uvc/uvc_ctrl.c | 64 ++--
 1 file changed, 49 insertions(+), 15 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index 20397aba..8f902a41 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -1629,6 +1629,40 @@ static void uvc_ctrl_fixup_xu_info(struct uvc_device 
*dev,
}
 }

+/*
+ * Retrieve flags for a given control
+ */
+static int uvc_ctrl_get_flags(struct uvc_device *dev, const struct uvc_control 
*ctrl,
+   const struct uvc_control_info *info)
+{
+   u8 *data;
+   int ret = 0;
+   int flags = 0;
+
+   data = kmalloc(2, GFP_KERNEL);
+   if (data == NULL)
+   return -ENOMEM;
+
+   ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
+info->selector, data, 1);
+   if (ret < 0) {
+   uvc_trace(UVC_TRACE_CONTROL,
+ "GET_INFO failed on control %pUl/%u (%d).\n",
+ info->entity, info->selector, ret);
+   } else {
+   flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
+   | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
+   | (data[0] & UVC_CONTROL_CAP_GET ?
+  UVC_CTRL_FLAG_GET_CUR : 0)
+   | (data[0] & UVC_CONTROL_CAP_SET ?
+  UVC_CTRL_FLAG_SET_CUR : 0)
+   | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
+  UVC_CTRL_FLAG_AUTO_UPDATE : 0);
+   }
+   kfree(data);
+   return flags;
+}
+
 /*
  * Query control information (size and flags) for XU controls.
  */
@@ -1636,6 +1670,7 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,
const struct uvc_control *ctrl, struct uvc_control_info *info)
 {
u8 *data;
+   int flags;
int ret;

data = kmalloc(2, GFP_KERNEL);
@@ -1659,24 +1694,15 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,

info->size = le16_to_cpup((__le16 *)data);

-   /* Query the control information (GET_INFO) */
-   ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
-info->selector, data, 1);
-   if (ret < 0) {
+   flags = uvc_ctrl_get_flags(dev, ctrl, info);
+
+   if (flags < 0) {
uvc_trace(UVC_TRACE_CONTROL,
- "GET_INFO failed on control %pUl/%u (%d).\n",
- info->entity, info->selector, ret);
+ "Failed to retrieve flags (%d).\n", ret);
+   ret = flags;
goto done;
}
-
-   info->flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
-   | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
-   | (data[0] & UVC_CONTROL_CAP_GET ?
-  UVC_CTRL_FLAG_GET_CUR : 0)
-   | (data[0] & UVC_CONTROL_CAP_SET ?
-  UVC_CTRL_FLAG_SET_CUR : 0)
-   | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
-  UVC_CTRL_FLAG_AUTO_UPDATE : 0);
+   info->flags = flags;

uvc_ctrl_fixup_xu_info(dev, ctrl, info);

@@ -1890,6 +1916,7 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, 
struct uvc_control *ctrl,
const struct uvc_control_info *info)
 {
int ret = 0;
+   int flags = 0;

ctrl->info = *info;
INIT_LIST_HEAD(>info.mappings);
@@ -1902,6 +1929,13 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, 
struct uvc_control *ctrl,
goto done;
}

+   flags = uvc_ctrl_get_flags(dev, ctrl, info);
+   if (flags < 0)
+   uvc_trace(UVC_TRACE_CONTROL,
+ "Failed to retrieve flags (%d).\n", ret);
+   else
+   ctrl->info.flags = flags;
+
ctrl->initialized = 1;

uvc_trace(UVC_TRACE_CONTROL, "Added control %pUl/%u to device %s "
-- 
2.14.2




Re: [PATCH] uvcvideo: Apply flags from device to actual properties

2017-10-11 Thread Edgar Thier

Use flags the device exposes for UVC controls.
This allows the device to define which property flags are set.

Since some cameras offer auto-adjustments for properties (e.g. auto-gain),
the values of other properties (e.g. gain) can change in the camera.
Examining the flags ensures that the driver is aware of such properties.

Signed-off-by: Edgar Thier <i...@edgarthier.net>
---
 drivers/media/usb/uvc/uvc_ctrl.c | 65 ++--
 1 file changed, 50 insertions(+), 15 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index 20397ab..7fbfeef 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -1630,12 +1630,47 @@ static void uvc_ctrl_fixup_xu_info(struct uvc_device 
*dev,
 }

 /*
+ * Retrieve flags for a given control
+ */
+static int uvc_ctrl_get_flags(struct uvc_device *dev, const struct uvc_control 
*ctrl,
+   const struct uvc_control_info *info)
+{
+   u8 *data;
+   int ret = 0;
+   int flags = 0;
+
+   data = kmalloc(2, GFP_KERNEL);
+   if (data == NULL)
+   return -ENOMEM;
+
+   ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
+info->selector, data, 1);
+   if (ret < 0) {
+   uvc_trace(UVC_TRACE_CONTROL,
+ "GET_INFO failed on control %pUl/%u (%d).\n",
+ info->entity, info->selector, ret);
+   } else {
+   flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
+   | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
+   | (data[0] & UVC_CONTROL_CAP_GET ?
+  UVC_CTRL_FLAG_GET_CUR : 0)
+   | (data[0] & UVC_CONTROL_CAP_SET ?
+  UVC_CTRL_FLAG_SET_CUR : 0)
+   | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
+  UVC_CTRL_FLAG_AUTO_UPDATE : 0);
+   }
+   kfree(data);
+   return flags;
+}
+
+/*
  * Query control information (size and flags) for XU controls.
  */
 static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,
const struct uvc_control *ctrl, struct uvc_control_info *info)
 {
u8 *data;
+   int flags;
int ret;

data = kmalloc(2, GFP_KERNEL);
@@ -1659,24 +1694,14 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,

info->size = le16_to_cpup((__le16 *)data);

-   /* Query the control information (GET_INFO) */
-   ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
-info->selector, data, 1);
-   if (ret < 0) {
+   flags = uvc_ctrl_get_flags(dev, ctrl, info);
+
+   if (flags < 0) {
uvc_trace(UVC_TRACE_CONTROL,
- "GET_INFO failed on control %pUl/%u (%d).\n",
- info->entity, info->selector, ret);
+ "Failed to retrieve flags (%d).\n", ret);
goto done;
}
-
-   info->flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
-   | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
-   | (data[0] & UVC_CONTROL_CAP_GET ?
-  UVC_CTRL_FLAG_GET_CUR : 0)
-   | (data[0] & UVC_CONTROL_CAP_SET ?
-  UVC_CTRL_FLAG_SET_CUR : 0)
-   | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
-  UVC_CTRL_FLAG_AUTO_UPDATE : 0);
+   info->flags = flags;

uvc_ctrl_fixup_xu_info(dev, ctrl, info);

@@ -1890,6 +1915,7 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, 
struct uvc_control *ctrl,
const struct uvc_control_info *info)
 {
int ret = 0;
+   int flags = 0;

ctrl->info = *info;
INIT_LIST_HEAD(>info.mappings);
@@ -1902,6 +1928,15 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, 
struct uvc_control *ctrl,
goto done;
}

+   flags = uvc_ctrl_get_flags(dev, ctrl, info);
+
+   if (flags < 0) {
+   uvc_trace(UVC_TRACE_CONTROL,
+ "Failed to retrieve flags (%d).\n", ret);
+   }
+
+   ctrl->info.flags = flags;
+
ctrl->initialized = 1;

uvc_trace(UVC_TRACE_CONTROL, "Added control %pUl/%u to device %s "
-- 
2.7.4




Re: [PATCH] uvcvideo: Apply flags from device to actual properties

2017-10-06 Thread Edgar Thier
Hi Kieran,

> Rather than forward declaring the function ... Could you put the function 
> higher
> in the module please?

Will do. Patch will come as a reply shortly.


>>> +   if (data == NULL)
>>> +   return -ENOMEM;
>>
>> This will set the callers 'flags' to -ENOMEM ? Is that desired?
>>
>> Of course removing the kmalloc will fix that anyway ...
> Perhaps we have to return an empty flags here, which is what we will return if
> the uvc_query_ctrl() fails anyway.

I wanted to keep the changes to a minimum. So I didn't touch the return values.
Are there any checks done for -ENOMEM et al? I didn't see any.

-Edgar


Re: [PATCH] uvcvideo: Apply flags from device to actual properties

2017-10-06 Thread Edgar Thier

Use flags the device exposes for UVC controls.
This allows the device to define which property flags are set.

Since some cameras offer auto-adjustments for properties (e.g. auto-gain),
the values of other properties (e.g. gain) can change in the camera.
Examining the flags ensures that the driver is aware of such properties.

Signed-off-by: Edgar Thier <i...@edgarthier.net>
---
 drivers/media/usb/uvc/uvc_ctrl.c | 56 +++-
 1 file changed, 38 insertions(+), 18 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index 20397ab..5091086 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -1630,6 +1630,41 @@ static void uvc_ctrl_fixup_xu_info(struct uvc_device 
*dev,
 }

 /*
+ * Retrieve flags for a given control
+ */
+static int uvc_ctrl_get_flags(struct uvc_device *dev, const struct uvc_control 
*ctrl,
+   const struct uvc_control_info *info)
+{
+   u8 *data;
+   int ret = 0;
+   int flags = 0;
+
+   data = kmalloc(2, GFP_KERNEL);
+   if (data == NULL)
+   return -ENOMEM;
+
+   ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
+info->selector, data, 1);
+   if (ret < 0) {
+   uvc_trace(UVC_TRACE_CONTROL,
+ "GET_INFO failed on control %pUl/%u (%d).\n",
+ info->entity, info->selector, ret);
+   } else {
+   flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
+   | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
+   | (data[0] & UVC_CONTROL_CAP_GET ?
+  UVC_CTRL_FLAG_GET_CUR : 0)
+   | (data[0] & UVC_CONTROL_CAP_SET ?
+  UVC_CTRL_FLAG_SET_CUR : 0)
+   | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
+  UVC_CTRL_FLAG_AUTO_UPDATE : 0);
+   }
+   kfree(data);
+   return flags;
+}
+
+
+/*
  * Query control information (size and flags) for XU controls.
  */
 static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,
@@ -1659,24 +1694,7 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,

info->size = le16_to_cpup((__le16 *)data);

-   /* Query the control information (GET_INFO) */
-   ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
-info->selector, data, 1);
-   if (ret < 0) {
-   uvc_trace(UVC_TRACE_CONTROL,
- "GET_INFO failed on control %pUl/%u (%d).\n",
- info->entity, info->selector, ret);
-   goto done;
-   }
-
-   info->flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
-   | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
-   | (data[0] & UVC_CONTROL_CAP_GET ?
-  UVC_CTRL_FLAG_GET_CUR : 0)
-   | (data[0] & UVC_CONTROL_CAP_SET ?
-  UVC_CTRL_FLAG_SET_CUR : 0)
-   | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
-  UVC_CTRL_FLAG_AUTO_UPDATE : 0);
+   info->flags = uvc_ctrl_get_flags(dev, ctrl, info);

uvc_ctrl_fixup_xu_info(dev, ctrl, info);

@@ -1902,6 +1920,8 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, 
struct uvc_control *ctrl,
goto done;
}

+   ctrl->info.flags = uvc_ctrl_get_flags(dev, ctrl, info);
+
ctrl->initialized = 1;

uvc_trace(UVC_TRACE_CONTROL, "Added control %pUl/%u to device %s "
-- 
2.7.4



Re: [PATCH] uvcvideo: Apply flags from device to actual properties

2017-10-05 Thread Edgar Thier
Hi all,

I was wondering if there are any problems with my latest patch or if it simply 
slipped through.
Feedback would be welcome.

Regards,

Edgar

On 08/18/2017 12:12 PM, Edgar Thier wrote:
> 
> Use flags the device exposes for UVC controls.
> This allows the device to define which property flags are set.
> 
> Since some cameras offer auto-adjustments for properties (e.g. auto-gain),
> the values of other properties (e.g. gain) can change in the camera.
> Examining the flags ensures that the driver is aware of such properties.
> 
> Signed-off-by: Edgar Thier <i...@edgarthier.net>
> ---
>  drivers/media/usb/uvc/uvc_ctrl.c | 58 
> +++-
>  1 file changed, 40 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_ctrl.c 
> b/drivers/media/usb/uvc/uvc_ctrl.c
> index c2ee6e3..6922c0cb 100644
> --- a/drivers/media/usb/uvc/uvc_ctrl.c
> +++ b/drivers/media/usb/uvc/uvc_ctrl.c
> @@ -1629,6 +1629,9 @@ static void uvc_ctrl_fixup_xu_info(struct uvc_device 
> *dev,
>   }
>  }
> 
> +static int uvc_ctrl_get_flags(struct uvc_device *dev, const struct 
> uvc_control *ctrl,
> + const struct uvc_control_info *info);
> +
>  /*
>   * Query control information (size and flags) for XU controls.
>   */
> @@ -1659,24 +1662,7 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device 
> *dev,
> 
>   info->size = le16_to_cpup((__le16 *)data);
> 
> - /* Query the control information (GET_INFO) */
> - ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
> -  info->selector, data, 1);
> - if (ret < 0) {
> - uvc_trace(UVC_TRACE_CONTROL,
> -   "GET_INFO failed on control %pUl/%u (%d).\n",
> -   info->entity, info->selector, ret);
> - goto done;
> - }
> -
> - info->flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
> - | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
> - | (data[0] & UVC_CONTROL_CAP_GET ?
> -UVC_CTRL_FLAG_GET_CUR : 0)
> - | (data[0] & UVC_CONTROL_CAP_SET ?
> -UVC_CTRL_FLAG_SET_CUR : 0)
> - | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
> -UVC_CTRL_FLAG_AUTO_UPDATE : 0);
> + info->flags = uvc_ctrl_get_flags(dev, ctrl, info);
> 
>   uvc_ctrl_fixup_xu_info(dev, ctrl, info);
> 
> @@ -1884,6 +1870,40 @@ int uvc_ctrl_restore_values(struct uvc_device *dev)
>   */
> 
>  /*
> + * Retrieve flags for a given control
> + */
> +static int uvc_ctrl_get_flags(struct uvc_device *dev, const struct 
> uvc_control *ctrl,
> + const struct uvc_control_info *info)
> +{
> + u8 *data;
> + int ret = 0;
> + int flags = 0;
> +
> + data = kmalloc(2, GFP_KERNEL);
> + if (data == NULL)
> + return -ENOMEM;
> +
> + ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
> +  info->selector, data, 1);
> + if (ret < 0) {
> + uvc_trace(UVC_TRACE_CONTROL,
> +   "GET_INFO failed on control %pUl/%u (%d).\n",
> +   info->entity, info->selector, ret);
> + } else {
> + flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
> + | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
> + | (data[0] & UVC_CONTROL_CAP_GET ?
> +UVC_CTRL_FLAG_GET_CUR : 0)
> + | (data[0] & UVC_CONTROL_CAP_SET ?
> +UVC_CTRL_FLAG_SET_CUR : 0)
> + | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
> +UVC_CTRL_FLAG_AUTO_UPDATE : 0);
> + }
> + kfree(data);
> + return flags;
> +}
> +
> +/*
>   * Add control information to a given control.
>   */
>  static int uvc_ctrl_add_info(struct uvc_device *dev, struct uvc_control 
> *ctrl,
> @@ -1902,6 +1922,8 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, 
> struct uvc_control *ctrl,
>   goto done;
>   }
> 
> + ctrl->info.flags = uvc_ctrl_get_flags(dev, ctrl, info);
> +
>   ctrl->initialized = 1;
> 
>   uvc_trace(UVC_TRACE_CONTROL, "Added control %pUl/%u to device %s "
> 


Re: UVC property auto update

2017-09-05 Thread Edgar Thier

> 
> Ok, looking more at the spec, the driver and your patch, here's what I 
> come up with:
> 
> 1. UVC defines which standard controls should have which flags. Among 
> those flags it specifies, which controls should specify the Autoupdate 
> flag. E.g. see the first of them as it appears in my copy of the spec 
> "4.2.2.4.8 Average Bit Rate Control"
> 2. The driver could read out flags from descriptors, but it hard-codes 
> them instead. So, (arguably), there's no need to actually read them at 
> probe time. XUs on the other hand aren't standard, therefore their flags 
> have to be read out.
> 3. In your patch you provide gain as an example. Do you mean the 
> PU_GAIN_CONTROL? The spec doesn't specify, that it should have Autoupdate 
> set. Now, whether that means, that using that flag with PU_GAIN_CONTROL is 
> a violation of the spec - I'm not sure about.
> 
> So, I think, the question really is - are hard-coded flags a proper and 
> sufficient approach or should flags be read from descriptors?
> 

That is the questioned I cannot answer. The current approach (with my patch) 
enables both.
The cameras I work with either assume no AUTO_UPDATE or try to define the FLAG 
themselves.
As to what the standard expects, I do not know as IMO it is not clearly enough 
defined if this flag
is optional or somehow expected. But I think that it makes more sense to ask 
the device
for its capabilities than the other way around. E.g. I have yet to encounter a 
camera that has hue
with AUTO_UPDATE yet the driver expects it.

> 
>> I will also ask the firmware developer if only value changes are available 
>> or flag changes are also
>> a possibility.
> 
> Well, flags aren't likely to change, perhaps. I think min and max values 
> are more likely to be updated.
> 

I just talked to him. There are no plans to use the auto update functionality 
for anything besides
GET_CUR. Flags could get messy since auto update itself could be toggled once 
other properties are
changed. These cross dependencies are not handled in the standard as far as I 
am aware.

> Well, flags aren't likely to change, perhaps. I think min and max values 
> are more likely to be updated.

That depends. When activating an auto feature, say auto-exposure. it could be 
interesting to set
exposure to read-only. For boundary changes I would say the question is how 
many users would
anticipate such a behavior.

>>>
>>> As you can see, it only handles the VALUE_CHANGE (GET_CUR) case. I would 
>>> suggest implementing a patch on top of it to add support for INFO_CHANGE 
>>> and you'd be the best person to test it then!
>>
>> I will try it out. I should be able to give you feedback tomorrow.
> 
> Thanks.
> 

Your patch works in combination with mine. I could not detect any problems.


Re: UVC property auto update

2017-09-04 Thread Edgar Thier
Hi Guennadi,


> But that patch only re-reads the flags. What does that give you? Do those > 
> flags change? In which way? As far as I understand the UVC Autoupdate
> feature, a change in GET_INFO data is only one possibility, (arguably) a 
> more important one is changes in GET_CUR data.

My understanding of the driver is rather narrow, so please correct me if I am 
wrong.
>From what I can see the uvc driver is currently not asking the device if a 
>property has self
modifying properties (and thus would require the AUTO_UPDATE flag).
This is only done for properties in the extension unit but not for 'standard' 
properties.
Thus properties exhibit different behavior depending on where they are defined.
By changing this the driver now assumes that a property with AUTO_UPDATE has to 
be re-read when
getting/setting a property and does not rely on cached values, no matter if 
extension unit or not.

I did not consider the possibility that a lower level change would be necessary 
or that a more
previce update mechanism for different property parts was possible.

Basically the entry point for my change would be here:
https://git.linuxtv.org/media_tree.git/tree/drivers/media/usb/uvc/uvc_ctrl.c#n1405

How an update is handled by the driver did not seem important for this patch as 
the retrieval of a
correct property value seemed more important.

> In either case, this should 
> be implemented using the UVC Interrupt endpoint. Here's my latest 
> asynchronous control patch:
> 
> https://patchwork.linuxtv.org/patch/42800/
> 
> As you can see, it only handles the VALUE_CHANGE (GET_CUR) case. I would 
> suggest implementing a patch on top of it to add support for INFO_CHANGE 
> and you'd be the best person to test it then!

I will try it out. I should be able to give you feedback tomorrow.
I will also ask the firmware developer if only value changes are available or 
flag changes are also
a possibility.

Cheers,

Edgar


Re: UVC property auto update

2017-09-04 Thread Edgar Thier
Hi Guennadi,

The cameras in question are USB-3.0 industrial cameras from The Imaging Source.
The ones I tested were the DFK UX250 and DFK UX264 models.
I do not know if there are other devices that have the AUTO_UPDATE flag for 
various properties.

Since I received no immediate answer I tried fixing it myself.
The result can be found here:
https://patchwork.linuxtv.org/patch/43289/

Cheers,

Edgar


Re: [PATCH] uvcvideo: Apply flags from device to actual properties

2017-08-18 Thread Edgar Thier

Use flags the device exposes for UVC controls.
This allows the device to define which property flags are set.

Since some cameras offer auto-adjustments for properties (e.g. auto-gain),
the values of other properties (e.g. gain) can change in the camera.
Examining the flags ensures that the driver is aware of such properties.

Signed-off-by: Edgar Thier <i...@edgarthier.net>
---
 drivers/media/usb/uvc/uvc_ctrl.c | 58 +++-
 1 file changed, 40 insertions(+), 18 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index c2ee6e3..6922c0cb 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -1629,6 +1629,9 @@ static void uvc_ctrl_fixup_xu_info(struct uvc_device *dev,
}
 }

+static int uvc_ctrl_get_flags(struct uvc_device *dev, const struct uvc_control 
*ctrl,
+   const struct uvc_control_info *info);
+
 /*
  * Query control information (size and flags) for XU controls.
  */
@@ -1659,24 +1662,7 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,

info->size = le16_to_cpup((__le16 *)data);

-   /* Query the control information (GET_INFO) */
-   ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
-info->selector, data, 1);
-   if (ret < 0) {
-   uvc_trace(UVC_TRACE_CONTROL,
- "GET_INFO failed on control %pUl/%u (%d).\n",
- info->entity, info->selector, ret);
-   goto done;
-   }
-
-   info->flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
-   | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
-   | (data[0] & UVC_CONTROL_CAP_GET ?
-  UVC_CTRL_FLAG_GET_CUR : 0)
-   | (data[0] & UVC_CONTROL_CAP_SET ?
-  UVC_CTRL_FLAG_SET_CUR : 0)
-   | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
-  UVC_CTRL_FLAG_AUTO_UPDATE : 0);
+   info->flags = uvc_ctrl_get_flags(dev, ctrl, info);

uvc_ctrl_fixup_xu_info(dev, ctrl, info);

@@ -1884,6 +1870,40 @@ int uvc_ctrl_restore_values(struct uvc_device *dev)
  */

 /*
+ * Retrieve flags for a given control
+ */
+static int uvc_ctrl_get_flags(struct uvc_device *dev, const struct uvc_control 
*ctrl,
+   const struct uvc_control_info *info)
+{
+   u8 *data;
+   int ret = 0;
+   int flags = 0;
+
+   data = kmalloc(2, GFP_KERNEL);
+   if (data == NULL)
+   return -ENOMEM;
+
+   ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
+info->selector, data, 1);
+   if (ret < 0) {
+   uvc_trace(UVC_TRACE_CONTROL,
+ "GET_INFO failed on control %pUl/%u (%d).\n",
+ info->entity, info->selector, ret);
+   } else {
+   flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
+   | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
+   | (data[0] & UVC_CONTROL_CAP_GET ?
+  UVC_CTRL_FLAG_GET_CUR : 0)
+   | (data[0] & UVC_CONTROL_CAP_SET ?
+  UVC_CTRL_FLAG_SET_CUR : 0)
+   | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
+  UVC_CTRL_FLAG_AUTO_UPDATE : 0);
+   }
+   kfree(data);
+   return flags;
+}
+
+/*
  * Add control information to a given control.
  */
 static int uvc_ctrl_add_info(struct uvc_device *dev, struct uvc_control *ctrl,
@@ -1902,6 +1922,8 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, 
struct uvc_control *ctrl,
goto done;
}

+   ctrl->info.flags = uvc_ctrl_get_flags(dev, ctrl, info);
+
ctrl->initialized = 1;

uvc_trace(UVC_TRACE_CONTROL, "Added control %pUl/%u to device %s "
-- 
2.7.4


[PATCH] uvcvideo: Apply flags from device to actual properties

2017-08-15 Thread Edgar Thier
Use flags the device exposes for UVC controls.

Signed-off-by: Edgar Thier <i...@edgarthier.net>
---
 drivers/media/usb/uvc/uvc_ctrl.c | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index c2ee6e3..bc69e92 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -1568,7 +1568,8 @@ int uvc_ctrl_set(struct uvc_video_chain *chain,
return ret;
}

-   ctrl->loaded = 1;
+   if (!(ctrl->info.flags && UVC_CTRL_FLAG_AUTO_UPDATE))
+   ctrl->loaded = 1;
}

/* Backup the current value in case we need to rollback later. */
@@ -1889,8 +1890,13 @@ int uvc_ctrl_restore_values(struct uvc_device *dev)
 static int uvc_ctrl_add_info(struct uvc_device *dev, struct uvc_control *ctrl,
const struct uvc_control_info *info)
 {
+   u8 *data;
int ret = 0;

+   data = kmalloc(2, GFP_KERNEL);
+   if (data == NULL)
+   return -ENOMEM;
+
ctrl->info = *info;
INIT_LIST_HEAD(>info.mappings);

@@ -1904,6 +1910,23 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, 
struct uvc_control *ctrl,

ctrl->initialized = 1;

+   ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
+ info->selector, data, 1);
+   if (ret < 0) {
+   uvc_trace(UVC_TRACE_CONTROL,
+ "GET_INFO failed on control %pUl/%u (%d).\n",
+ info->entity, info->selector, ret);
+   }
+   else {
+   ctrl->info.flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
+   | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
+   | (data[0] & UVC_CONTROL_CAP_GET ?
+  UVC_CTRL_FLAG_GET_CUR : 0)
+   | (data[0] & UVC_CONTROL_CAP_SET ?
+  UVC_CTRL_FLAG_SET_CUR : 0)
+   | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
+  UVC_CTRL_FLAG_AUTO_UPDATE : 0);
+   }
uvc_trace(UVC_TRACE_CONTROL, "Added control %pUl/%u to device %s "
"entity %u\n", ctrl->info.entity, ctrl->info.selector,
dev->udev->devpath, ctrl->entity->id);
@@ -1911,6 +1934,7 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, 
struct uvc_control *ctrl,
 done:
if (ret < 0)
kfree(ctrl->uvc_data);
+   kfree(data);
return ret;
 }

-- 
2.7.4



UVC property auto update

2017-08-07 Thread Edgar Thier
Hi all,

I have some USB-3.0 cameras that use UVC.
These cameras offer auto updates for various properties.
An example of such a property would be gain, that will be adjusted when 
activating the auto-gain
property. These property changes are not queried by the UVC driver, unless it 
already has the
property marked as auto update via UVC_CTRL_FLAG_AUTO_UPDATE.
>From what I have seen, it seems that this flag is not checked when indexing 
>the camera controls.
However it is checked when using extension units, so all properties loaded 
through such a unit are
being updates as one would hope.

My questions:

Is it intended that properties cannot mark themselves as autoupdate?
If yes:
Is there a recommended way of working around this?
Do all autoupdate properties have to be in an extension unit?
If no:
What should a fix look like?

Regards,

Edgar


Re: [PATCH] uvcvideo: Add bayer 16-bit format patterns

2016-11-15 Thread Edgar Thier
Hi Laurent,

> Which device(s) support these formats ?

As mentioned in my last mail, I took the freedom and uploaded the lsusb
-v output for 3 cameras with
bayer 16-bit patterns. You can find them here:

dfk23up1300_16bitbayer_RG.lsusb:  http://pastebin.com/PDdY7rs0
dfk23ux249_16bitbayer_GB.lsusb: http://pastebin.com/gtjF3Q2k
dfk33ux250_16bitbayer_GR.lsusb: http://pastebin.com/Errz5UMr

All 3 are USB 3.0 industrial cameras by 'The Imaging Source'.

> And could you please try to fix your e-mail client and/or server to avoid 
> corrupting patches ?

I am not sure what is wrong but I will look into it.

Cheers,

Edgar
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] uvcvideo: Add bayer 16-bit format patterns

2016-11-14 Thread Edgar Thier

Hi Sakari,

Sorry for the waiting. I hope the patch I just submitted is alright.

I took the freedom and uploaded the lsusb -v output for 3 cameras with
bayer 16-bit patterns. You can find them here:

dfk23up1300_16bitbayer_RG.lsusb:  http://pastebin.com/PDdY7rs0
dfk23ux249_16bitbayer_GB.lsusb: http://pastebin.com/gtjF3Q2k
dfk33ux250_16bitbayer_GR.lsusb: http://pastebin.com/Errz5UMr

Cheers,

Edgar

> Hi Edgar,
>
> On Mon, Nov 14, 2016 at 02:26:56PM +0100, Edgar Thier wrote:
>> From aec97c931cb4b91f91dd0ed38f74d866d4f13347 Mon Sep 17 00:00:00 2001
>> From: Edgar Thier <i...@edgarthier.net>
>> Date: Mon, 14 Nov 2016 14:17:57 +0100
>> Subject: [PATCH] uvcvideo: Add bayer 16-bit format patterns
>>
>> Add bayer 16-bit GUIDs to uvcvideo and associated them with the
>> corresponding V4L2 pixel formats.
>>
>> Signed-off-by: Edgar Thier <i...@edgarthier.net>
>> ---
>
> ...
>
>> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
>> index 4364ce6..6bdf592 100644
>> --- a/include/uapi/linux/videodev2.h
>> +++ b/include/uapi/linux/videodev2.h
>> @@ -605,6 +605,9 @@ struct v4l2_pix_format {
>> #define V4L2_PIX_FMT_SGRBG12 v4l2_fourcc('B', 'A', '1', '2') /* 12  GRGR.. 
>> BGBG.. */
>> #define V4L2_PIX_FMT_SRGGB12 v4l2_fourcc('R', 'G', '1', '2') /* 12  RGRG.. 
>> GBGB.. */
>> #define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') /* 16  BGBG.. 
>> GRGR.. */
>> +#define V4L2_PIX_FMT_SGBRG16 v4l2_fourcc('G', 'B', '1', '6') /* 16  GBGB.. 
>> RGRG.. */
>> +#define V4L2_PIX_FMT_SRGGB16 v4l2_fourcc('R', 'G', '1', '6') /* 16  RGRG.. 
>> GBGB.. */
>> +#define V4L2_PIX_FMT_SGRBG16 v4l2_fourcc('G', 'R', '1', '6') /* 16  GRGR.. 
>> BGBG.. */
>
> Thanks for the patch!
>
> Could you rebase your uvcvideo changes on this patch, dropping the framework
> changes from yours?
>
> Cc Laurent. Laurent, could you take both of the patches to your tree after
> the rebase?
>
> The patch is also available here:
>
> <URL:https://git.linuxtv.org/sailus/media_tree.git/commit/?h=packed12-postponed2=c5b60538b33f993109248a642c8e9b74f7d1abd1>
>
>
> From c5b60538b33f993109248a642c8e9b74f7d1abd1 Mon Sep 17 00:00:00 2001
> From: Sakari Ailus <sakari.ai...@linux.intel.com>
> Date: Mon, 27 Jun 2016 16:46:16 +0300
> Subject: [PATCH 1/1] v4l: Add 16-bit raw bayer pixel formats
>
> The formats added by this patch are:
>
>   V4L2_PIX_FMT_SBGGR16
>   V4L2_PIX_FMT_SGBRG16
>   V4L2_PIX_FMT_SGRBG16
>
> V4L2_PIX_FMT_SRGGB16 already existed before the patch. Rework the
> documentation to match that of the other sample depths.
>
> Also align the description of V4L2_PIX_FMT_SRGGB16 to match with other
> similar formats.
>
> Signed-off-by: Sakari Ailus <sakari.ai...@linux.intel.com>
> Acked-by: Lad, Prabhakar <prabhakar.cse...@gmail.com>
> ---
>  Documentation/media/uapi/v4l/pixfmt-rgb.rst |  2 +-
>  Documentation/media/uapi/v4l/pixfmt-sbggr16.rst | 62 --
>  Documentation/media/uapi/v4l/pixfmt-srggb16.rst | 69 
> +
>  drivers/media/v4l2-core/v4l2-ioctl.c|  5 +-
>  include/uapi/linux/videodev2.h  |  3 ++
>  5 files changed, 77 insertions(+), 64 deletions(-)
>  delete mode 100644 Documentation/media/uapi/v4l/pixfmt-sbggr16.rst
>  create mode 100644 Documentation/media/uapi/v4l/pixfmt-srggb16.rst
>
> diff --git a/Documentation/media/uapi/v4l/pixfmt-rgb.rst 
> b/Documentation/media/uapi/v4l/pixfmt-rgb.rst
> index 9cc9808..b0f3513 100644
> --- a/Documentation/media/uapi/v4l/pixfmt-rgb.rst
> +++ b/Documentation/media/uapi/v4l/pixfmt-rgb.rst
> @@ -12,9 +12,9 @@ RGB Formats
>
>  pixfmt-packed-rgb
>  pixfmt-srggb8
> -pixfmt-sbggr16
>  pixfmt-srggb10
>  pixfmt-srggb10p
>  pixfmt-srggb10alaw8
>  pixfmt-srggb10dpcm8
>  pixfmt-srggb12
> +pixfmt-srggb16
> diff --git a/Documentation/media/uapi/v4l/pixfmt-sbggr16.rst 
> b/Documentation/media/uapi/v4l/pixfmt-sbggr16.rst
> deleted file mode 100644
> index 6f7f327..000
> --- a/Documentation/media/uapi/v4l/pixfmt-sbggr16.rst
> +++ /dev/null
> @@ -1,62 +0,0 @@
> -.. -*- coding: utf-8; mode: rst -*-
> -
> -.. _V4L2-PIX-FMT-SBGGR16:
> -
> -*
> -V4L2_PIX_FMT_SBGGR16 ('BYR2')
> -*
> -
> -Bayer RGB format
> -
> -
> -Description
> -===
> -
> -This format is similar to
> -:ref:`V4L2_PIX_FMT_SBGGR8 `, except each pixel
> -has a depth of 16 bits. The least significant byte is stored at lower
> -memory addresses (little-endian).
> -
> -**Byte Order.**
> -Each

[PATCH] uvcvideo: Add bayer 16-bit format patterns

2016-11-14 Thread Edgar Thier

>From 10ce06db4ab3c037758b3cb5264007f59801f1a1 Mon Sep 17 00:00:00 2001
From: Edgar Thier <i...@edgarthier.net>
Date: Tue, 15 Nov 2016 06:33:10 +0100
Subject: [PATCH] uvcvideo: Add bayer 16-bit format patterns

Signed-off-by: Edgar Thier <i...@edgarthier.net>
---
drivers/media/usb/uvc/uvc_driver.c | 20 
drivers/media/usb/uvc/uvcvideo.h   | 12 
2 files changed, 32 insertions(+)

diff --git a/drivers/media/usb/uvc/uvc_driver.c 
b/drivers/media/usb/uvc/uvc_driver.c
index 87b2fc3b..9d1fc33 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -168,6 +168,26 @@ static struct uvc_format_desc uvc_fmts[] = {
.guid   = UVC_GUID_FORMAT_RW10,
.fcc= V4L2_PIX_FMT_SRGGB10P,
},
+   {
+   .name   = "Bayer 16-bit (SBGGR16)",
+   .guid   = UVC_GUID_FORMAT_BG16,
+   .fcc= V4L2_PIX_FMT_SBGGR16,
+   },
+   {
+   .name   = "Bayer 16-bit (SGBRG16)",
+   .guid   = UVC_GUID_FORMAT_GB16,
+   .fcc= V4L2_PIX_FMT_SGBRG16,
+   },
+   {
+   .name   = "Bayer 16-bit (SRGGB16)",
+   .guid   = UVC_GUID_FORMAT_RG16,
+   .fcc= V4L2_PIX_FMT_SRGGB16,
+   },
+   {
+   .name   = "Bayer 16-bit (SGRBG16)",
+   .guid   = UVC_GUID_FORMAT_GR16,
+   .fcc= V4L2_PIX_FMT_SGRBG16,
+   },
};

/* 
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 7e4d3ee..3d6cc62 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -106,6 +106,18 @@
#define UVC_GUID_FORMAT_RGGB \
{ 'R',  'G',  'G',  'B', 0x00, 0x00, 0x10, 0x00, \
0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
+#define UVC_GUID_FORMAT_BG16 \
+   { 'B',  'G',  '1',  '6', 0x00, 0x00, 0x10, 0x00, \
+0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
+#define UVC_GUID_FORMAT_GB16 \
+   { 'G',  'B',  '1',  '6', 0x00, 0x00, 0x10, 0x00, \
+0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
+#define UVC_GUID_FORMAT_RG16 \
+   { 'R',  'G',  '1',  '6', 0x00, 0x00, 0x10, 0x00, \
+0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
+#define UVC_GUID_FORMAT_GR16 \
+   { 'G',  'R',  '1',  '6', 0x00, 0x00, 0x10, 0x00, \
+0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
#define UVC_GUID_FORMAT_RGBP \
{ 'R',  'G',  'B',  'P', 0x00, 0x00, 0x10, 0x00, \
0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
--
2.10.2
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] uvcvideo: Add bayer 16-bit format patterns

2016-11-14 Thread Edgar Thier
>From aec97c931cb4b91f91dd0ed38f74d866d4f13347 Mon Sep 17 00:00:00 2001
From: Edgar Thier <i...@edgarthier.net>
Date: Mon, 14 Nov 2016 14:17:57 +0100
Subject: [PATCH] uvcvideo: Add bayer 16-bit format patterns

Add bayer 16-bit GUIDs to uvcvideo and associated them with the
corresponding V4L2 pixel formats.

Signed-off-by: Edgar Thier <i...@edgarthier.net>
---
drivers/media/usb/uvc/uvc_driver.c   | 20 
drivers/media/usb/uvc/uvcvideo.h | 12 
drivers/media/v4l2-core/v4l2-ioctl.c |  4 
include/uapi/linux/videodev2.h   |  3 +++
4 files changed, 39 insertions(+)

diff --git a/drivers/media/usb/uvc/uvc_driver.c 
b/drivers/media/usb/uvc/uvc_driver.c
index 87b2fc3b..9d1fc33 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -168,6 +168,26 @@ static struct uvc_format_desc uvc_fmts[] = {
.guid   = UVC_GUID_FORMAT_RW10,
.fcc= V4L2_PIX_FMT_SRGGB10P,
},
+   {
+   .name   = "Bayer 16-bit (SBGGR16)",
+   .guid   = UVC_GUID_FORMAT_BG16,
+   .fcc= V4L2_PIX_FMT_SBGGR16,
+   },
+   {
+   .name   = "Bayer 16-bit (SGBRG16)",
+   .guid   = UVC_GUID_FORMAT_GB16,
+   .fcc= V4L2_PIX_FMT_SGBRG16,
+   },
+   {
+   .name   = "Bayer 16-bit (SRGGB16)",
+   .guid   = UVC_GUID_FORMAT_RG16,
+   .fcc= V4L2_PIX_FMT_SRGGB16,
+   },
+   {
+   .name   = "Bayer 16-bit (SGRBG16)",
+   .guid   = UVC_GUID_FORMAT_GR16,
+   .fcc= V4L2_PIX_FMT_SGRBG16,
+   },
};

/* 
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 7e4d3ee..3d6cc62 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -106,6 +106,18 @@
#define UVC_GUID_FORMAT_RGGB \
{ 'R',  'G',  'G',  'B', 0x00, 0x00, 0x10, 0x00, \
0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
+#define UVC_GUID_FORMAT_BG16 \
+   { 'B',  'G',  '1',  '6', 0x00, 0x00, 0x10, 0x00, \
+0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
+#define UVC_GUID_FORMAT_GB16 \
+   { 'G',  'B',  '1',  '6', 0x00, 0x00, 0x10, 0x00, \
+0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
+#define UVC_GUID_FORMAT_RG16 \
+   { 'R',  'G',  '1',  '6', 0x00, 0x00, 0x10, 0x00, \
+0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
+#define UVC_GUID_FORMAT_GR16 \
+   { 'G',  'R',  '1',  '6', 0x00, 0x00, 0x10, 0x00, \
+0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
#define UVC_GUID_FORMAT_RGBP \
{ 'R',  'G',  'B',  'P', 0x00, 0x00, 0x10, 0x00, \
0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 181381d..abbb6d5 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1179,6 +1179,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_SGBRG12:  descr = "12-bit Bayer GBGB/RGRG"; break;
case V4L2_PIX_FMT_SGRBG12:  descr = "12-bit Bayer GRGR/BGBG"; break;
case V4L2_PIX_FMT_SRGGB12:  descr = "12-bit Bayer RGRG/GBGB"; break;
+   case V4L2_PIX_FMT_SGBRG16:  descr = "16-bit Bayer GBGB/RGRG"; break;
+   case V4L2_PIX_FMT_SGRBG16:  descr = "16-bit Bayer GRGR/BGBG"; break;
+   case V4L2_PIX_FMT_SRGGB16:  descr = "16-bit Bayer RGRG/GBGB"; break;
+   case V4L2_PIX_FMT_SBGGR16:  descr = "16-bit Bayer BGBG/GRGR"; break;
case V4L2_PIX_FMT_SBGGR10P: descr = "10-bit Bayer BGBG/GRGR Packed"; break;
case V4L2_PIX_FMT_SGBRG10P: descr = "10-bit Bayer GBGB/RGRG Packed"; break;
case V4L2_PIX_FMT_SGRBG10P: descr = "10-bit Bayer GRGR/BGBG Packed"; break;
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 4364ce6..6bdf592 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -605,6 +605,9 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_SGRBG12 v4l2_fourcc('B', 'A', '1', '2') /* 12  GRGR.. 
BGBG.. */
#define V4L2_PIX_FMT_SRGGB12 v4l2_fourcc('R', 'G', '1', '2') /* 12  RGRG.. 
GBGB.. */
#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') /* 16  BGBG.. 
GRGR.. */
+#define V4L2_PIX_FMT_SGBRG16 v4l2_fourcc('G', 'B', '1', '6') /* 16  GBGB.. 
RGRG.. */
+#define V4L2_PIX_FMT_SRGGB16 v4l2_fourcc('R', 'G', '1', '6') /* 16  RGRG.. 
GBGB.. */
+#define V4L2_PIX_FMT_SGRBG16 v4l2_fourcc('G', 'R', '1', '6') /* 16  GRGR.. 
BGBG.. */

/* HSV formats */
#define V4L2_PIX_FMT_HSV24 v4l2_fourcc('H

[PATCH] uvcvideo: Add bayer 8-bit patterns to uvcvideo

2014-02-19 Thread Edgar Thier

Add bayer 8-bit GUIDs to uvcvideo and
associated them with the corresponding V4L2 pixel formats.

Signed-off-by: Edgar Thier i...@edgarthier.net
---
 drivers/media/usb/uvc/uvc_driver.c | 22 +-
 drivers/media/usb/uvc/uvcvideo.h   | 12 
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_driver.c 
b/drivers/media/usb/uvc/uvc_driver.c
index c3bb250..84da426 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -108,11 +108,31 @@ static struct uvc_format_desc uvc_fmts[] = {
.fcc= V4L2_PIX_FMT_Y16,
},
{
-   .name   = RGB Bayer,
+   .name   = RGB Bayer (bggr),
.guid   = UVC_GUID_FORMAT_BY8,
.fcc= V4L2_PIX_FMT_SBGGR8,
},
{
+   .name   = RGB Bayer (bggr),
+   .guid   = UVC_GUID_FORMAT_BY8_BA81,
+   .fcc= V4L2_PIX_FMT_SBGGR8,
+   },
+   {
+   .name   = RGB Bayer (grbg),
+   .guid   = UVC_GUID_FORMAT_BY8_GRBG,
+   .fcc= V4L2_PIX_FMT_SGRBG8,
+   },
+   {
+   .name   = RGB Bayer (gbrg),
+   .guid   = UVC_GUID_FORMAT_BY8_GBRG,
+   .fcc= V4L2_PIX_FMT_SGBRG8,
+   },
+   {
+   .name   = RGB Bayer (rggb),
+   .guid   = UVC_GUID_FORMAT_BY8_RGGB,
+   .fcc= V4L2_PIX_FMT_SRGGB8,
+   },
+   {
.name   = RGB565,
.guid   = UVC_GUID_FORMAT_RGBP,
.fcc= V4L2_PIX_FMT_RGB565,
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 9e35982..57357d9 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -94,6 +94,18 @@
 #define UVC_GUID_FORMAT_BY8 \
{ 'B',  'Y',  '8',  ' ', 0x00, 0x00, 0x10, 0x00, \
 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
+#define UVC_GUID_FORMAT_BY8_BA81 \
+   { 'B',  'A',  '8',  '1', 0x00, 0x00, 0x10, 0x00, \
+0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
+#define UVC_GUID_FORMAT_BY8_GRBG \
+   { 'G',  'R',  'B',  'G', 0x00, 0x00, 0x10, 0x00, \
+0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
+#define UVC_GUID_FORMAT_BY8_GBRG \
+   { 'G',  'B',  'R',  'G', 0x00, 0x00, 0x10, 0x00, \
+0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
+#define UVC_GUID_FORMAT_BY8_RGGB \
+   { 'R',  'G',  'G',  'B', 0x00, 0x00, 0x10, 0x00, \
+0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
 #define UVC_GUID_FORMAT_RGBP \
{ 'R',  'G',  'B',  'P', 0x00, 0x00, 0x10, 0x00, \
 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Added bayer 8-bit patterns to uvcvideo

2014-01-20 Thread Edgar Thier
Add bayer 8-bit GUIDs to uvcvideo and
associate them with the corresponding V4L2 pixel formats.

Signed-off-by: Edgar Thier i...@edgarthier.net
---
 drivers/media/usb/uvc/uvc_driver.c | 22 +-
 drivers/media/usb/uvc/uvcvideo.h   | 12 
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_driver.c
b/drivers/media/usb/uvc/uvc_driver.c
index c3bb250..84da426 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -108,11 +108,31 @@ static struct uvc_format_desc uvc_fmts[] = {
 .fcc= V4L2_PIX_FMT_Y16,
 },
 {
-.name= RGB Bayer,
+.name= RGB Bayer (bggr),
 .guid= UVC_GUID_FORMAT_BY8,
 .fcc= V4L2_PIX_FMT_SBGGR8,
 },
 {
+.name= RGB Bayer (bggr),
+.guid= UVC_GUID_FORMAT_BY8_BA81,
+.fcc= V4L2_PIX_FMT_SBGGR8,
+},
+{
+.name= RGB Bayer (grbg),
+.guid= UVC_GUID_FORMAT_BY8_GRBG,
+.fcc= V4L2_PIX_FMT_SGRBG8,
+},
+{
+.name= RGB Bayer (gbrg),
+.guid= UVC_GUID_FORMAT_BY8_GBRG,
+.fcc= V4L2_PIX_FMT_SGBRG8,
+},
+{
+.name= RGB Bayer (rggb),
+.guid= UVC_GUID_FORMAT_BY8_RGGB,
+.fcc= V4L2_PIX_FMT_SRGGB8,
+},
+{
 .name= RGB565,
 .guid= UVC_GUID_FORMAT_RGBP,
 .fcc= V4L2_PIX_FMT_RGB565,
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 9e35982..57357d9 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -94,6 +94,18 @@
 #define UVC_GUID_FORMAT_BY8 \
 { 'B',  'Y',  '8',  ' ', 0x00, 0x00, 0x10, 0x00, \
  0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
+#define UVC_GUID_FORMAT_BY8_BA81 \
+{ 'B',  'A',  '8',  '1', 0x00, 0x00, 0x10, 0x00, \
+ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
+#define UVC_GUID_FORMAT_BY8_GRBG \
+{ 'G',  'R',  'B',  'G', 0x00, 0x00, 0x10, 0x00, \
+ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
+#define UVC_GUID_FORMAT_BY8_GBRG \
+{ 'G',  'B',  'R',  'G', 0x00, 0x00, 0x10, 0x00, \
+ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
+#define UVC_GUID_FORMAT_BY8_RGGB \
+{ 'R',  'G',  'G',  'B', 0x00, 0x00, 0x10, 0x00, \
+ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
 #define UVC_GUID_FORMAT_RGBP \
 { 'R',  'G',  'B',  'P', 0x00, 0x00, 0x10, 0x00, \
  0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
-- 
1.8.5.3
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html