-/* $OpenBSD: uvideo.c,v 1.83 2008/08/24 11:05:02 mglocker Exp $ */
+/* $OpenBSD: uvideo.c,v 1.84 2008/08/24 11:43:00 mglocker Exp $ */
/*
* Copyright (c) 2008 Robert Nagy <robert@openbsd.org>
return;
/* set default video stream interface */
- error = usbd_set_interface(sc->sc_vs_curr->ifaceh, 0);
+ error = usbd_set_interface(sc->sc_vs_cur->ifaceh, 0);
if (error != USBD_NORMAL_COMPLETION)
return;
}
/* XXX for now always use the first video stream */
- sc->sc_vs_curr = &sc->sc_vs_coll[0];
+ sc->sc_vs_cur = &sc->sc_vs_coll[0];
return (USBD_NORMAL_COMPLETION);
}
if (desc->bDescriptorType != UDESC_INTERFACE)
goto next;
id = (usb_interface_descriptor_t *)(uint8_t *)desc;
- if (id->bInterfaceNumber != sc->sc_vs_curr->iface)
+ if (id->bInterfaceNumber != sc->sc_vs_cur->iface)
goto next;
if (id->bNumEndpoints == 0)
goto next;
/* save endpoint with requested bandwidth */
if (UGETW(ed->wMaxPacketSize) >= max_packet_size) {
- sc->sc_vs_curr->endpoint = ed->bEndpointAddress;
- sc->sc_vs_curr->curalt = id->bAlternateSetting;
- sc->sc_vs_curr->max_packet_size = max_packet_size;
+ sc->sc_vs_cur->endpoint = ed->bEndpointAddress;
+ sc->sc_vs_cur->curalt = id->bAlternateSetting;
+ sc->sc_vs_cur->max_packet_size = max_packet_size;
DPRINTF(1, "%s: set alternate iface to ", DEVNAME(sc));
DPRINTF(1, "bAlternateSetting=0x%02x\n",
id->bAlternateSetting);
uvideo_vs_set_probe(struct uvideo_softc *sc, uint8_t *probe_data)
{
usb_device_request_t req;
- usbd_status err;
+ usbd_status error;
uint16_t tmp;
struct usb_video_probe_commit *pc;
tmp = VS_PROBE_CONTROL;
tmp = tmp << 8;
USETW(req.wValue, tmp);
- USETW(req.wIndex, sc->sc_vs_curr->iface);
+ USETW(req.wIndex, sc->sc_vs_cur->iface);
USETW(req.wLength, 26);
pc = (struct usb_video_probe_commit *)probe_data;
- err = usbd_do_request(sc->sc_udev, &req, probe_data);
- if (err) {
+ error = usbd_do_request(sc->sc_udev, &req, probe_data);
+ if (error) {
printf("%s: could not SET probe request: %s\n",
- DEVNAME(sc), usbd_errstr(err));
+ DEVNAME(sc), usbd_errstr(error));
return (USBD_INVAL);
}
DPRINTF(1, "%s: SET probe request successfully\n", DEVNAME(sc));
uint8_t request)
{
usb_device_request_t req;
- usbd_status err;
+ usbd_status error;
uint16_t tmp;
struct usb_video_probe_commit *pc;
tmp = VS_PROBE_CONTROL;
tmp = tmp << 8;
USETW(req.wValue, tmp);
- USETW(req.wIndex, sc->sc_vs_curr->iface);
+ USETW(req.wIndex, sc->sc_vs_cur->iface);
USETW(req.wLength, 26);
pc = (struct usb_video_probe_commit *)probe_data;
- err = usbd_do_request(sc->sc_udev, &req, probe_data);
- if (err) {
+ error = usbd_do_request(sc->sc_udev, &req, probe_data);
+ if (error) {
printf("%s: could not GET probe request: %s\n",
- DEVNAME(sc), usbd_errstr(err));
+ DEVNAME(sc), usbd_errstr(error));
return (USBD_INVAL);
}
DPRINTF(1, "%s: GET probe request successfully\n", DEVNAME(sc));
uvideo_vs_set_commit(struct uvideo_softc *sc, uint8_t *probe_data)
{
usb_device_request_t req;
- usbd_status err;
+ usbd_status error;
uint16_t tmp;
req.bmRequestType = UVIDEO_SET_IF;
tmp = VS_COMMIT_CONTROL;
tmp = tmp << 8;
USETW(req.wValue, tmp);
- USETW(req.wIndex, sc->sc_vs_curr->iface);
+ USETW(req.wIndex, sc->sc_vs_cur->iface);
USETW(req.wLength, 26);
- err = usbd_do_request(sc->sc_udev, &req, probe_data);
- if (err) {
+ error = usbd_do_request(sc->sc_udev, &req, probe_data);
+ if (error) {
printf("%s: could not SET commit request: %s\n",
- DEVNAME(sc), usbd_errstr(err));
+ DEVNAME(sc), usbd_errstr(error));
return (USBD_INVAL);
}
DPRINTF(1, "%s: SET commit request successfully\n", DEVNAME(sc));
DPRINTF(1, "%s: %s\n", DEVNAME(sc), __func__);
- sc->sc_vs_curr->sc = sc;
+ sc->sc_vs_cur->sc = sc;
- sc->sc_vs_curr->xfer = usbd_alloc_xfer(sc->sc_udev);
- if (sc->sc_vs_curr->xfer == NULL) {
+ sc->sc_vs_cur->xfer = usbd_alloc_xfer(sc->sc_udev);
+ if (sc->sc_vs_cur->xfer == NULL) {
printf("%s: could not allocate VS xfer!\n", DEVNAME(sc));
return (USBD_NOMEM);
}
- size = sc->sc_vs_curr->max_packet_size * sc->sc_nframes;
+ size = sc->sc_vs_cur->max_packet_size * sc->sc_nframes;
- sc->sc_vs_curr->buf = usbd_alloc_buffer(sc->sc_vs_curr->xfer, size);
- if (sc->sc_vs_curr->buf == NULL) {
+ sc->sc_vs_cur->buf = usbd_alloc_buffer(sc->sc_vs_cur->xfer, size);
+ if (sc->sc_vs_cur->buf == NULL) {
printf("%s: could not allocate VS buffer!\n", DEVNAME(sc));
return (USBD_NOMEM);
}
{
DPRINTF(1, "%s: %s\n", DEVNAME(sc), __func__);
- if (sc->sc_vs_curr->buf != NULL) {
- usbd_free_buffer(sc->sc_vs_curr->xfer);
- sc->sc_vs_curr->buf = NULL;
+ if (sc->sc_vs_cur->buf != NULL) {
+ usbd_free_buffer(sc->sc_vs_cur->xfer);
+ sc->sc_vs_cur->buf = NULL;
}
- if (sc->sc_vs_curr->xfer != NULL) {
- usbd_free_xfer(sc->sc_vs_curr->xfer);
- sc->sc_vs_curr->xfer = NULL;
+ if (sc->sc_vs_cur->xfer != NULL) {
+ usbd_free_xfer(sc->sc_vs_cur->xfer);
+ sc->sc_vs_cur->xfer = NULL;
}
}
return (error);
}
- error = uvideo_vs_set_alt(sc, sc->sc_vs_curr->ifaceh,
+ error = uvideo_vs_set_alt(sc, sc->sc_vs_cur->ifaceh,
UGETDW(sc->sc_desc_probe.dwMaxPayloadTransferSize));
if (error != USBD_NORMAL_COMPLETION) {
printf("%s: could not set alternate interface!\n",
return (error);
}
- ed = usbd_interface2endpoint_descriptor(sc->sc_vs_curr->ifaceh, 0);
+ ed = usbd_interface2endpoint_descriptor(sc->sc_vs_cur->ifaceh, 0);
if (ed == NULL) {
printf("%s: no endpoint descriptor for VS iface\n",
DEVNAME(sc));
DPRINTF(1, "%s: open pipe for ", DEVNAME(sc));
DPRINTF(1, "bEndpointAddress=0x%02x (0x%02x), wMaxPacketSize=%d (%d)\n",
ed->bEndpointAddress,
- sc->sc_vs_curr->endpoint,
+ sc->sc_vs_cur->endpoint,
UGETW(ed->wMaxPacketSize),
- sc->sc_vs_curr->max_packet_size);
+ sc->sc_vs_cur->max_packet_size);
error = usbd_open_pipe(
- sc->sc_vs_curr->ifaceh,
- sc->sc_vs_curr->endpoint,
+ sc->sc_vs_cur->ifaceh,
+ sc->sc_vs_cur->endpoint,
USBD_EXCLUSIVE_USE,
- &sc->sc_vs_curr->pipeh);
+ &sc->sc_vs_cur->pipeh);
if (error != USBD_NORMAL_COMPLETION) {
printf("%s: could not open VS pipe: %s\n",
DEVNAME(sc), usbd_errstr(error));
if (strncmp(sc->sc_udev->bus->bdev.dv_xname, "ohci", 4) == 0) {
/* ohci workaround */
sc->sc_nframes = 6400 /
- sc->sc_vs_curr->max_packet_size;
+ sc->sc_vs_cur->max_packet_size;
} else {
sc->sc_nframes = UGETDW(sc->sc_desc_probe.dwMaxVideoFrameSize) /
- sc->sc_vs_curr->max_packet_size;
+ sc->sc_vs_cur->max_packet_size;
}
if (sc->sc_nframes > UVIDEO_NFRAMES_MAX)
sc->sc_nframes = UVIDEO_NFRAMES_MAX;
uvideo_vs_close(struct uvideo_softc *sc)
{
/* switch back to default interface (turns off cam LED) */
- (void)usbd_set_interface(sc->sc_vs_curr->ifaceh, 0);
+ (void)usbd_set_interface(sc->sc_vs_cur->ifaceh, 0);
- if (sc->sc_vs_curr->pipeh) {
- usbd_abort_pipe(sc->sc_vs_curr->pipeh);
- usbd_close_pipe(sc->sc_vs_curr->pipeh);
- sc->sc_vs_curr->pipeh = NULL;
+ if (sc->sc_vs_cur->pipeh) {
+ usbd_abort_pipe(sc->sc_vs_cur->pipeh);
+ usbd_close_pipe(sc->sc_vs_cur->pipeh);
+ sc->sc_vs_cur->pipeh = NULL;
}
}
return;
for (i = 0; i < sc->sc_nframes; i++)
- sc->sc_vs_curr->size[i] = sc->sc_vs_curr->max_packet_size;
+ sc->sc_vs_cur->size[i] = sc->sc_vs_cur->max_packet_size;
usbd_setup_isoc_xfer(
- sc->sc_vs_curr->xfer,
- sc->sc_vs_curr->pipeh,
- sc->sc_vs_curr,
- sc->sc_vs_curr->size,
+ sc->sc_vs_cur->xfer,
+ sc->sc_vs_cur->pipeh,
+ sc->sc_vs_cur,
+ sc->sc_vs_cur->size,
sc->sc_nframes,
USBD_NO_COPY | USBD_SHORT_XFER_OK,
uvideo_vs_cb);
- (void)usbd_transfer(sc->sc_vs_curr->xfer);
+ (void)usbd_transfer(sc->sc_vs_cur->xfer);
}
void