Merge tag 'usb-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB/PHY updates from Greg KH: "Here is the big USB/PHY driver patches for 4.20-rc1 Lots of USB changes in here, primarily in these areas: - typec updates and new drivers - new PHY drivers - dwc2 driver updates and additions (this old core keeps getting added to new devices.) - usbtmc major update based on the industry group coming together and working to add new features and performance to the driver. - USB gadget additions for new features - USB gadget configfs updates - chipidea driver updates - other USB gadget updates - USB serial driver updates - renesas driver updates - xhci driver updates - other tiny USB driver updates All of these have been in linux-next for a while with no reported issues" * tag 'usb-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (229 commits) usb: phy: ab8500: silence some uninitialized variable warnings usb: xhci: tegra: Add genpd support usb: xhci: tegra: Power-off power-domains on removal usbip:vudc: BUG kmalloc-2048 (Not tainted): Poison overwritten usbip: tools: fix atoi() on non-null terminated string USB: misc: appledisplay: fix backlight update_status return code phy: phy-pxa-usb: add a new driver usb: host: add DT bindings for faraday fotg2 usb: host: ohci-at91: fix request of irq for optional gpio usb/early: remove set but not used variable 'remain_length' usb: typec: Fix copy/paste on typec_set_vconn_role() kerneldoc usb: typec: tcpm: Report back negotiated PPS voltage and current USB: core: remove set but not used variable 'udev' usb: core: fix memory leak on port_dev_path allocation USB: net2280: Remove ->disconnect() callback from net2280_pullup() usb: dwc2: disable power_down on rockchip devices usb: gadget: udc: renesas_usb3: add support for r8a77990 dt-bindings: usb: renesas_usb3: add bindings for r8a77990 usb: gadget: udc: renesas_usb3: Add r8a774a1 support USB: serial: cypress_m8: remove set but not used variable 'iflag' ...
This commit is contained in:
@@ -22,12 +22,8 @@
|
||||
* controlled by two clock sources :
|
||||
* CLK_5 := c_srate, and CLK_6 := p_srate
|
||||
*/
|
||||
#define USB_OUT_IT_ID 1
|
||||
#define IO_IN_IT_ID 2
|
||||
#define IO_OUT_OT_ID 3
|
||||
#define USB_IN_OT_ID 4
|
||||
#define USB_OUT_CLK_ID 5
|
||||
#define USB_IN_CLK_ID 6
|
||||
#define USB_OUT_CLK_ID (out_clk_src_desc.bClockID)
|
||||
#define USB_IN_CLK_ID (in_clk_src_desc.bClockID)
|
||||
|
||||
#define CONTROL_ABSENT 0
|
||||
#define CONTROL_RDONLY 1
|
||||
@@ -43,6 +39,9 @@
|
||||
#define UNFLW_CTRL 8
|
||||
#define OVFLW_CTRL 10
|
||||
|
||||
#define EPIN_EN(_opts) ((_opts)->p_chmask != 0)
|
||||
#define EPOUT_EN(_opts) ((_opts)->c_chmask != 0)
|
||||
|
||||
struct f_uac2 {
|
||||
struct g_audio g_audio;
|
||||
u8 ac_intf, as_in_intf, as_out_intf;
|
||||
@@ -135,7 +134,7 @@ static struct uac_clock_source_descriptor in_clk_src_desc = {
|
||||
.bDescriptorType = USB_DT_CS_INTERFACE,
|
||||
|
||||
.bDescriptorSubtype = UAC2_CLOCK_SOURCE,
|
||||
.bClockID = USB_IN_CLK_ID,
|
||||
/* .bClockID = DYNAMIC */
|
||||
.bmAttributes = UAC_CLOCK_SOURCE_TYPE_INT_FIXED,
|
||||
.bmControls = (CONTROL_RDONLY << CLK_FREQ_CTRL),
|
||||
.bAssocTerminal = 0,
|
||||
@@ -147,7 +146,7 @@ static struct uac_clock_source_descriptor out_clk_src_desc = {
|
||||
.bDescriptorType = USB_DT_CS_INTERFACE,
|
||||
|
||||
.bDescriptorSubtype = UAC2_CLOCK_SOURCE,
|
||||
.bClockID = USB_OUT_CLK_ID,
|
||||
/* .bClockID = DYNAMIC */
|
||||
.bmAttributes = UAC_CLOCK_SOURCE_TYPE_INT_FIXED,
|
||||
.bmControls = (CONTROL_RDONLY << CLK_FREQ_CTRL),
|
||||
.bAssocTerminal = 0,
|
||||
@@ -159,10 +158,10 @@ static struct uac2_input_terminal_descriptor usb_out_it_desc = {
|
||||
.bDescriptorType = USB_DT_CS_INTERFACE,
|
||||
|
||||
.bDescriptorSubtype = UAC_INPUT_TERMINAL,
|
||||
.bTerminalID = USB_OUT_IT_ID,
|
||||
/* .bTerminalID = DYNAMIC */
|
||||
.wTerminalType = cpu_to_le16(UAC_TERMINAL_STREAMING),
|
||||
.bAssocTerminal = 0,
|
||||
.bCSourceID = USB_OUT_CLK_ID,
|
||||
/* .bCSourceID = DYNAMIC */
|
||||
.iChannelNames = 0,
|
||||
.bmControls = cpu_to_le16(CONTROL_RDWR << COPY_CTRL),
|
||||
};
|
||||
@@ -173,10 +172,10 @@ static struct uac2_input_terminal_descriptor io_in_it_desc = {
|
||||
.bDescriptorType = USB_DT_CS_INTERFACE,
|
||||
|
||||
.bDescriptorSubtype = UAC_INPUT_TERMINAL,
|
||||
.bTerminalID = IO_IN_IT_ID,
|
||||
/* .bTerminalID = DYNAMIC */
|
||||
.wTerminalType = cpu_to_le16(UAC_INPUT_TERMINAL_UNDEFINED),
|
||||
.bAssocTerminal = 0,
|
||||
.bCSourceID = USB_IN_CLK_ID,
|
||||
/* .bCSourceID = DYNAMIC */
|
||||
.iChannelNames = 0,
|
||||
.bmControls = cpu_to_le16(CONTROL_RDWR << COPY_CTRL),
|
||||
};
|
||||
@@ -187,11 +186,11 @@ static struct uac2_output_terminal_descriptor usb_in_ot_desc = {
|
||||
.bDescriptorType = USB_DT_CS_INTERFACE,
|
||||
|
||||
.bDescriptorSubtype = UAC_OUTPUT_TERMINAL,
|
||||
.bTerminalID = USB_IN_OT_ID,
|
||||
/* .bTerminalID = DYNAMIC */
|
||||
.wTerminalType = cpu_to_le16(UAC_TERMINAL_STREAMING),
|
||||
.bAssocTerminal = 0,
|
||||
.bSourceID = IO_IN_IT_ID,
|
||||
.bCSourceID = USB_IN_CLK_ID,
|
||||
/* .bSourceID = DYNAMIC */
|
||||
/* .bCSourceID = DYNAMIC */
|
||||
.bmControls = cpu_to_le16(CONTROL_RDWR << COPY_CTRL),
|
||||
};
|
||||
|
||||
@@ -201,11 +200,11 @@ static struct uac2_output_terminal_descriptor io_out_ot_desc = {
|
||||
.bDescriptorType = USB_DT_CS_INTERFACE,
|
||||
|
||||
.bDescriptorSubtype = UAC_OUTPUT_TERMINAL,
|
||||
.bTerminalID = IO_OUT_OT_ID,
|
||||
/* .bTerminalID = DYNAMIC */
|
||||
.wTerminalType = cpu_to_le16(UAC_OUTPUT_TERMINAL_UNDEFINED),
|
||||
.bAssocTerminal = 0,
|
||||
.bSourceID = USB_OUT_IT_ID,
|
||||
.bCSourceID = USB_OUT_CLK_ID,
|
||||
/* .bSourceID = DYNAMIC */
|
||||
/* .bCSourceID = DYNAMIC */
|
||||
.bmControls = cpu_to_le16(CONTROL_RDWR << COPY_CTRL),
|
||||
};
|
||||
|
||||
@@ -253,7 +252,7 @@ static struct uac2_as_header_descriptor as_out_hdr_desc = {
|
||||
.bDescriptorType = USB_DT_CS_INTERFACE,
|
||||
|
||||
.bDescriptorSubtype = UAC_AS_GENERAL,
|
||||
.bTerminalLink = USB_OUT_IT_ID,
|
||||
/* .bTerminalLink = DYNAMIC */
|
||||
.bmControls = 0,
|
||||
.bFormatType = UAC_FORMAT_TYPE_I,
|
||||
.bmFormats = cpu_to_le32(UAC_FORMAT_TYPE_I_PCM),
|
||||
@@ -330,7 +329,7 @@ static struct uac2_as_header_descriptor as_in_hdr_desc = {
|
||||
.bDescriptorType = USB_DT_CS_INTERFACE,
|
||||
|
||||
.bDescriptorSubtype = UAC_AS_GENERAL,
|
||||
.bTerminalLink = USB_IN_OT_ID,
|
||||
/* .bTerminalLink = DYNAMIC */
|
||||
.bmControls = 0,
|
||||
.bFormatType = UAC_FORMAT_TYPE_I,
|
||||
.bmFormats = cpu_to_le32(UAC_FORMAT_TYPE_I_PCM),
|
||||
@@ -471,6 +470,125 @@ static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
|
||||
le16_to_cpu(ep_desc->wMaxPacketSize)));
|
||||
}
|
||||
|
||||
/* Use macro to overcome line length limitation */
|
||||
#define USBDHDR(p) (struct usb_descriptor_header *)(p)
|
||||
|
||||
static void setup_descriptor(struct f_uac2_opts *opts)
|
||||
{
|
||||
/* patch descriptors */
|
||||
int i = 1; /* ID's start with 1 */
|
||||
|
||||
if (EPOUT_EN(opts))
|
||||
usb_out_it_desc.bTerminalID = i++;
|
||||
if (EPIN_EN(opts))
|
||||
io_in_it_desc.bTerminalID = i++;
|
||||
if (EPOUT_EN(opts))
|
||||
io_out_ot_desc.bTerminalID = i++;
|
||||
if (EPIN_EN(opts))
|
||||
usb_in_ot_desc.bTerminalID = i++;
|
||||
if (EPOUT_EN(opts))
|
||||
out_clk_src_desc.bClockID = i++;
|
||||
if (EPIN_EN(opts))
|
||||
in_clk_src_desc.bClockID = i++;
|
||||
|
||||
usb_out_it_desc.bCSourceID = out_clk_src_desc.bClockID;
|
||||
usb_in_ot_desc.bSourceID = io_in_it_desc.bTerminalID;
|
||||
usb_in_ot_desc.bCSourceID = in_clk_src_desc.bClockID;
|
||||
io_in_it_desc.bCSourceID = in_clk_src_desc.bClockID;
|
||||
io_out_ot_desc.bCSourceID = out_clk_src_desc.bClockID;
|
||||
io_out_ot_desc.bSourceID = usb_out_it_desc.bTerminalID;
|
||||
as_out_hdr_desc.bTerminalLink = usb_out_it_desc.bTerminalID;
|
||||
as_in_hdr_desc.bTerminalLink = usb_in_ot_desc.bTerminalID;
|
||||
|
||||
iad_desc.bInterfaceCount = 1;
|
||||
ac_hdr_desc.wTotalLength = 0;
|
||||
|
||||
if (EPIN_EN(opts)) {
|
||||
u16 len = le16_to_cpu(ac_hdr_desc.wTotalLength);
|
||||
|
||||
len += sizeof(in_clk_src_desc);
|
||||
len += sizeof(usb_in_ot_desc);
|
||||
len += sizeof(io_in_it_desc);
|
||||
ac_hdr_desc.wTotalLength = cpu_to_le16(len);
|
||||
iad_desc.bInterfaceCount++;
|
||||
}
|
||||
if (EPOUT_EN(opts)) {
|
||||
u16 len = le16_to_cpu(ac_hdr_desc.wTotalLength);
|
||||
|
||||
len += sizeof(out_clk_src_desc);
|
||||
len += sizeof(usb_out_it_desc);
|
||||
len += sizeof(io_out_ot_desc);
|
||||
ac_hdr_desc.wTotalLength = cpu_to_le16(len);
|
||||
iad_desc.bInterfaceCount++;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
fs_audio_desc[i++] = USBDHDR(&iad_desc);
|
||||
fs_audio_desc[i++] = USBDHDR(&std_ac_if_desc);
|
||||
fs_audio_desc[i++] = USBDHDR(&ac_hdr_desc);
|
||||
if (EPIN_EN(opts))
|
||||
fs_audio_desc[i++] = USBDHDR(&in_clk_src_desc);
|
||||
if (EPOUT_EN(opts)) {
|
||||
fs_audio_desc[i++] = USBDHDR(&out_clk_src_desc);
|
||||
fs_audio_desc[i++] = USBDHDR(&usb_out_it_desc);
|
||||
}
|
||||
if (EPIN_EN(opts)) {
|
||||
fs_audio_desc[i++] = USBDHDR(&io_in_it_desc);
|
||||
fs_audio_desc[i++] = USBDHDR(&usb_in_ot_desc);
|
||||
}
|
||||
if (EPOUT_EN(opts)) {
|
||||
fs_audio_desc[i++] = USBDHDR(&io_out_ot_desc);
|
||||
fs_audio_desc[i++] = USBDHDR(&std_as_out_if0_desc);
|
||||
fs_audio_desc[i++] = USBDHDR(&std_as_out_if1_desc);
|
||||
fs_audio_desc[i++] = USBDHDR(&as_out_hdr_desc);
|
||||
fs_audio_desc[i++] = USBDHDR(&as_out_fmt1_desc);
|
||||
fs_audio_desc[i++] = USBDHDR(&fs_epout_desc);
|
||||
fs_audio_desc[i++] = USBDHDR(&as_iso_out_desc);
|
||||
}
|
||||
if (EPIN_EN(opts)) {
|
||||
fs_audio_desc[i++] = USBDHDR(&std_as_in_if0_desc);
|
||||
fs_audio_desc[i++] = USBDHDR(&std_as_in_if1_desc);
|
||||
fs_audio_desc[i++] = USBDHDR(&as_in_hdr_desc);
|
||||
fs_audio_desc[i++] = USBDHDR(&as_in_fmt1_desc);
|
||||
fs_audio_desc[i++] = USBDHDR(&fs_epin_desc);
|
||||
fs_audio_desc[i++] = USBDHDR(&as_iso_in_desc);
|
||||
}
|
||||
fs_audio_desc[i] = NULL;
|
||||
|
||||
i = 0;
|
||||
hs_audio_desc[i++] = USBDHDR(&iad_desc);
|
||||
hs_audio_desc[i++] = USBDHDR(&std_ac_if_desc);
|
||||
hs_audio_desc[i++] = USBDHDR(&ac_hdr_desc);
|
||||
if (EPIN_EN(opts))
|
||||
hs_audio_desc[i++] = USBDHDR(&in_clk_src_desc);
|
||||
if (EPOUT_EN(opts)) {
|
||||
hs_audio_desc[i++] = USBDHDR(&out_clk_src_desc);
|
||||
hs_audio_desc[i++] = USBDHDR(&usb_out_it_desc);
|
||||
}
|
||||
if (EPIN_EN(opts)) {
|
||||
hs_audio_desc[i++] = USBDHDR(&io_in_it_desc);
|
||||
hs_audio_desc[i++] = USBDHDR(&usb_in_ot_desc);
|
||||
}
|
||||
if (EPOUT_EN(opts)) {
|
||||
hs_audio_desc[i++] = USBDHDR(&io_out_ot_desc);
|
||||
hs_audio_desc[i++] = USBDHDR(&std_as_out_if0_desc);
|
||||
hs_audio_desc[i++] = USBDHDR(&std_as_out_if1_desc);
|
||||
hs_audio_desc[i++] = USBDHDR(&as_out_hdr_desc);
|
||||
hs_audio_desc[i++] = USBDHDR(&as_out_fmt1_desc);
|
||||
hs_audio_desc[i++] = USBDHDR(&hs_epout_desc);
|
||||
hs_audio_desc[i++] = USBDHDR(&as_iso_out_desc);
|
||||
}
|
||||
if (EPIN_EN(opts)) {
|
||||
hs_audio_desc[i++] = USBDHDR(&std_as_in_if0_desc);
|
||||
hs_audio_desc[i++] = USBDHDR(&std_as_in_if1_desc);
|
||||
hs_audio_desc[i++] = USBDHDR(&as_in_hdr_desc);
|
||||
hs_audio_desc[i++] = USBDHDR(&as_in_fmt1_desc);
|
||||
hs_audio_desc[i++] = USBDHDR(&hs_epin_desc);
|
||||
hs_audio_desc[i++] = USBDHDR(&as_iso_in_desc);
|
||||
}
|
||||
hs_audio_desc[i] = NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
|
||||
{
|
||||
@@ -530,25 +648,29 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
|
||||
uac2->ac_intf = ret;
|
||||
uac2->ac_alt = 0;
|
||||
|
||||
ret = usb_interface_id(cfg, fn);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
|
||||
return ret;
|
||||
if (EPOUT_EN(uac2_opts)) {
|
||||
ret = usb_interface_id(cfg, fn);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
|
||||
return ret;
|
||||
}
|
||||
std_as_out_if0_desc.bInterfaceNumber = ret;
|
||||
std_as_out_if1_desc.bInterfaceNumber = ret;
|
||||
uac2->as_out_intf = ret;
|
||||
uac2->as_out_alt = 0;
|
||||
}
|
||||
std_as_out_if0_desc.bInterfaceNumber = ret;
|
||||
std_as_out_if1_desc.bInterfaceNumber = ret;
|
||||
uac2->as_out_intf = ret;
|
||||
uac2->as_out_alt = 0;
|
||||
|
||||
ret = usb_interface_id(cfg, fn);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
|
||||
return ret;
|
||||
if (EPIN_EN(uac2_opts)) {
|
||||
ret = usb_interface_id(cfg, fn);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
|
||||
return ret;
|
||||
}
|
||||
std_as_in_if0_desc.bInterfaceNumber = ret;
|
||||
std_as_in_if1_desc.bInterfaceNumber = ret;
|
||||
uac2->as_in_intf = ret;
|
||||
uac2->as_in_alt = 0;
|
||||
}
|
||||
std_as_in_if0_desc.bInterfaceNumber = ret;
|
||||
std_as_in_if1_desc.bInterfaceNumber = ret;
|
||||
uac2->as_in_intf = ret;
|
||||
uac2->as_in_alt = 0;
|
||||
|
||||
/* Calculate wMaxPacketSize according to audio bandwidth */
|
||||
set_ep_max_packet_size(uac2_opts, &fs_epin_desc, 1000, true);
|
||||
@@ -556,16 +678,20 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
|
||||
set_ep_max_packet_size(uac2_opts, &hs_epin_desc, 8000, true);
|
||||
set_ep_max_packet_size(uac2_opts, &hs_epout_desc, 8000, false);
|
||||
|
||||
agdev->out_ep = usb_ep_autoconfig(gadget, &fs_epout_desc);
|
||||
if (!agdev->out_ep) {
|
||||
dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
|
||||
return -ENODEV;
|
||||
if (EPOUT_EN(uac2_opts)) {
|
||||
agdev->out_ep = usb_ep_autoconfig(gadget, &fs_epout_desc);
|
||||
if (!agdev->out_ep) {
|
||||
dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
|
||||
return -ENODEV;
|
||||
}
|
||||
}
|
||||
|
||||
agdev->in_ep = usb_ep_autoconfig(gadget, &fs_epin_desc);
|
||||
if (!agdev->in_ep) {
|
||||
dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
|
||||
return -ENODEV;
|
||||
if (EPIN_EN(uac2_opts)) {
|
||||
agdev->in_ep = usb_ep_autoconfig(gadget, &fs_epin_desc);
|
||||
if (!agdev->in_ep) {
|
||||
dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
|
||||
return -ENODEV;
|
||||
}
|
||||
}
|
||||
|
||||
agdev->in_ep_maxpsize = max_t(u16,
|
||||
@@ -578,6 +704,8 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
|
||||
hs_epout_desc.bEndpointAddress = fs_epout_desc.bEndpointAddress;
|
||||
hs_epin_desc.bEndpointAddress = fs_epin_desc.bEndpointAddress;
|
||||
|
||||
setup_descriptor(uac2_opts);
|
||||
|
||||
ret = usb_assign_descriptors(fn, fs_audio_desc, hs_audio_desc, NULL,
|
||||
NULL);
|
||||
if (ret)
|
||||
|
@@ -197,12 +197,6 @@ static const struct usb_descriptor_header * const uvc_ss_streaming[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
void uvc_set_trace_param(unsigned int trace)
|
||||
{
|
||||
uvc_gadget_trace_param = trace;
|
||||
}
|
||||
EXPORT_SYMBOL(uvc_set_trace_param);
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* Control requests
|
||||
*/
|
||||
@@ -232,13 +226,8 @@ uvc_function_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
|
||||
struct v4l2_event v4l2_event;
|
||||
struct uvc_event *uvc_event = (void *)&v4l2_event.u.data;
|
||||
|
||||
/* printk(KERN_INFO "setup request %02x %02x value %04x index %04x %04x\n",
|
||||
* ctrl->bRequestType, ctrl->bRequest, le16_to_cpu(ctrl->wValue),
|
||||
* le16_to_cpu(ctrl->wIndex), le16_to_cpu(ctrl->wLength));
|
||||
*/
|
||||
|
||||
if ((ctrl->bRequestType & USB_TYPE_MASK) != USB_TYPE_CLASS) {
|
||||
INFO(f->config->cdev, "invalid request type\n");
|
||||
uvcg_info(f, "invalid request type\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -272,7 +261,7 @@ uvc_function_get_alt(struct usb_function *f, unsigned interface)
|
||||
{
|
||||
struct uvc_device *uvc = to_uvc(f);
|
||||
|
||||
INFO(f->config->cdev, "uvc_function_get_alt(%u)\n", interface);
|
||||
uvcg_info(f, "%s(%u)\n", __func__, interface);
|
||||
|
||||
if (interface == uvc->control_intf)
|
||||
return 0;
|
||||
@@ -291,13 +280,13 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
|
||||
struct uvc_event *uvc_event = (void *)&v4l2_event.u.data;
|
||||
int ret;
|
||||
|
||||
INFO(cdev, "uvc_function_set_alt(%u, %u)\n", interface, alt);
|
||||
uvcg_info(f, "%s(%u, %u)\n", __func__, interface, alt);
|
||||
|
||||
if (interface == uvc->control_intf) {
|
||||
if (alt)
|
||||
return -EINVAL;
|
||||
|
||||
INFO(cdev, "reset UVC Control\n");
|
||||
uvcg_info(f, "reset UVC Control\n");
|
||||
usb_ep_disable(uvc->control_ep);
|
||||
|
||||
if (!uvc->control_ep->desc)
|
||||
@@ -348,7 +337,7 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
|
||||
if (!uvc->video.ep)
|
||||
return -EINVAL;
|
||||
|
||||
INFO(cdev, "reset UVC\n");
|
||||
uvcg_info(f, "reset UVC\n");
|
||||
usb_ep_disable(uvc->video.ep);
|
||||
|
||||
ret = config_ep_by_speed(f->config->cdev->gadget,
|
||||
@@ -373,7 +362,7 @@ uvc_function_disable(struct usb_function *f)
|
||||
struct uvc_device *uvc = to_uvc(f);
|
||||
struct v4l2_event v4l2_event;
|
||||
|
||||
INFO(f->config->cdev, "uvc_function_disable\n");
|
||||
uvcg_info(f, "%s()\n", __func__);
|
||||
|
||||
memset(&v4l2_event, 0, sizeof(v4l2_event));
|
||||
v4l2_event.type = UVC_EVENT_DISCONNECT;
|
||||
@@ -392,21 +381,19 @@ uvc_function_disable(struct usb_function *f)
|
||||
void
|
||||
uvc_function_connect(struct uvc_device *uvc)
|
||||
{
|
||||
struct usb_composite_dev *cdev = uvc->func.config->cdev;
|
||||
int ret;
|
||||
|
||||
if ((ret = usb_function_activate(&uvc->func)) < 0)
|
||||
INFO(cdev, "UVC connect failed with %d\n", ret);
|
||||
uvcg_info(&uvc->func, "UVC connect failed with %d\n", ret);
|
||||
}
|
||||
|
||||
void
|
||||
uvc_function_disconnect(struct uvc_device *uvc)
|
||||
{
|
||||
struct usb_composite_dev *cdev = uvc->func.config->cdev;
|
||||
int ret;
|
||||
|
||||
if ((ret = usb_function_deactivate(&uvc->func)) < 0)
|
||||
INFO(cdev, "UVC disconnect failed with %d\n", ret);
|
||||
uvcg_info(&uvc->func, "UVC disconnect failed with %d\n", ret);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
@@ -605,7 +592,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
struct f_uvc_opts *opts;
|
||||
int ret = -EINVAL;
|
||||
|
||||
INFO(cdev, "uvc_function_bind\n");
|
||||
uvcg_info(f, "%s()\n", __func__);
|
||||
|
||||
opts = fi_to_f_uvc_opts(f->fi);
|
||||
/* Sanity check the streaming endpoint module parameters.
|
||||
@@ -618,8 +605,8 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
if (opts->streaming_maxburst &&
|
||||
(opts->streaming_maxpacket % 1024) != 0) {
|
||||
opts->streaming_maxpacket = roundup(opts->streaming_maxpacket, 1024);
|
||||
INFO(cdev, "overriding streaming_maxpacket to %d\n",
|
||||
opts->streaming_maxpacket);
|
||||
uvcg_info(f, "overriding streaming_maxpacket to %d\n",
|
||||
opts->streaming_maxpacket);
|
||||
}
|
||||
|
||||
/* Fill in the FS/HS/SS Video Streaming specific descriptors from the
|
||||
@@ -658,7 +645,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
/* Allocate endpoints. */
|
||||
ep = usb_ep_autoconfig(cdev->gadget, &uvc_control_ep);
|
||||
if (!ep) {
|
||||
INFO(cdev, "Unable to allocate control EP\n");
|
||||
uvcg_info(f, "Unable to allocate control EP\n");
|
||||
goto error;
|
||||
}
|
||||
uvc->control_ep = ep;
|
||||
@@ -672,7 +659,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
ep = usb_ep_autoconfig(cdev->gadget, &uvc_fs_streaming_ep);
|
||||
|
||||
if (!ep) {
|
||||
INFO(cdev, "Unable to allocate streaming EP\n");
|
||||
uvcg_info(f, "Unable to allocate streaming EP\n");
|
||||
goto error;
|
||||
}
|
||||
uvc->video.ep = ep;
|
||||
@@ -699,12 +686,14 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
uvc_iad.bFirstInterface = ret;
|
||||
uvc_control_intf.bInterfaceNumber = ret;
|
||||
uvc->control_intf = ret;
|
||||
opts->control_interface = ret;
|
||||
|
||||
if ((ret = usb_interface_id(c, f)) < 0)
|
||||
goto error;
|
||||
uvc_streaming_intf_alt0.bInterfaceNumber = ret;
|
||||
uvc_streaming_intf_alt1.bInterfaceNumber = ret;
|
||||
uvc->streaming_intf = ret;
|
||||
opts->streaming_interface = ret;
|
||||
|
||||
/* Copy descriptors */
|
||||
f->fs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL);
|
||||
@@ -743,19 +732,19 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
uvc->control_req->context = uvc;
|
||||
|
||||
if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) {
|
||||
printk(KERN_INFO "v4l2_device_register failed\n");
|
||||
uvcg_err(f, "failed to register V4L2 device\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Initialise video. */
|
||||
ret = uvcg_video_init(&uvc->video);
|
||||
ret = uvcg_video_init(&uvc->video, uvc);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
|
||||
/* Register a V4L2 device. */
|
||||
ret = uvc_register_video(uvc);
|
||||
if (ret < 0) {
|
||||
printk(KERN_INFO "Unable to register video device\n");
|
||||
uvcg_err(f, "failed to register video device\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -792,6 +781,7 @@ static struct usb_function_instance *uvc_alloc_inst(void)
|
||||
struct uvc_output_terminal_descriptor *od;
|
||||
struct uvc_color_matching_descriptor *md;
|
||||
struct uvc_descriptor_header **ctl_cls;
|
||||
int ret;
|
||||
|
||||
opts = kzalloc(sizeof(*opts), GFP_KERNEL);
|
||||
if (!opts)
|
||||
@@ -868,7 +858,12 @@ static struct usb_function_instance *uvc_alloc_inst(void)
|
||||
opts->streaming_interval = 1;
|
||||
opts->streaming_maxpacket = 1024;
|
||||
|
||||
uvcg_attach_configfs(opts);
|
||||
ret = uvcg_attach_configfs(opts);
|
||||
if (ret < 0) {
|
||||
kfree(opts);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
return &opts->func_inst;
|
||||
}
|
||||
|
||||
@@ -886,7 +881,7 @@ static void uvc_unbind(struct usb_configuration *c, struct usb_function *f)
|
||||
struct usb_composite_dev *cdev = c->cdev;
|
||||
struct uvc_device *uvc = to_uvc(f);
|
||||
|
||||
INFO(cdev, "%s\n", __func__);
|
||||
uvcg_info(f, "%s\n", __func__);
|
||||
|
||||
device_remove_file(&uvc->vdev.dev, &dev_attr_function_name);
|
||||
video_unregister_device(&uvc->vdev);
|
||||
|
@@ -25,6 +25,9 @@ struct f_uvc_opts {
|
||||
unsigned int streaming_maxpacket;
|
||||
unsigned int streaming_maxburst;
|
||||
|
||||
unsigned int control_interface;
|
||||
unsigned int streaming_interface;
|
||||
|
||||
/*
|
||||
* Control descriptors array pointers for full-/high-speed and
|
||||
* super-speed. They point by default to the uvc_fs_control_cls and
|
||||
|
@@ -24,6 +24,7 @@
|
||||
struct usb_ep;
|
||||
struct usb_request;
|
||||
struct uvc_descriptor_header;
|
||||
struct uvc_device;
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* Debugging, printing and logging
|
||||
@@ -51,14 +52,12 @@ extern unsigned int uvc_gadget_trace_param;
|
||||
printk(KERN_DEBUG "uvcvideo: " msg); \
|
||||
} while (0)
|
||||
|
||||
#define uvc_warn_once(dev, warn, msg...) \
|
||||
do { \
|
||||
if (!test_and_set_bit(warn, &dev->warnings)) \
|
||||
printk(KERN_INFO "uvcvideo: " msg); \
|
||||
} while (0)
|
||||
|
||||
#define uvc_printk(level, msg...) \
|
||||
printk(level "uvcvideo: " msg)
|
||||
#define uvcg_dbg(f, fmt, args...) \
|
||||
dev_dbg(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args)
|
||||
#define uvcg_info(f, fmt, args...) \
|
||||
dev_info(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args)
|
||||
#define uvcg_err(f, fmt, args...) \
|
||||
dev_err(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args)
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* Driver specific constants
|
||||
@@ -73,6 +72,7 @@ extern unsigned int uvc_gadget_trace_param;
|
||||
*/
|
||||
|
||||
struct uvc_video {
|
||||
struct uvc_device *uvc;
|
||||
struct usb_ep *ep;
|
||||
|
||||
/* Frame parameters */
|
||||
|
File diff ditekan karena terlalu besar
Load Diff
@@ -115,8 +115,8 @@ uvc_v4l2_set_format(struct file *file, void *fh, struct v4l2_format *fmt)
|
||||
}
|
||||
|
||||
if (i == ARRAY_SIZE(uvc_formats)) {
|
||||
printk(KERN_INFO "Unsupported format 0x%08x.\n",
|
||||
fmt->fmt.pix.pixelformat);
|
||||
uvcg_info(&uvc->func, "Unsupported format 0x%08x.\n",
|
||||
fmt->fmt.pix.pixelformat);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@@ -125,6 +125,23 @@ uvc_video_encode_isoc(struct usb_request *req, struct uvc_video *video,
|
||||
* Request handling
|
||||
*/
|
||||
|
||||
static int uvcg_video_ep_queue(struct uvc_video *video, struct usb_request *req)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = usb_ep_queue(video->ep, req, GFP_ATOMIC);
|
||||
if (ret < 0) {
|
||||
uvcg_err(&video->uvc->func, "Failed to queue request (%d).\n",
|
||||
ret);
|
||||
|
||||
/* Isochronous endpoints can't be halted. */
|
||||
if (usb_endpoint_xfer_bulk(video->ep->desc))
|
||||
usb_ep_set_halt(video->ep);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* I somehow feel that synchronisation won't be easy to achieve here. We have
|
||||
* three events that control USB requests submission:
|
||||
@@ -169,13 +186,14 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req)
|
||||
break;
|
||||
|
||||
case -ESHUTDOWN: /* disconnect from host. */
|
||||
printk(KERN_DEBUG "VS request cancelled.\n");
|
||||
uvcg_dbg(&video->uvc->func, "VS request cancelled.\n");
|
||||
uvcg_queue_cancel(queue, 1);
|
||||
goto requeue;
|
||||
|
||||
default:
|
||||
printk(KERN_INFO "VS request completed with status %d.\n",
|
||||
req->status);
|
||||
uvcg_info(&video->uvc->func,
|
||||
"VS request completed with status %d.\n",
|
||||
req->status);
|
||||
uvcg_queue_cancel(queue, 0);
|
||||
goto requeue;
|
||||
}
|
||||
@@ -189,14 +207,13 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req)
|
||||
|
||||
video->encode(req, video, buf);
|
||||
|
||||
if ((ret = usb_ep_queue(ep, req, GFP_ATOMIC)) < 0) {
|
||||
printk(KERN_INFO "Failed to queue request (%d).\n", ret);
|
||||
usb_ep_set_halt(ep);
|
||||
spin_unlock_irqrestore(&video->queue.irqlock, flags);
|
||||
ret = uvcg_video_ep_queue(video, req);
|
||||
spin_unlock_irqrestore(&video->queue.irqlock, flags);
|
||||
|
||||
if (ret < 0) {
|
||||
uvcg_queue_cancel(queue, 0);
|
||||
goto requeue;
|
||||
}
|
||||
spin_unlock_irqrestore(&video->queue.irqlock, flags);
|
||||
|
||||
return;
|
||||
|
||||
@@ -316,15 +333,13 @@ int uvcg_video_pump(struct uvc_video *video)
|
||||
video->encode(req, video, buf);
|
||||
|
||||
/* Queue the USB request */
|
||||
ret = usb_ep_queue(video->ep, req, GFP_ATOMIC);
|
||||
ret = uvcg_video_ep_queue(video, req);
|
||||
spin_unlock_irqrestore(&queue->irqlock, flags);
|
||||
|
||||
if (ret < 0) {
|
||||
printk(KERN_INFO "Failed to queue request (%d)\n", ret);
|
||||
usb_ep_set_halt(video->ep);
|
||||
spin_unlock_irqrestore(&queue->irqlock, flags);
|
||||
uvcg_queue_cancel(queue, 0);
|
||||
break;
|
||||
}
|
||||
spin_unlock_irqrestore(&queue->irqlock, flags);
|
||||
}
|
||||
|
||||
spin_lock_irqsave(&video->req_lock, flags);
|
||||
@@ -342,8 +357,8 @@ int uvcg_video_enable(struct uvc_video *video, int enable)
|
||||
int ret;
|
||||
|
||||
if (video->ep == NULL) {
|
||||
printk(KERN_INFO "Video enable failed, device is "
|
||||
"uninitialized.\n");
|
||||
uvcg_info(&video->uvc->func,
|
||||
"Video enable failed, device is uninitialized.\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
@@ -375,11 +390,12 @@ int uvcg_video_enable(struct uvc_video *video, int enable)
|
||||
/*
|
||||
* Initialize the UVC video stream.
|
||||
*/
|
||||
int uvcg_video_init(struct uvc_video *video)
|
||||
int uvcg_video_init(struct uvc_video *video, struct uvc_device *uvc)
|
||||
{
|
||||
INIT_LIST_HEAD(&video->req_free);
|
||||
spin_lock_init(&video->req_lock);
|
||||
|
||||
video->uvc = uvc;
|
||||
video->fcc = V4L2_PIX_FMT_YUYV;
|
||||
video->bpp = 16;
|
||||
video->width = 320;
|
||||
|
@@ -18,6 +18,6 @@ int uvcg_video_pump(struct uvc_video *video);
|
||||
|
||||
int uvcg_video_enable(struct uvc_video *video, int enable);
|
||||
|
||||
int uvcg_video_init(struct uvc_video *video);
|
||||
int uvcg_video_init(struct uvc_video *video, struct uvc_device *uvc);
|
||||
|
||||
#endif /* __UVC_VIDEO_H__ */
|
||||
|
Reference in New Issue
Block a user