Re: [BUG] usb: gadget: Kernel oops with UVC USB gadget and configfs

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

 



Dne 4.2.2017 v 23:42 Robert Jarzmik napsal(a):
> Petr Cvek <petr.cvek@xxxxxx> writes:
> 
>> Setting the UVC gadget with configfs and then reloading UDC controler driver
>> (pxa27x_udc) causes kernel to fail.
>>
>> UDC subsystem was patched only in decreasing maxpacket size for UVC, addition
>> of more predefined endpoints for pxa27x_udc and addition of some debugging pr_info.
>>
>> Practically same behaviour was observed on 4.7.0 too.
> Hi Petr,
> 
> If you could provide me your "debug patch" for the new endpoints, packet size
> and pr_infos, I could try to reproduce on my platform and have a look.
> 

Sent it in the attachment, along with the belonging error log and a script to reproduce.

Not all patched parts (UDC+webcam) are probably necessary as the failure can be reproduced
without using webcam at all. Warning: patch is probably dirty formatted (I tried to
clean it a little bit, but still ...). Patch is from vanilla kernel (4.10.0-rc5) at commit:

	a4685d2f58e2230d4e27fb2ee581d7ea35e5d046 

Failure starts after last:

	modprobe pxa27x_udc

which is commented in the script. Modprobe command fails with:

	Segmentation fault

> I must say that I'm not familiar with uvc, so I can only suppose you're trying
> to stream the magician camera to USB to "act" like a Webcam, is it what you're
> trying to achieve ?

Exactly! With USB 1.1 there is little bit problem with bandwidth for raw YUV :-), but
JPEG 320x240 is fine (although I had to patch UVC function and g_webcam). UVC gadget requires
userspace part of driver. I heavily changed one from there (to sends the images from filesystem),
but it is not required to reproduce the error:

	http://git.ideasonboard.org/uvc-gadget.git

With the configfs method this userspace driver does not work, but it cannot be properly debugged
unless gadget driver/kernel oopses after reload.

Petr 

> 
> Cheers.
> 
> --
> Robert
> 

>From b444aeea9de2d8e507f2301f9fed1eb64dcc7e1e Mon Sep 17 00:00:00 2001
From: Petr Cvek <petr.cvek@xxxxxx>
Date: Wed, 3 Aug 2016 22:29:44 +0200
Subject: [PATCH] PXA27x UDC more endpoints for more gadgets + UVC gadget
 (configfs)

---
 drivers/usb/gadget/function/f_uvc.c     |  6 ++-
 drivers/usb/gadget/function/uvc_v4l2.c  | 34 +++++++++++++-
 drivers/usb/gadget/function/uvc_video.c |  3 +-
 drivers/usb/gadget/legacy/webcam.c      | 35 +++++++--------
 drivers/usb/gadget/udc/core.c           |  3 ++
 drivers/usb/gadget/udc/pxa27x_udc.c     | 79 +++++++++++++++++++++------------
 drivers/usb/gadget/udc/pxa27x_udc.h     |  7 ++-
 7 files changed, 116 insertions(+), 51 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
index 27ed51b5082f..ff20eacad4c4 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -597,6 +597,9 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
 	opts = fi_to_f_uvc_opts(f->fi);
 	/* Sanity check the streaming endpoint module parameters.
 	 */
+
+	pr_info("[DEBUG] opts->streaming_maxpacket=%i\n",opts->streaming_maxpacket);
+
 	opts->streaming_interval = clamp(opts->streaming_interval, 1U, 16U);
 	opts->streaming_maxpacket = clamp(opts->streaming_maxpacket, 1U, 3072U);
 	opts->streaming_maxburst = min(opts->streaming_maxburst, 15U);
@@ -845,7 +848,8 @@ static struct usb_function_instance *uvc_alloc_inst(void)
 		(const struct uvc_descriptor_header * const *)ctl_cls;
 
 	opts->streaming_interval = 1;
-	opts->streaming_maxpacket = 1024;
+
+	opts->streaming_maxpacket = 256;	//for PXA limit (PXA should support 1023)
 
 	uvcg_attach_configfs(opts);
 	return &opts->func_inst;
diff --git a/drivers/usb/gadget/function/uvc_v4l2.c b/drivers/usb/gadget/function/uvc_v4l2.c
index 3e22b45687d3..4a2957b765ae 100644
--- a/drivers/usb/gadget/function/uvc_v4l2.c
+++ b/drivers/usb/gadget/function/uvc_v4l2.c
@@ -61,6 +61,7 @@ struct uvc_format {
 static struct uvc_format uvc_formats[] = {
 	{ 16, V4L2_PIX_FMT_YUYV  },
 	{ 0,  V4L2_PIX_FMT_MJPEG },
+	{ 0,  V4L2_PIX_FMT_JPEG },
 };
 
 static int
@@ -81,6 +82,34 @@ uvc_v4l2_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
 	return 0;
 }
 
