Re: [PATCH] media: uvcvideo: Support realtek's UVC 1.5 device

2018-05-22 Thread Kai Heng Feng


On May 23, 2018, at 4:32 AM, Laurent Pinchart  
<laurent.pinch...@ideasonboard.com> wrote:


Hello,

Thank you for the patch.

On Wednesday, 9 May 2018 05:13:08 EEST ming_q...@realsil.com.cn wrote:

From: ming_qian <ming_q...@realsil.com.cn>

The length of UVC 1.5 video control is 48, and it id 34 for UVC 1.1.
Change it to 48 for UVC 1.5 device,
and the UVC 1.5 device can be recognized.

More changes to the driver are needed for full UVC 1.5 compatibility.
However, at least the UVC 1.5 Realtek RTS5847/RTS5852 cameras have
been reported to work well.


This patch is however not specific to Realtek devices, so I think we should
make the subject line more generic. It's fine mentioning in the commit  
message
itself that the Realtek RTS5847/RTS5852 cameras have been successfully  
tested.



Signed-off-by: ming_qian <ming_q...@realsil.com.cn>
---
 drivers/media/usb/uvc/uvc_video.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/usb/uvc/uvc_video.c
b/drivers/media/usb/uvc/uvc_video.c index aa0082f..32dfb32 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -171,6 +171,8 @@ static int uvc_get_video_ctrl(struct uvc_streaming
*stream, int ret;

size = stream->dev->uvc_version >= 0x0110 ? 34 : 26;
+   if (stream->dev->uvc_version >= 0x0150)
+   size = 48;
if ((stream->dev->quirks & UVC_QUIRK_PROBE_DEF) &&
query == UVC_GET_DEF)
return -EIO;
@@ -259,6 +261,8 @@ static int uvc_set_video_ctrl(struct uvc_streaming
*stream, int ret;

size = stream->dev->uvc_version >= 0x0110 ? 34 : 26;
+   if (stream->dev->uvc_version >= 0x0150)
+   size = 48;
data = kzalloc(size, GFP_KERNEL);
if (data == NULL)
return -ENOMEM;


Instead of duplicating the computation in both functions, I think we should
move the code to a helper function.

Furthermore there are equality checks further down both functions that  
compare

the size to 34, they should be updated to also support UVC 1.5.

I propose the following updated patch. If you're fine with it there's no  
need

to resubmit, I'll queue it for v4.19.

I have dropped the Reviewed-by and Tested-by tags as the patch has changed.

commit a9c002732695eab2096580a0d1a1687bc2f95928
Author: ming_qian <ming_q...@realsil.com.cn>
Date:   Wed May 9 10:13:08 2018 +0800

media: uvcvideo: Support UVC 1.5 video probe & commit controls

The length of UVC 1.5 video control is 48, and it is 34 for UVC 1.1.
Change it to 48 for UVC 1.5 device, and the UVC 1.5 device can be
recognized.

More changes to the driver are needed for full UVC 1.5 compatibility.
However, at least the UVC 1.5 Realtek RTS5847/RTS5852 cameras have been
reported to work well.

Cc: sta...@vger.kernel.org
Signed-off-by: ming_qian <ming_q...@realsil.com.cn>
[Factor out code to helper function, update size checks]
Signed-off-by: Laurent Pinchart <laurent.pinch...@ideasonboard.com>


I tested this new patch and it works well.

Tested-by: Kai-Heng Feng <kai.heng.f...@canonical.com>



diff --git a/drivers/media/usb/uvc/uvc_video.c  
b/drivers/media/usb/uvc/uvc_video.c

index eb9e04a59427..285b0e813b9d 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -207,14 +207,27 @@ static void uvc_fixup_video_ctrl(struct  
uvc_streaming *stream,

}
 }

+static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
+{
+   /*
+* Return the size of the video probe and commit controls, which depends
+* on the protocol version.
+*/
+   if (stream->dev->uvc_version < 0x0110)
+   return 26;
+   else if (stream->dev->uvc_version < 0x0150)
+   return 34;
+   else
+   return 48;
+}
+
 static int uvc_get_video_ctrl(struct uvc_streaming *stream,
struct uvc_streaming_control *ctrl, int probe, u8 query)
 {
+   u16 size = uvc_video_ctrl_size(stream);
u8 *data;
-   u16 size;
int ret;

-   size = stream->dev->uvc_version >= 0x0110 ? 34 : 26;
if ((stream->dev->quirks & UVC_QUIRK_PROBE_DEF) &&
query == UVC_GET_DEF)
return -EIO;
@@ -271,7 +284,7 @@ static int uvc_get_video_ctrl(struct uvc_streaming  
*stream,

ctrl->dwMaxVideoFrameSize = get_unaligned_le32([18]);
ctrl->dwMaxPayloadTransferSize = get_unaligned_le32([22]);

-   if (size == 34) {
+   if (size >= 34) {
ctrl->dwClockFrequency = get_unaligned_le32([26]);
ctrl->bmFramingInfo = data[30];
ctrl->bPreferedVersion = data[31];
@@ -300,11 +313,10 @@ static int uvc_get_video_ctrl(struct uvc_streaming  
*stream,

 static int uvc_set_video_ctrl(struct 

Re: [PATCH] media: uvcvideo: Support realtek's UVC 1.5 device

2018-05-10 Thread Kai-Heng Feng

at 10:13, ming_q...@realsil.com.cn wrote:


From: ming_qian <ming_q...@realsil.com.cn>

The length of UVC 1.5 video control is 48, and it id 34 for UVC 1.1.
Change it to 48 for UVC 1.5 device,
and the UVC 1.5 device can be recognized.

More changes to the driver are needed for full UVC 1.5 compatibility.
However, at least the UVC 1.5 Realtek RTS5847/RTS5852 cameras have
been reported to work well.


I think this should also Cc: stable.

Tested-by: Kai-Heng Feng <kai.heng.f...@canonical.com>



Signed-off-by: ming_qian <ming_q...@realsil.com.cn>
---
 drivers/media/usb/uvc/uvc_video.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/usb/uvc/uvc_video.c  
b/drivers/media/usb/uvc/uvc_video.c

index aa0082f..32dfb32 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -171,6 +171,8 @@ static int uvc_get_video_ctrl(struct uvc_streaming  
*stream,

int ret;

size = stream->dev->uvc_version >= 0x0110 ? 34 : 26;
+   if (stream->dev->uvc_version >= 0x0150)
+   size = 48;
if ((stream->dev->quirks & UVC_QUIRK_PROBE_DEF) &&
query == UVC_GET_DEF)
return -EIO;
@@ -259,6 +261,8 @@ static int uvc_set_video_ctrl(struct uvc_streaming  
*stream,

int ret;

size = stream->dev->uvc_version >= 0x0110 ? 34 : 26;
+   if (stream->dev->uvc_version >= 0x0150)
+   size = 48;
data = kzalloc(size, GFP_KERNEL);
if (data == NULL)
return -ENOMEM;
--
2.7.4





UVC1.5 webcam does not work on XPS 9370

2018-04-17 Thread Kai Heng Feng

Hi,

The Realtek 0bda:58f4 webcam which XPS 9370 uses doesn't work [1], not sure  
if it's because Linux doesn't support UVC1.5:


[2.174138] Linux video capture interface: v2.00
[2.182580] usbcore: registered new interface driver btusb
[2.188376] uvcvideo: Found UVC 1.50 device Integrated_Webcam_HD  
(0bda:58f4)
[2.189001] uvcvideo: UVC non compliance - GET_DEF(PROBE) not supported.  
Enabling workaround.
[2.189426] uvcvideo: Failed to query (129) UVC probe control : -75  
(exp. 34).

[2.189429] uvcvideo: Failed to initialize the device (-5).
[2.190336] uvcvideo: Unknown video format  
0032-0002-0010-8000-00aa00389b71
[2.190341] uvcvideo: Found UVC 1.50 device Integrated_Webcam_HD  
(0bda:58f4)
[2.190925] uvcvideo: UVC non compliance - GET_DEF(PROBE) not supported.  
Enabling workaround.
[2.191183] uvcvideo: Failed to query (129) UVC probe control : -75  
(exp. 34).

[2.191186] uvcvideo: Failed to initialize the device (-5).
[2.191214] usbcore: registered new interface driver uvcvideo
[2.191214] USB Video Class driver (1.1.1)

The Realtek webcam (0bda:58f4) has another firmware that supports UVC1.0,  
so the current solution is swapping the entire screen for the laptop.


Eventually UVC1.5 will be supported by Linux, so I am wondering if this is  
really because UVC1.5?


Kai-Heng

[1] https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1763748


Re: [PATCH] media: cx231xx: Add support for AverMedia DVD EZMaker 7

2018-04-13 Thread Kai Heng Feng

Hi,

On Mar 26, 2018, at 2:06 PM, Kai-Heng Feng <kai.heng.f...@canonical.com>  
wrote:


User reports AverMedia DVD EZMaker 7 can be driven by VIDEO_GRABBER.
Add the device to the id_table to make it work.


*Gentle ping*
I am hoping this patch can get merged in v4.17.

Kai-Heng



BugLink: https://bugs.launchpad.net/bugs/1620762
Signed-off-by: Kai-Heng Feng <kai.heng.f...@canonical.com>
---
 drivers/media/usb/cx231xx/cx231xx-cards.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c  
b/drivers/media/usb/cx231xx/cx231xx-cards.c

index f9ec7fedcd5b..da01c5125acb 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -945,6 +945,9 @@ struct usb_device_id cx231xx_id_table[] = {
 .driver_info = CX231XX_BOARD_CNXT_RDE_250},
{USB_DEVICE(0x0572, 0x58A0),
 .driver_info = CX231XX_BOARD_CNXT_RDU_250},
+   /* AverMedia DVD EZMaker 7 */
+   {USB_DEVICE(0x07ca, 0xc039),
+.driver_info = CX231XX_BOARD_CNXT_VIDEO_GRABBER},
{USB_DEVICE(0x2040, 0xb110),
 .driver_info = CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL},
{USB_DEVICE(0x2040, 0xb111),
--
2.15.1


[PATCH] media: cx231xx: Add support for AverMedia DVD EZMaker 7

2018-03-26 Thread Kai-Heng Feng
User reports AverMedia DVD EZMaker 7 can be driven by VIDEO_GRABBER.
Add the device to the id_table to make it work.

BugLink: https://bugs.launchpad.net/bugs/1620762
Signed-off-by: Kai-Heng Feng <kai.heng.f...@canonical.com>
---
 drivers/media/usb/cx231xx/cx231xx-cards.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c 
b/drivers/media/usb/cx231xx/cx231xx-cards.c
index f9ec7fedcd5b..da01c5125acb 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -945,6 +945,9 @@ struct usb_device_id cx231xx_id_table[] = {
 .driver_info = CX231XX_BOARD_CNXT_RDE_250},
{USB_DEVICE(0x0572, 0x58A0),
 .driver_info = CX231XX_BOARD_CNXT_RDU_250},
+   /* AverMedia DVD EZMaker 7 */
+   {USB_DEVICE(0x07ca, 0xc039),
+.driver_info = CX231XX_BOARD_CNXT_VIDEO_GRABBER},
{USB_DEVICE(0x2040, 0xb110),
 .driver_info = CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL},
{USB_DEVICE(0x2040, 0xb111),
-- 
2.15.1