Lines Matching refs:dev
69 void hdpvr_delete(struct hdpvr_device *dev) in hdpvr_delete() argument
71 hdpvr_free_buffers(dev); in hdpvr_delete()
72 usb_put_dev(dev->udev); in hdpvr_delete()
117 static int device_authorization(struct hdpvr_device *dev) in device_authorization() argument
124 mutex_lock(&dev->usbc_mutex); in device_authorization()
125 ret = usb_control_msg(dev->udev, in device_authorization()
126 usb_rcvctrlpipe(dev->udev, 0), in device_authorization()
129 dev->usbc_buf, 46, in device_authorization()
132 v4l2_err(&dev->v4l2_dev, in device_authorization()
138 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in device_authorization()
140 ret, dev->usbc_buf); in device_authorization()
144 dev->fw_ver = dev->usbc_buf[1]; in device_authorization()
146 v4l2_info(&dev->v4l2_dev, "firmware version 0x%x dated %s\n", in device_authorization()
147 dev->fw_ver, &dev->usbc_buf[2]); in device_authorization()
149 if (dev->fw_ver > 0x15) { in device_authorization()
150 dev->options.brightness = 0x80; in device_authorization()
151 dev->options.contrast = 0x40; in device_authorization()
152 dev->options.hue = 0xf; in device_authorization()
153 dev->options.saturation = 0x40; in device_authorization()
154 dev->options.sharpness = 0x80; in device_authorization()
157 switch (dev->fw_ver) { in device_authorization()
159 dev->flags &= ~HDPVR_FLAG_AC3_CAP; in device_authorization()
165 dev->flags |= HDPVR_FLAG_AC3_CAP; in device_authorization()
168 v4l2_info(&dev->v4l2_dev, "untested firmware, the driver might" in device_authorization()
170 if (dev->fw_ver >= HDPVR_FIRMWARE_VERSION_AC3) in device_authorization()
171 dev->flags |= HDPVR_FLAG_AC3_CAP; in device_authorization()
173 dev->flags &= ~HDPVR_FLAG_AC3_CAP; in device_authorization()
176 response = dev->usbc_buf+38; in device_authorization()
178 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, "challenge: %8ph\n", in device_authorization()
183 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, " response: %8ph\n", in device_authorization()
188 ret = usb_control_msg(dev->udev, in device_authorization()
189 usb_sndctrlpipe(dev->udev, 0), in device_authorization()
194 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in device_authorization()
199 mutex_unlock(&dev->usbc_mutex); in device_authorization()
203 static int hdpvr_device_init(struct hdpvr_device *dev) in hdpvr_device_init() argument
208 if (device_authorization(dev)) in hdpvr_device_init()
212 hdpvr_set_options(dev); in hdpvr_device_init()
215 mutex_lock(&dev->usbc_mutex); in hdpvr_device_init()
216 buf = dev->usbc_buf; in hdpvr_device_init()
218 ret = usb_control_msg(dev->udev, in hdpvr_device_init()
219 usb_sndctrlpipe(dev->udev, 0), in hdpvr_device_init()
224 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in hdpvr_device_init()
226 mutex_unlock(&dev->usbc_mutex); in hdpvr_device_init()
229 mutex_lock(&dev->usbc_mutex); in hdpvr_device_init()
231 ret = usb_control_msg(dev->udev, in hdpvr_device_init()
232 usb_sndctrlpipe(dev->udev, 0), in hdpvr_device_init()
235 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in hdpvr_device_init()
240 ret = usb_control_msg(dev->udev, in hdpvr_device_init()
241 usb_sndctrlpipe(dev->udev, 0), in hdpvr_device_init()
244 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in hdpvr_device_init()
246 mutex_unlock(&dev->usbc_mutex); in hdpvr_device_init()
248 dev->status = STATUS_IDLE; in hdpvr_device_init()
273 struct hdpvr_device *dev; in hdpvr_probe() local
282 dev = kzalloc(sizeof(*dev), GFP_KERNEL); in hdpvr_probe()
283 if (!dev) { in hdpvr_probe()
284 dev_err(&interface->dev, "Out of memory\n"); in hdpvr_probe()
290 INIT_LIST_HEAD(&dev->free_buff_list); in hdpvr_probe()
291 INIT_LIST_HEAD(&dev->rec_buff_list); in hdpvr_probe()
294 if (v4l2_device_register(&interface->dev, &dev->v4l2_dev)) { in hdpvr_probe()
295 dev_err(&interface->dev, "v4l2_device_register failed\n"); in hdpvr_probe()
299 mutex_init(&dev->io_mutex); in hdpvr_probe()
300 mutex_init(&dev->i2c_mutex); in hdpvr_probe()
301 mutex_init(&dev->usbc_mutex); in hdpvr_probe()
302 dev->usbc_buf = kmalloc(64, GFP_KERNEL); in hdpvr_probe()
303 if (!dev->usbc_buf) { in hdpvr_probe()
304 v4l2_err(&dev->v4l2_dev, "Out of memory\n"); in hdpvr_probe()
308 init_waitqueue_head(&dev->wait_buffer); in hdpvr_probe()
309 init_waitqueue_head(&dev->wait_data); in hdpvr_probe()
311 dev->workqueue = create_singlethread_workqueue("hdpvr_buffer"); in hdpvr_probe()
312 if (!dev->workqueue) in hdpvr_probe()
315 dev->options = hdpvr_default_options; in hdpvr_probe()
318 dev->options.video_input = default_video_input; in hdpvr_probe()
321 dev->options.audio_input = default_audio_input; in hdpvr_probe()
323 dev->options.audio_codec = in hdpvr_probe()
327 dev->udev = usb_get_dev(interface_to_usbdev(interface)); in hdpvr_probe()
335 if (!dev->bulk_in_endpointAddr && in hdpvr_probe()
340 dev->bulk_in_size = buffer_size; in hdpvr_probe()
341 dev->bulk_in_endpointAddr = endpoint->bEndpointAddress; in hdpvr_probe()
345 if (!dev->bulk_in_endpointAddr) { in hdpvr_probe()
346 v4l2_err(&dev->v4l2_dev, "Could not find bulk-in endpoint\n"); in hdpvr_probe()
351 if (hdpvr_device_init(dev)) { in hdpvr_probe()
352 v4l2_err(&dev->v4l2_dev, "device init failed\n"); in hdpvr_probe()
356 mutex_lock(&dev->io_mutex); in hdpvr_probe()
357 if (hdpvr_alloc_buffers(dev, NUM_BUFFERS)) { in hdpvr_probe()
358 mutex_unlock(&dev->io_mutex); in hdpvr_probe()
359 v4l2_err(&dev->v4l2_dev, in hdpvr_probe()
363 mutex_unlock(&dev->io_mutex); in hdpvr_probe()
366 retval = hdpvr_register_i2c_adapter(dev); in hdpvr_probe()
368 v4l2_err(&dev->v4l2_dev, "i2c adapter register failed\n"); in hdpvr_probe()
372 client = hdpvr_register_ir_rx_i2c(dev); in hdpvr_probe()
374 v4l2_err(&dev->v4l2_dev, "i2c IR RX device register failed\n"); in hdpvr_probe()
379 client = hdpvr_register_ir_tx_i2c(dev); in hdpvr_probe()
381 v4l2_err(&dev->v4l2_dev, "i2c IR TX device register failed\n"); in hdpvr_probe()
387 retval = hdpvr_register_videodev(dev, &interface->dev, in hdpvr_probe()
390 v4l2_err(&dev->v4l2_dev, "registering videodev failed\n"); in hdpvr_probe()
395 v4l2_info(&dev->v4l2_dev, "device now attached to %s\n", in hdpvr_probe()
396 video_device_node_name(&dev->video_dev)); in hdpvr_probe()
401 i2c_del_adapter(&dev->i2c_adapter); in hdpvr_probe()
404 if (dev) { in hdpvr_probe()
406 if (dev->workqueue) in hdpvr_probe()
407 destroy_workqueue(dev->workqueue); in hdpvr_probe()
409 hdpvr_delete(dev); in hdpvr_probe()
416 struct hdpvr_device *dev = to_hdpvr_dev(usb_get_intfdata(interface)); in hdpvr_disconnect() local
418 v4l2_info(&dev->v4l2_dev, "device %s disconnected\n", in hdpvr_disconnect()
419 video_device_node_name(&dev->video_dev)); in hdpvr_disconnect()
421 mutex_lock(&dev->io_mutex); in hdpvr_disconnect()
422 dev->status = STATUS_DISCONNECTED; in hdpvr_disconnect()
423 wake_up_interruptible(&dev->wait_data); in hdpvr_disconnect()
424 wake_up_interruptible(&dev->wait_buffer); in hdpvr_disconnect()
425 mutex_unlock(&dev->io_mutex); in hdpvr_disconnect()
426 v4l2_device_disconnect(&dev->v4l2_dev); in hdpvr_disconnect()
428 flush_workqueue(dev->workqueue); in hdpvr_disconnect()
429 mutex_lock(&dev->io_mutex); in hdpvr_disconnect()
430 hdpvr_cancel_queue(dev); in hdpvr_disconnect()
431 mutex_unlock(&dev->io_mutex); in hdpvr_disconnect()
433 i2c_del_adapter(&dev->i2c_adapter); in hdpvr_disconnect()
435 video_unregister_device(&dev->video_dev); in hdpvr_disconnect()