+//around v3.10 for v4l2 compliance
+static int uvc_v4l2_enum_format(struct file *file, void  *priv,
+                   struct v4l2_fmtdesc *fmt)
+{
+   struct uvc_format *format;
+   enum v4l2_buf_type type = fmt->type;
+
+   if (fmt->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
+       pr_info("wcam: bad type %i\n",fmt->type);
+       return -EINVAL;
+   }
+
+   if (fmt->index >= ARRAY_SIZE(uvc_formats)) {
+       pr_info("wcam: index to high %i/%i\n",fmt->index,ARRAY_SIZE(uvc_formats));
+       return -EINVAL;
+   }
+
+   fmt->pixelformat = uvc_formats[fmt->index].fcc;
+   fmt->flags = 0;	//V4L2_FMT_FLAG_COMPRESSED or V4L2_FMT_FLAG_EMULATED
+
+   strlcpy(fmt->description, "TODO\0",
+       sizeof(fmt->description));
+
+   fmt->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+
+   return 0;
+}
+
 static int
 uvc_v4l2_get_format(struct file *file, void *fh, struct v4l2_format *fmt)
 {
@@ -94,7 +123,9 @@ uvc_v4l2_get_format(struct file *file, void *fh, struct v4l2_format *fmt)
 	fmt->fmt.pix.field = V4L2_FIELD_NONE;
 	fmt->fmt.pix.bytesperline = video->bpp * video->width / 8;
 	fmt->fmt.pix.sizeimage = video->imagesize;
-	fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
+//	fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
+	fmt->fmt.pix.colorspace =   V4L2_COLORSPACE_JPEG;
+
 	fmt->fmt.pix.priv = 0;
 
 	return 0;
@@ -263,6 +294,7 @@ uvc_v4l2_ioctl_default(struct file *file, void *fh, bool valid_prio,
 
 const struct v4l2_ioctl_ops uvc_v4l2_ioctl_ops = {
 	.vidioc_querycap = uvc_v4l2_querycap,
+	.vidioc_enum_fmt_vid_out = uvc_v4l2_enum_format,
 	.vidioc_g_fmt_vid_out = uvc_v4l2_get_format,
 	.vidioc_s_fmt_vid_out = uvc_v4l2_set_format,
 	.vidioc_reqbufs = uvc_v4l2_reqbufs,
diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
index 0f01c04d7cbd..e746b3bce90f 100644
--- a/drivers/usb/gadget/function/uvc_video.c
+++ b/drivers/usb/gadget/function/uvc_video.c
@@ -384,7 +384,8 @@ int uvcg_video_init(struct uvc_video *video)
 	INIT_LIST_HEAD(&video->req_free);
 	spin_lock_init(&video->req_lock);
 
-	video->fcc = V4L2_PIX_FMT_YUYV;
+//	video->fcc = V4L2_PIX_FMT_YUYV;
+video->fcc = V4L2_PIX_FMT_MJPEG;
 	video->bpp = 16;
 	video->width = 320;
 	video->height = 240;
diff --git a/drivers/usb/gadget/legacy/webcam.c b/drivers/usb/gadget/legacy/webcam.c
index f9661cd627c8..9478412b224d 100644
--- a/drivers/usb/gadget/legacy/webcam.c
+++ b/drivers/usb/gadget/legacy/webcam.c
@@ -42,7 +42,7 @@ MODULE_PARM_DESC(trace, "Trace level bitmask");
  */
 
 #define WEBCAM_VENDOR_ID		0x1d6b	/* Linux Foundation */
-#define WEBCAM_PRODUCT_ID		0x0102	/* Webcam A/V gadget */
+#define WEBCAM_PRODUCT_ID		0x0666	/* Webcam A/V gadget, dummy PID */
 #define WEBCAM_DEVICE_BCD		0x0010	/* 0.10 */
 
 static char webcam_vendor_label[] = "Linux Foundation";
@@ -235,14 +235,14 @@ static const struct uvc_format_mjpeg uvc_format_mjpg = {
 DECLARE_UVC_FRAME_MJPEG(1);
 DECLARE_UVC_FRAME_MJPEG(3);
 
-static const struct UVC_FRAME_MJPEG(3) uvc_frame_mjpg_360p = {
+static const struct UVC_FRAME_MJPEG(3) uvc_frame_mjpg_240p = {
 	.bLength		= UVC_DT_FRAME_MJPEG_SIZE(3),
 	.bDescriptorType	= USB_DT_CS_INTERFACE,
 	.bDescriptorSubType	= UVC_VS_FRAME_MJPEG,
 	.bFrameIndex		= 1,
 	.bmCapabilities		= 0,
-	.wWidth			= cpu_to_le16(640),
-	.wHeight		= cpu_to_le16(360),
+	.wWidth			= cpu_to_le16(320),
+	.wHeight		= cpu_to_le16(240),
 	.dwMinBitRate		= cpu_to_le32(18432000),
 	.dwMaxBitRate		= cpu_to_le32(55296000),
 	.dwMaxVideoFrameBufferSize	= cpu_to_le32(460800),
@@ -253,14 +253,14 @@ static const struct UVC_FRAME_MJPEG(3) uvc_frame_mjpg_360p = {
 	.dwFrameInterval[2]	= cpu_to_le32(5000000),
 };
 
-static const struct UVC_FRAME_MJPEG(1) uvc_frame_mjpg_720p = {
+static const struct UVC_FRAME_MJPEG(1) uvc_frame_mjpg_480p = {
 	.bLength		= UVC_DT_FRAME_MJPEG_SIZE(1),
 	.bDescriptorType	= USB_DT_CS_INTERFACE,
 	.bDescriptorSubType	= UVC_VS_FRAME_MJPEG,
 	.bFrameIndex		= 2,
 	.bmCapabilities		= 0,
-	.wWidth			= cpu_to_le16(1280),
-	.wHeight		= cpu_to_le16(720),
+	.wWidth			= cpu_to_le16(640),
+	.wHeight		= cpu_to_le16(480),
 	.dwMinBitRate		= cpu_to_le32(29491200),
 	.dwMaxBitRate		= cpu_to_le32(29491200),
 	.dwMaxVideoFrameBufferSize	= cpu_to_le32(1843200),
@@ -296,12 +296,9 @@ static const struct uvc_descriptor_header * const uvc_ss_control_cls[] = {
 
 static const struct uvc_descriptor_header * const uvc_fs_streaming_cls[] = {
 	(const struct uvc_descriptor_header *) &uvc_input_header,
-	(const struct uvc_descriptor_header *) &uvc_format_yuv,
-	(const struct uvc_descriptor_header *) &uvc_frame_yuv_360p,
-	(const struct uvc_descriptor_header *) &uvc_frame_yuv_720p,
 	(const struct uvc_descriptor_header *) &uvc_format_mjpg,
-	(const struct uvc_descriptor_header *) &uvc_frame_mjpg_360p,
-	(const struct uvc_descriptor_header *) &uvc_frame_mjpg_720p,
+	(const struct uvc_descriptor_header *) &uvc_frame_mjpg_240p,
+	(const struct uvc_descriptor_header *) &uvc_frame_mjpg_480p,
 	(const struct uvc_descriptor_header *) &uvc_color_matching,
 	NULL,
 };
@@ -312,8 +309,8 @@ static const struct uvc_descriptor_header * const uvc_hs_streaming_cls[] = {
 	(const struct uvc_descriptor_header *) &uvc_frame_yuv_360p,
 	(const struct uvc_descriptor_header *) &uvc_frame_yuv_720p,
 	(const struct uvc_descriptor_header *) &uvc_format_mjpg,
-	(const struct uvc_descriptor_header *) &uvc_frame_mjpg_360p,
-	(const struct uvc_descriptor_header *) &uvc_frame_mjpg_720p,
+	(const struct uvc_descriptor_header *) &uvc_frame_mjpg_240p,
+	(const struct uvc_descriptor_header *) &uvc_frame_mjpg_480p,
 	(const struct uvc_descriptor_header *) &uvc_color_matching,
 	NULL,
 };
@@ -324,8 +321,8 @@ static const struct uvc_descriptor_header * const uvc_ss_streaming_cls[] = {
 	(const struct uvc_descriptor_header *) &uvc_frame_yuv_360p,
 	(const struct uvc_descriptor_header *) &uvc_frame_yuv_720p,
 	(const struct uvc_descriptor_header *) &uvc_format_mjpg,
-	(const struct uvc_descriptor_header *) &uvc_frame_mjpg_360p,
-	(const struct uvc_descriptor_header *) &uvc_frame_mjpg_720p,
+	(const struct uvc_descriptor_header *) &uvc_frame_mjpg_240p,
+	(const struct uvc_descriptor_header *) &uvc_frame_mjpg_480p,
 	(const struct uvc_descriptor_header *) &uvc_color_matching,
 	NULL,
 };
@@ -352,7 +349,7 @@ webcam_config_bind(struct usb_configuration *c)
 
 static struct usb_configuration webcam_config_driver = {
 	.label			= webcam_config_label,
-	.bConfigurationValue	= 1,
+	.bConfigurationValue	= 3,	// set during userspace program test
 	.iConfiguration		= 0, /* dynamic */
 	.bmAttributes		= USB_CONFIG_ATT_SELFPOWER,
 	.MaxPower		= CONFIG_USB_GADGET_VBUS_DRAW,
@@ -406,8 +403,10 @@ webcam_bind(struct usb_composite_dev *cdev)
 
 	/* Register our configuration. */
 	if ((ret = usb_add_config(cdev, &webcam_config_driver,
-					webcam_config_bind)) < 0)
+					webcam_config_bind)) < 0) {
+		pr_err("ERR: webcam usb_add_config ret=%i\n",ret);
 		goto error;
+	}
 
 	usb_composite_overwrite_options(cdev, &coverwrite);
 	INFO(cdev, "Webcam Video Gadget\n");
diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index 0402177f93cd..382baf40d32b 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -897,6 +897,8 @@ int usb_gadget_ep_match_desc(struct usb_gadget *gadget,
 	u16		max;
 	int		num_req_streams = 0;
 
+	pr_info("====name: %s, mp=%i\n",ep->name,ep->maxpacket_limit);
+
 	/* endpoint already claimed? */
 	if (ep->claimed)
 		return 0;
@@ -906,6 +908,7 @@ int usb_gadget_ep_match_desc(struct usb_gadget *gadget,
 
 	if (usb_endpoint_dir_in(desc) && !ep->caps.dir_in)
 		return 0;
+
 	if (usb_endpoint_dir_out(desc) && !ep->caps.dir_out)
 		return 0;
 
diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c
index 7fa60f5b7ae4..654605412cfd 100644
--- a/drivers/usb/gadget/udc/pxa27x_udc.c
+++ b/drivers/usb/gadget/udc/pxa27x_udc.c
@@ -2381,38 +2381,61 @@ static struct pxa_udc memory = {
 
 	.udc_usb_ep = {
 		USB_EP_CTRL,
-		USB_EP_OUT_BULK(1),
-		USB_EP_IN_BULK(2),
-		USB_EP_IN_ISO(3),
-		USB_EP_OUT_ISO(4),
-		USB_EP_IN_INT(5),
+		USB_EP_IN_INT(1),
+		USB_EP_IN_INT(2),
+		USB_EP_OUT_INT(3),
+
+		USB_EP_IN_ISO(4),
+		USB_EP_OUT_ISO(5),
+		USB_EP_IN_BULK(6),
+		USB_EP_OUT_BULK(7),
+
+		USB_EP_IN_BULK(8),
+		USB_EP_OUT_BULK(9),
+
+		USB_EP_IN_ISO(10),
+		USB_EP_OUT_BULK(11),
+		USB_EP_IN_BULK(12),
+		USB_EP_IN_INT(13),
+		USB_EP_OUT_INT(14),
 	},
 
 	.pxa_ep = {
 		PXA_EP_CTRL,
-		/* Endpoints for gadget zero */
-		PXA_EP_OUT_BULK(1, 1, 3, 0, 0),
-		PXA_EP_IN_BULK(2,  2, 3, 0, 0),
-		/* Endpoints for ether gadget, file storage gadget */
-		PXA_EP_OUT_BULK(3, 1, 1, 0, 0),
-		PXA_EP_IN_BULK(4,  2, 1, 0, 0),
-		PXA_EP_IN_ISO(5,   3, 1, 0, 0),
-		PXA_EP_OUT_ISO(6,  4, 1, 0, 0),
-		PXA_EP_IN_INT(7,   5, 1, 0, 0),
-		/* Endpoints for RNDIS, serial */
-		PXA_EP_OUT_BULK(8, 1, 2, 0, 0),
-		PXA_EP_IN_BULK(9,  2, 2, 0, 0),
-		PXA_EP_IN_INT(10,  5, 2, 0, 0),
-		/*
-		 * All the following endpoints are only for completion.  They
-		 * won't never work, as multiple interfaces are really broken on
-		 * the pxa.
-		*/
-		PXA_EP_OUT_BULK(11, 1, 2, 1, 0),
-		PXA_EP_IN_BULK(12,  2, 2, 1, 0),
-		/* Endpoint for CDC Ether */
-		PXA_EP_OUT_BULK(13, 1, 1, 1, 1),
-		PXA_EP_IN_BULK(14,  2, 1, 1, 1),
+
+/* NOTICE these endpoints were crafted (around 3.13) before changes in the UDC
+endpoint lookup functions. They may be redundant now. */
+
+		/*g_hid*/
+		PXA_EP_IN_INT(1,    1, 1, 0, 0),
+		PXA_EP_OUT_INT(2,   3, 1, 0, 0),
+		/*g_audio uac2*/
+		PXA_EP_OUT_ISO(3,   5, 1, 1, 1),
+		PXA_EP_IN_ISO(4,    4, 1, 2, 1),
+		/*g_ether, mass storage*/
+		PXA_EP_IN_BULK(5,   6, 1, 0, 0),
+		PXA_EP_OUT_BULK(6,  7, 1, 0, 0),
+		/*g_webcam*/
+		PXA_EP_IN_INT(7,    1, 3, 0, 0),
+		PXA_EP_IN_ISO(8,    4, 3, 1, 1),
+		/*g_cdc maybe?*/
+		PXA_EP_IN_BULK(9,   6, 1, 1, 1),
+		PXA_EP_OUT_BULK(10, 7, 1, 1, 1),
+		PXA_EP_IN_INT(11,   1, 1, 0, 0),
+		PXA_EP_IN_BULK(12,  6, 1, 0, 0),
+		PXA_EP_OUT_BULK(13, 7, 1, 0, 0),
+		PXA_EP_IN_INT(14,   2, 1, 0, 0),
+		/*additional userspace gadget?*/
+		PXA_EP_IN_BULK(15,  6, 1, 2, 0),
+		PXA_EP_OUT_BULK(16, 7, 1, 2, 0),
+		PXA_EP_IN_ISO(17,   4, 1, 1, 1),
+		/*free*/
+		PXA_EP_OUT_BULK(18, 11, 1, 1, 0),
+		PXA_EP_IN_BULK(19,  12, 2, 0, 0),
+		PXA_EP_OUT_BULK(20, 11, 2, 0, 0),
+		PXA_EP_IN_BULK(21,  12, 2, 1, 0),
+		PXA_EP_OUT_BULK(22, 11, 2, 1, 0),
+		PXA_EP_IN_INT(23,   13, 3, 0, 0),
 	}
 };
 
diff --git a/drivers/usb/gadget/udc/pxa27x_udc.h b/drivers/usb/gadget/udc/pxa27x_udc.h
index cea2cb79b30c..586c9bc9a748 100644
--- a/drivers/usb/gadget/udc/pxa27x_udc.h
+++ b/drivers/usb/gadget/udc/pxa27x_udc.h
@@ -261,6 +261,8 @@
 					USB_EP_CAPS_DIR_OUT)
 #define USB_EP_IN_INT(n)	USB_EP_INT(n,  "ep" #n "in-int", 1, \
 					USB_EP_CAPS_DIR_IN)
+#define USB_EP_OUT_INT(n)	USB_EP_INT(n,  "ep" #n "out-int", 0, \
+					USB_EP_CAPS_DIR_OUT)
 #define USB_EP_CTRL	USB_EP_DEF(0,  "ep0", 0, CONTROL, EP0_FIFO_SIZE, \
 				USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_ALL)
 
@@ -287,6 +289,7 @@
 #define PXA_EP_IN_ISO(i, adr, c, f, a)		PXA_EP_ISO(i, adr, 1, c, f, a)
 #define PXA_EP_OUT_ISO(i, adr, c, f, a)		PXA_EP_ISO(i, adr, 0, c, f, a)
 #define PXA_EP_IN_INT(i, adr, c, f, a)		PXA_EP_INT(i, adr, 1, c, f, a)
+#define PXA_EP_OUT_INT(i, adr, c, f, a)		PXA_EP_INT(i, adr, 0, c, f, a)
 #define PXA_EP_CTRL	PXA_EP_DEF(0, 0, 0, 0, EP0_FIFO_SIZE, 0, 0, 0)
 
 struct pxa27x_udc;
@@ -419,8 +422,8 @@ struct udc_stats {
 	unsigned long	irqs_reconfig;
 };
 
-#define NR_USB_ENDPOINTS (1 + 5)	/* ep0 + ep1in-bulk + .. + ep3in-iso */
-#define NR_PXA_ENDPOINTS (1 + 14)	/* ep0 + epA + epB + .. + epX */
+#define NR_USB_ENDPOINTS (1 + 14) /* ep0 + ep1in-int + .. + ep14out-int */
+#define NR_PXA_ENDPOINTS (1 + 23) /* ep0 + epA + epB + .. + epX */
 
 /**
  * struct pxa_udc - udc structure
-- 
2.11.0

[ 2108.316373] configfs-gadget gadget: uvc_function_bind
[ 2108.316440] [DEBUG] opts->streaming_maxpacket=256
[ 2108.316467] ====name: ep1in-int, mp=16
[ 2108.316495] ====name: ep1in-int, mp=16
[ 2108.316508] ====name: ep2in-int, mp=16
[ 2108.316520] ====name: ep3out-int, mp=16
[ 2108.316532] ====name: ep4in-iso, mp=256
[ 2108.659336] configfs-gadget gadget: uvc_unbind
[ 2152.789540] configfs-gadget gadget: uvc_function_bind
[ 2152.789611] [DEBUG] opts->streaming_maxpacket=256
[ 2152.789639] ====name: ep1in-int, mp=16
[ 2152.789666] ====name: ep1in-int, mp=16
[ 2152.789679] ====name: ep2in-int, mp=16
[ 2152.789692] ====name: ep3out-int, mp=16
[ 2152.793067] ====name: ep4in-iso, mp=256
[ 2152.793479] kobject (c3831030): tried to init an initialized object, something is seriously wrong.
[ 2152.793515] CPU: 0 PID: 15666 Comm: modprobe Not tainted 4.10.0-rc5-magician+ #36
[ 2152.793527] Hardware name: HTC Magician
[ 2152.793693] [<c000f300>] (unwind_backtrace) from [<c000d1ac>] (show_stack+0x10/0x14)
[ 2152.794125] [<c000d1ac>] (show_stack) from [<c01dd010>] (kobject_init+0x34/0x90)
[ 2152.794198] [<c01dd010>] (kobject_init) from [<c024bd70>] (device_initialize+0x20/0x9c)
[ 2152.794256] [<c024bd70>] (device_initialize) from [<c024e0a4>] (device_register+0xc/0x18)
[ 2152.795172] [<c024e0a4>] (device_register) from [<bf0e653c>] (__video_register_device+0xf8c/0x1600 [videodev])
[ 2152.806611] [<bf0e653c>] (__video_register_device [videodev]) from [<bf4c7be4>] (uvc_function_bind+0x3dc/0x430 [usb_f_uvc])
[ 2152.814300] [<bf4c7be4>] (uvc_function_bind [usb_f_uvc]) from [<bf4b5d70>] (usb_add_function+0x108/0x1ac [libcomposite])
[ 2152.820006] [<bf4b5d70>] (usb_add_function [libcomposite]) from [<bf4b9b24>] (configfs_composite_bind+0x2a0/0x30c [libcomposite])
[ 2152.825943] [<bf4b9b24>] (configfs_composite_bind [libcomposite]) from [<bf4a1914>] (udc_bind_to_driver+0x34/0xf0 [udc_core])
[ 2152.826529] [<bf4a1914>] (udc_bind_to_driver [udc_core]) from [<bf4a1b08>] (usb_add_gadget_udc_release+0x138/0x21c [udc_core])
[ 2152.826731] [<bf4a1b08>] (usb_add_gadget_udc_release [udc_core]) from [<bf4db838>] (pxa_udc_probe+0x290/0x2fc [pxa27x_udc])
[ 2152.833554] [<bf4db838>] (pxa_udc_probe [pxa27x_udc]) from [<c02522d0>] (platform_drv_probe+0x38/0x84)
[ 2152.833602] [<c02522d0>] (platform_drv_probe) from [<c0250784>] (driver_probe_device+0x1e0/0x3f4)
[ 2152.833633] [<c0250784>] (driver_probe_device) from [<c0250a18>] (__driver_attach+0x80/0xf0)
[ 2152.833709] [<c0250a18>] (__driver_attach) from [<c024ebc8>] (bus_for_each_dev+0x7c/0x8c)
[ 2152.834050] [<c024ebc8>] (bus_for_each_dev) from [<c024fd14>] (bus_add_driver+0x170/0x220)
[ 2152.834085] [<c024fd14>] (bus_add_driver) from [<c0251368>] (driver_register+0xa0/0xe0)
[ 2152.834127] [<c0251368>] (driver_register) from [<c00097f4>] (do_one_initcall+0x144/0x17c)
[ 2152.834211] [<c00097f4>] (do_one_initcall) from [<c006eeec>] (do_init_module+0x50/0x374)
[ 2152.834251] [<c006eeec>] (do_init_module) from [<c00696f8>] (load_module+0x177c/0x1cd8)
[ 2152.834286] [<c00696f8>] (load_module) from [<c0069d88>] (SyS_init_module+0x134/0x148)
[ 2152.834319] [<c0069d88>] (SyS_init_module) from [<c000a320>] (ret_fast_syscall+0x0/0x38)
[ 2152.834547] Unable to handle kernel paging request at virtual address bf4ae600
[ 2152.834570] pgd = c1270000
[ 2152.834584] [bf4ae600] *pgd=a3597811, *pte=00000000, *ppte=00000000
[ 2152.834654] Internal error: Oops: 7 [#1] PREEMPT ARM
[ 2152.834671] Modules linked in: pxa27x_udc(+) usb_f_uvc libcomposite udc_core videobuf2_vmalloc ppp_deflate zlib_inflate zlib_deflate bsd_comp ppp_async ppp_generic slhc ircomm_tty ircomm ds2760_battery w1_ds2760 ds1wm wire configfs btusb btintel bluetooth firmware_class ads7846 max1586 soc_mediabus ohci_pxa27x pxaficp_ir fixed videobuf2_dma_sg videobuf2_memops spi_pxa2xx_platform ohci_hcd v4l2_common irda videobuf2_v4l2 pwm_bl usbcore i2c_pxa backlight videodev pwm_pxa usb_common videobuf2_core i2c_core snd_soc_pxa2xx snd_soc_pxa_ssp snd_pxa2xx_lib rtc_pxa snd_pcm_dmaengine ssp rtc_sa1100 snd_soc_core snd_pcm snd_timer snd htc_pasic3 soundcore pda_power mfd_core leds_gpio led_class [last unloaded: pxa27x_udc]
[ 2152.835206] CPU: 0 PID: 15666 Comm: modprobe Not tainted 4.10.0-rc5-magician+ #36
[ 2152.835224] Hardware name: HTC Magician
[ 2152.835252] task: c365b1a0 task.stack: c1512000
[ 2152.835310] PC is at kobject_get+0xc/0x98
[ 2152.835341] LR is at get_device+0x14/0x1c
[ 2152.835367] pc : [<c01dd474>]    lr : [<c024bf98>]    psr: a0000013
[ 2152.835367] sp : c1513bd8  ip : c0498f20  fp : 00000001
[ 2152.835382] r10: c04d900c  r9 : bf0f59b4  r8 : 00000000
[ 2152.835399] r7 : 00000000  r6 : c38311dc  r5 : c3831020  r4 : bf4ae5e0
[ 2152.835417] r3 : c170c140  r2 : c170c140  r1 : c045c3ba  r0 : bf4ae5e0
[ 2152.835441] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[ 2152.835460] Control: 0000397f  Table: a1270000  DAC: 00000051
[ 2152.835477] Process modprobe (pid: 15666, stack limit = 0xc1512198)
[ 2152.835495] Stack: (0xc1513bd8 to 0xc1514000)
[ 2152.835520] 3bc0:                                                       bf4ae5e0 c045c3ba
[ 2152.835551] 3be0: c3831028 c024bf98 c3831028 c024dc60 00000001 c003dc78 c3831028 c383109c
[ 2152.835581] 3c00: 00000000 7501637c c3831028 c3831028 c3831020 c38311dc 00000000 00000000
[ 2152.835611] 3c20: bf0f59b4 00000001 00000001 bf0e653c c3fa94e0 c3831240 fffffffc 00000001
[ 2152.835641] 3c40: 00000000 00000000 000e8335 00000000 0e000018 00000000 00000000 00000000
[ 2152.835671] 3c60: c3831240 c3831294 00000001 00000000 c31e4f54 c3831240 c3831020 00000000
[ 2152.835703] 3c80: bf4dd5a0 bf4c7be4 bf4cdaa0 c3831294 c3831294 c0cbd828 bf4c7808 00000000
[ 2152.835735] 3ca0: c31e4f54 c0cbd844 c31e4d00 bf4b5d70 c0cbd828 c3831294 c38312ec 00000200
[ 2152.835768] 3cc0: c31e4ee0 c0cbd828 c3831294 bf4b9b24 c1512000 c31e4f8c c38312ec c0cbd89c
[ 2152.835799] 3ce0: 00000001 c3224c40 c31e4ee0 bf4a2bf4 00000000 c3224c48 bf4dd5d8 c04dfdb8
[ 2152.835831] 3d00: c4f95000 bf4a1914 c3224c40 c31e4ee0 bf4a2bf4 bf4a1b08 bf4dcdac bf4dd580
[ 2152.835862] 3d20: 00000000 c04dfdb8 bf4dd590 0000000f c1513f44 bf4db838 00000080 bf4dcdac
[ 2152.835893] 3d40: bf4dd590 c1513f44 c4f95000 bf4db5a8 c04dfdb8 bf4de104 00000000 00000000
[ 2152.835925] 3d60: 00000035 c02522d0 c04dfdb8 bf4de104 c055e288 c0250784 bf4de104 c04dfdb8
[ 2152.835955] 3d80: 60000013 c04dfdb8 c04dfdec bf4de104 00000000 00000001 00000000 c0250a18
[ 2152.835986] 3da0: 00000000 bf4de104 c0250998 c024ebc8 c384e50c c3864050 bf4de104 c3388640
[ 2152.836017] 3dc0: c05002d8 c024fd14 bf4dd3dd 00000001 00000000 bf4de104 c04d900c ffffe000
[ 2152.836048] 3de0: c33eab20 c0251368 bf4e1000 c04d900c ffffe000 c00097f4 c38636a0 00000000
[ 2152.836079] 3e00: 00000020 ffffffe0 00000020 c04ea43c c3fc1780 0000002c 014000c0 00000020
[ 2152.836109] 3e20: 80000013 c1513f44 00000016 c00aab60 0000002c c04ea43c 00000020 0000000c
[ 2152.836139] 3e40: 00000001 7501637c c33eab20 bf4de540 00000001 c23bcfe0 c33eab20 00000001
[ 2152.836170] 3e60: c33eab44 c006eeec bf4de540 00000001 bf4de540 00000001 bf4de588 c00696f8
[ 2152.836201] 3e80: bf4de54c 00007fff bf4de540 c0067510 c0066f48 00000074 c0367d04 c4f9c71c
[ 2152.836232] 3ea0: bf4de698 000000dc 01fba5f0 c035f8b0 c01d8290 20000013 00000000 00000000
[ 2152.836260] 3ec0: 00000000 00000000 00000000 00000000 6e72656b 00006c65 00000000 00000000
[ 2152.836287] 3ee0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 2152.836316] 3f00: 00000000 00000000 00000000 7501637c 00000000 0000776c 01fc34d4 00000000
[ 2152.836347] 3f20: c4f9c76c c1512000 01fba5f0 00000051 000c5d40 c0069d88 c0dd1768 c00c624c
[ 2152.836379] 3f40: c0dd1760 c4f95000 0000776c c4f9c1cc c4f9c064 c4f9a648 000046c0 00004fd0
[ 2152.836408] 3f60: bf4de280 00000016 00000000 00001718 00000022 00000023 0000001b 00000000
[ 2152.836438] 3f80: 00000013 00000000 0000776c 01fba5a8 01fba5f0 00000080 c000a4c4 c1512000
[ 2152.836468] 3fa0: 00020000 c000a320 0000776c 01fba5a8 01fbbd68 0000776c 01fba5f0 01fba610
[ 2152.836500] 3fc0: 0000776c 01fba5a8 01fba5f0 00000080 000c5d74 01fba610 00000000 000c5d40
[ 2152.836531] 3fe0: beef0aa0 beef0a90 00025bf0 b6e39ff0 60000010 01fbbd68 0068732f 00000000
[ 2152.836629] [<c01dd474>] (kobject_get) from [<c024bf98>] (get_device+0x14/0x1c)
[ 2152.836675] [<c024bf98>] (get_device) from [<c024dc60>] (device_add+0xe8/0x520)
[ 2152.837575] [<c024dc60>] (device_add) from [<bf0e653c>] (__video_register_device+0xf8c/0x1600 [videodev])
[ 2152.838920] [<bf0e653c>] (__video_register_device [videodev]) from [<bf4c7be4>] (uvc_function_bind+0x3dc/0x430 [usb_f_uvc])
[ 2152.839437] [<bf4c7be4>] (uvc_function_bind [usb_f_uvc]) from [<bf4b5d70>] (usb_add_function+0x108/0x1ac [libcomposite])
[ 2152.839627] [<bf4b5d70>] (usb_add_function [libcomposite]) from [<bf4b9b24>] (configfs_composite_bind+0x2a0/0x30c [libcomposite])
[ 2152.839940] [<bf4b9b24>] (configfs_composite_bind [libcomposite]) from [<bf4a1914>] (udc_bind_to_driver+0x34/0xf0 [udc_core])
[ 2152.840055] [<bf4a1914>] (udc_bind_to_driver [udc_core]) from [<bf4a1b08>] (usb_add_gadget_udc_release+0x138/0x21c [udc_core])
[ 2152.840267] [<bf4a1b08>] (usb_add_gadget_udc_release [udc_core]) from [<bf4db838>] (pxa_udc_probe+0x290/0x2fc [pxa27x_udc])
[ 2152.840380] [<bf4db838>] (pxa_udc_probe [pxa27x_udc]) from [<c02522d0>] (platform_drv_probe+0x38/0x84)
[ 2152.840425] [<c02522d0>] (platform_drv_probe) from [<c0250784>] (driver_probe_device+0x1e0/0x3f4)
[ 2152.840456] [<c0250784>] (driver_probe_device) from [<c0250a18>] (__driver_attach+0x80/0xf0)
[ 2152.840531] [<c0250a18>] (__driver_attach) from [<c024ebc8>] (bus_for_each_dev+0x7c/0x8c)
[ 2152.840579] [<c024ebc8>] (bus_for_each_dev) from [<c024fd14>] (bus_add_driver+0x170/0x220)
[ 2152.840614] [<c024fd14>] (bus_add_driver) from [<c0251368>] (driver_register+0xa0/0xe0)
[ 2152.840658] [<c0251368>] (driver_register) from [<c00097f4>] (do_one_initcall+0x144/0x17c)
[ 2152.840740] [<c00097f4>] (do_one_initcall) from [<c006eeec>] (do_init_module+0x50/0x374)
[ 2152.840782] [<c006eeec>] (do_init_module) from [<c00696f8>] (load_module+0x177c/0x1cd8)
[ 2152.840818] [<c00696f8>] (load_module) from [<c0069d88>] (SyS_init_module+0x134/0x148)
[ 2152.840851] [<c0069d88>] (SyS_init_module) from [<c000a320>] (ret_fast_syscall+0x0/0x38)
[ 2152.840886] Code: eaffffd4 e92d4013 e2504000 0a00001a (e5d43020) 
[ 2152.868355] ---[ end trace 9640cb4354b07b80 ]---
#!/bin/sh
rm -r /tmp/udc/usb_gadget/
rm -r /tmp/udc/usb_gadget/
rm -r /tmp/udc/usb_gadget/
umount /tmp/udc

rmmod usb_f_eem g_ether usb_f_rndis u_ether
rmmod usb_f_eem g_ether usb_f_rndis u_ether
rmmod usb_f_eem g_ether usb_f_rndis u_ether
rmmod usb_f_eem g_ether usb_f_rndis u_ether
rmmod usb_f_uvc libcomposite pxa27x_udc udc_core
rmmod usb_f_uvc libcomposite pxa27x_udc udc_core




modprobe udc-core
modprobe pxa27x-udc
modprobe libcomposite
modprobe usb_f_uvc

mkdir -p /tmp/udc
cd /tmp/udc

mount none /tmp/udc -t configfs
sleep 1
mkdir -p /tmp/udc/usb_gadget/gcam
sleep 1
cd /tmp/udc/usb_gadget/gcam
mkdir -p configs/c.1

mkdir -p functions/uvc.usb0
mkdir -p strings/0x409
mkdir -p configs/c.1/strings/0x409

echo 0x1d6b > idVendor
echo 0x0102 > idProduct
echo 16 > bMaxPacketSize0
echo "Magician" > strings/0x409/serialnumber
echo "Linux Foundation" > strings/0x409/manufacturer
echo "Webcam/EEM" > strings/0x409/product
echo "Video" > configs/c.1/strings/0x409/configuration
echo 239 > bDeviceClass
echo 2 > bDeviceSubClass
echo 1 > bDeviceProtocol
echo 500 > configs/c.1/MaxPower
echo 0xc0 > configs/c.1/bmAttributes

mkdir -p functions/uvc.usb0/streaming/mjpeg/m/240p
cat <<EOF > functions/uvc.usb0/streaming/mjpeg/m/240p/dwFrameInterval
666666
1000000
5000000
EOF
echo "320" > functions/uvc.usb0/streaming/mjpeg/m/240p/wWidth 
echo "240" > functions/uvc.usb0/streaming/mjpeg/m/240p/wHeight
echo "2000000" >  functions/uvc.usb0/streaming/mjpeg/m/240p/dwDefaultFrameInterval

mkdir -p functions/uvc.usb0/streaming/header/h
cd functions/uvc.usb0/streaming/header/h
ln -s ../../mjpeg/m
cd ../../class/fs
ln -s ../../header/h

cd ../../class/hs
ln -s ../../header/h

cd ../../../control
mkdir header/h
ln -s header/h class/fs

ln -s header/h class/ss

cd ../../../
ln -s functions/uvc.usb0 configs/c.1

echo pxa27x-udc > UDC

rmmod pxa27x_udc

#modprobe pxa27x_udc


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux