• Home
  • Raw
  • Download

Lines Matching refs:radio

198 static int si470x_get_report(struct si470x_device *radio, void *buf, int size)  in si470x_get_report()  argument
203 retval = usb_control_msg(radio->usbdev, in si470x_get_report()
204 usb_rcvctrlpipe(radio->usbdev, 0), in si470x_get_report()
211 dev_warn(&radio->intf->dev, in si470x_get_report()
221 static int si470x_set_report(struct si470x_device *radio, void *buf, int size) in si470x_set_report() argument
226 retval = usb_control_msg(radio->usbdev, in si470x_set_report()
227 usb_sndctrlpipe(radio->usbdev, 0), in si470x_set_report()
234 dev_warn(&radio->intf->dev, in si470x_set_report()
244 static int si470x_get_register(struct si470x_device *radio, int regnr) in si470x_get_register() argument
248 radio->usb_buf[0] = REGISTER_REPORT(regnr); in si470x_get_register()
250 retval = si470x_get_report(radio, radio->usb_buf, REGISTER_REPORT_SIZE); in si470x_get_register()
253 radio->registers[regnr] = get_unaligned_be16(&radio->usb_buf[1]); in si470x_get_register()
262 static int si470x_set_register(struct si470x_device *radio, int regnr) in si470x_set_register() argument
266 radio->usb_buf[0] = REGISTER_REPORT(regnr); in si470x_set_register()
267 put_unaligned_be16(radio->registers[regnr], &radio->usb_buf[1]); in si470x_set_register()
269 retval = si470x_set_report(radio, radio->usb_buf, REGISTER_REPORT_SIZE); in si470x_set_register()
283 static int si470x_get_all_registers(struct si470x_device *radio) in si470x_get_all_registers() argument
288 radio->usb_buf[0] = ENTIRE_REPORT; in si470x_get_all_registers()
290 retval = si470x_get_report(radio, radio->usb_buf, ENTIRE_REPORT_SIZE); in si470x_get_all_registers()
294 radio->registers[regnr] = get_unaligned_be16( in si470x_get_all_registers()
295 &radio->usb_buf[regnr * RADIO_REGISTER_SIZE + 1]); in si470x_get_all_registers()
309 static int si470x_set_led_state(struct si470x_device *radio, in si470x_set_led_state() argument
314 radio->usb_buf[0] = LED_REPORT; in si470x_set_led_state()
315 radio->usb_buf[1] = LED_COMMAND; in si470x_set_led_state()
316 radio->usb_buf[2] = led_state; in si470x_set_led_state()
318 retval = si470x_set_report(radio, radio->usb_buf, LED_REPORT_SIZE); in si470x_set_led_state()
332 static int si470x_get_scratch_page_versions(struct si470x_device *radio) in si470x_get_scratch_page_versions() argument
336 radio->usb_buf[0] = SCRATCH_REPORT; in si470x_get_scratch_page_versions()
338 retval = si470x_get_report(radio, radio->usb_buf, SCRATCH_REPORT_SIZE); in si470x_get_scratch_page_versions()
341 dev_warn(&radio->intf->dev, "si470x_get_scratch: si470x_get_report returned %d\n", in si470x_get_scratch_page_versions()
344 radio->software_version = radio->usb_buf[1]; in si470x_get_scratch_page_versions()
345 radio->hardware_version = radio->usb_buf[2]; in si470x_get_scratch_page_versions()
364 struct si470x_device *radio = urb->context; in si470x_int_in_callback() local
378 dev_warn(&radio->intf->dev, in si470x_int_in_callback()
388 radio->registers[STATUSRSSI] = in si470x_int_in_callback()
389 get_unaligned_be16(&radio->int_in_buffer[1]); in si470x_int_in_callback()
391 if (radio->registers[STATUSRSSI] & STATUSRSSI_STC) in si470x_int_in_callback()
392 complete(&radio->completion); in si470x_int_in_callback()
394 if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS)) { in si470x_int_in_callback()
397 radio->registers[STATUSRSSI + regnr] = in si470x_int_in_callback()
398 get_unaligned_be16(&radio->int_in_buffer[ in si470x_int_in_callback()
401 if ((radio->registers[STATUSRSSI] & STATUSRSSI_RDSR) == 0) { in si470x_int_in_callback()
405 if ((radio->registers[STATUSRSSI] & STATUSRSSI_RDSS) == 0) { in si470x_int_in_callback()
412 bler = (radio->registers[STATUSRSSI] & in si470x_int_in_callback()
414 rds = radio->registers[RDSA]; in si470x_int_in_callback()
417 bler = (radio->registers[READCHAN] & in si470x_int_in_callback()
419 rds = radio->registers[RDSB]; in si470x_int_in_callback()
422 bler = (radio->registers[READCHAN] & in si470x_int_in_callback()
424 rds = radio->registers[RDSC]; in si470x_int_in_callback()
427 bler = (radio->registers[READCHAN] & in si470x_int_in_callback()
429 rds = radio->registers[RDSD]; in si470x_int_in_callback()
443 memcpy(&radio->buffer[radio->wr_index], &tmpbuf, 3); in si470x_int_in_callback()
444 radio->wr_index += 3; in si470x_int_in_callback()
447 if (radio->wr_index >= radio->buf_size) in si470x_int_in_callback()
448 radio->wr_index = 0; in si470x_int_in_callback()
451 if (radio->wr_index == radio->rd_index) { in si470x_int_in_callback()
453 radio->rd_index += 3; in si470x_int_in_callback()
454 if (radio->rd_index >= radio->buf_size) in si470x_int_in_callback()
455 radio->rd_index = 0; in si470x_int_in_callback()
458 if (radio->wr_index != radio->rd_index) in si470x_int_in_callback()
459 wake_up_interruptible(&radio->read_queue); in si470x_int_in_callback()
464 if (radio->int_in_running && radio->usbdev) { in si470x_int_in_callback()
465 retval = usb_submit_urb(radio->int_in_urb, GFP_ATOMIC); in si470x_int_in_callback()
467 dev_warn(&radio->intf->dev, in si470x_int_in_callback()
469 radio->int_in_running = 0; in si470x_int_in_callback()
472 radio->status_rssi_auto_update = radio->int_in_running; in si470x_int_in_callback()
488 struct si470x_device *radio = in si470x_usb_release() local
491 usb_free_urb(radio->int_in_urb); in si470x_usb_release()
492 v4l2_ctrl_handler_free(&radio->hdl); in si470x_usb_release()
493 v4l2_device_unregister(&radio->v4l2_dev); in si470x_usb_release()
494 kfree(radio->int_in_buffer); in si470x_usb_release()
495 kfree(radio->buffer); in si470x_usb_release()
496 kfree(radio->usb_buf); in si470x_usb_release()
497 kfree(radio); in si470x_usb_release()
511 struct si470x_device *radio = video_drvdata(file); in si470x_vidioc_querycap() local
515 usb_make_path(radio->usbdev, capability->bus_info, in si470x_vidioc_querycap()
521 static int si470x_start_usb(struct si470x_device *radio) in si470x_start_usb() argument
526 usb_fill_int_urb(radio->int_in_urb, radio->usbdev, in si470x_start_usb()
527 usb_rcvintpipe(radio->usbdev, in si470x_start_usb()
528 radio->int_in_endpoint->bEndpointAddress), in si470x_start_usb()
529 radio->int_in_buffer, in si470x_start_usb()
530 le16_to_cpu(radio->int_in_endpoint->wMaxPacketSize), in si470x_start_usb()
532 radio, in si470x_start_usb()
533 radio->int_in_endpoint->bInterval); in si470x_start_usb()
535 radio->int_in_running = 1; in si470x_start_usb()
538 retval = usb_submit_urb(radio->int_in_urb, GFP_KERNEL); in si470x_start_usb()
540 dev_info(&radio->intf->dev, in si470x_start_usb()
542 radio->int_in_running = 0; in si470x_start_usb()
544 radio->status_rssi_auto_update = radio->int_in_running; in si470x_start_usb()
547 retval = si470x_start(radio); in si470x_start_usb()
551 v4l2_ctrl_handler_setup(&radio->hdl); in si470x_start_usb()
566 struct si470x_device *radio; in si470x_usb_driver_probe() local
573 radio = kzalloc(sizeof(struct si470x_device), GFP_KERNEL); in si470x_usb_driver_probe()
574 if (!radio) { in si470x_usb_driver_probe()
578 radio->usb_buf = kmalloc(MAX_REPORT_SIZE, GFP_KERNEL); in si470x_usb_driver_probe()
579 if (radio->usb_buf == NULL) { in si470x_usb_driver_probe()
583 radio->usbdev = interface_to_usbdev(intf); in si470x_usb_driver_probe()
584 radio->intf = intf; in si470x_usb_driver_probe()
585 radio->band = 1; /* Default to 76 - 108 MHz */ in si470x_usb_driver_probe()
586 mutex_init(&radio->lock); in si470x_usb_driver_probe()
587 init_completion(&radio->completion); in si470x_usb_driver_probe()
589 radio->get_register = si470x_get_register; in si470x_usb_driver_probe()
590 radio->set_register = si470x_set_register; in si470x_usb_driver_probe()
591 radio->fops_open = si470x_fops_open; in si470x_usb_driver_probe()
592 radio->fops_release = si470x_fops_release; in si470x_usb_driver_probe()
593 radio->vidioc_querycap = si470x_vidioc_querycap; in si470x_usb_driver_probe()
601 radio->int_in_endpoint = endpoint; in si470x_usb_driver_probe()
603 if (!radio->int_in_endpoint) { in si470x_usb_driver_probe()
609 int_end_size = le16_to_cpu(radio->int_in_endpoint->wMaxPacketSize); in si470x_usb_driver_probe()
611 radio->int_in_buffer = kmalloc(int_end_size, GFP_KERNEL); in si470x_usb_driver_probe()
612 if (!radio->int_in_buffer) { in si470x_usb_driver_probe()
618 radio->int_in_urb = usb_alloc_urb(0, GFP_KERNEL); in si470x_usb_driver_probe()
619 if (!radio->int_in_urb) { in si470x_usb_driver_probe()
624 radio->v4l2_dev.release = si470x_usb_release; in si470x_usb_driver_probe()
635 retval = usb_control_msg(radio->usbdev, in si470x_usb_driver_probe()
636 usb_rcvctrlpipe(radio->usbdev, 0), in si470x_usb_driver_probe()
640 radio->usb_buf, 3, 500); in si470x_usb_driver_probe()
642 (get_unaligned_be16(&radio->usb_buf[1]) & 0xfff) != 0x0242) { in si470x_usb_driver_probe()
649 retval = v4l2_device_register(&intf->dev, &radio->v4l2_dev); in si470x_usb_driver_probe()
655 v4l2_ctrl_handler_init(&radio->hdl, 2); in si470x_usb_driver_probe()
656 v4l2_ctrl_new_std(&radio->hdl, &si470x_ctrl_ops, in si470x_usb_driver_probe()
658 v4l2_ctrl_new_std(&radio->hdl, &si470x_ctrl_ops, in si470x_usb_driver_probe()
660 if (radio->hdl.error) { in si470x_usb_driver_probe()
661 retval = radio->hdl.error; in si470x_usb_driver_probe()
665 radio->videodev = si470x_viddev_template; in si470x_usb_driver_probe()
666 radio->videodev.ctrl_handler = &radio->hdl; in si470x_usb_driver_probe()
667 radio->videodev.lock = &radio->lock; in si470x_usb_driver_probe()
668 radio->videodev.v4l2_dev = &radio->v4l2_dev; in si470x_usb_driver_probe()
669 radio->videodev.release = video_device_release_empty; in si470x_usb_driver_probe()
670 radio->videodev.device_caps = in si470x_usb_driver_probe()
673 video_set_drvdata(&radio->videodev, radio); in si470x_usb_driver_probe()
676 if (si470x_get_all_registers(radio) < 0) { in si470x_usb_driver_probe()
681 radio->registers[DEVICEID], radio->registers[SI_CHIPID]); in si470x_usb_driver_probe()
682 if ((radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE) < RADIO_FW_VERSION) { in si470x_usb_driver_probe()
688 radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE); in si470x_usb_driver_probe()
693 if (si470x_get_scratch_page_versions(radio) < 0) { in si470x_usb_driver_probe()
698 radio->software_version, radio->hardware_version); in si470x_usb_driver_probe()
699 if (radio->hardware_version < RADIO_HW_VERSION) { in si470x_usb_driver_probe()
705 radio->hardware_version); in si470x_usb_driver_probe()
718 si470x_set_led_state(radio, BLINK_GREEN_LED); in si470x_usb_driver_probe()
721 radio->buf_size = rds_buf * 3; in si470x_usb_driver_probe()
722 radio->buffer = kmalloc(radio->buf_size, GFP_KERNEL); in si470x_usb_driver_probe()
723 if (!radio->buffer) { in si470x_usb_driver_probe()
729 radio->wr_index = 0; in si470x_usb_driver_probe()
730 radio->rd_index = 0; in si470x_usb_driver_probe()
731 init_waitqueue_head(&radio->read_queue); in si470x_usb_driver_probe()
732 usb_set_intfdata(intf, radio); in si470x_usb_driver_probe()
735 retval = si470x_start_usb(radio); in si470x_usb_driver_probe()
736 if (retval < 0 && !radio->int_in_running) in si470x_usb_driver_probe()
742 si470x_set_freq(radio, 87.5 * FREQ_MUL); /* available in all regions */ in si470x_usb_driver_probe()
745 retval = video_register_device(&radio->videodev, VFL_TYPE_RADIO, in si470x_usb_driver_probe()
754 usb_kill_urb(radio->int_in_urb); in si470x_usb_driver_probe()
756 kfree(radio->buffer); in si470x_usb_driver_probe()
758 v4l2_ctrl_handler_free(&radio->hdl); in si470x_usb_driver_probe()
760 v4l2_device_unregister(&radio->v4l2_dev); in si470x_usb_driver_probe()
762 usb_free_urb(radio->int_in_urb); in si470x_usb_driver_probe()
764 kfree(radio->int_in_buffer); in si470x_usb_driver_probe()
766 kfree(radio->usb_buf); in si470x_usb_driver_probe()
768 kfree(radio); in si470x_usb_driver_probe()
780 struct si470x_device *radio = usb_get_intfdata(intf); in si470x_usb_driver_suspend() local
785 if (radio->int_in_running) { in si470x_usb_driver_suspend()
786 radio->int_in_running = 0; in si470x_usb_driver_suspend()
787 if (radio->int_in_urb) in si470x_usb_driver_suspend()
788 usb_kill_urb(radio->int_in_urb); in si470x_usb_driver_suspend()
792 wake_up_interruptible(&radio->read_queue); in si470x_usb_driver_suspend()
795 si470x_stop(radio); in si470x_usb_driver_suspend()
805 struct si470x_device *radio = usb_get_intfdata(intf); in si470x_usb_driver_resume() local
811 ret = si470x_start_usb(radio); in si470x_usb_driver_resume()
813 v4l2_ctrl_handler_setup(&radio->hdl); in si470x_usb_driver_resume()
824 struct si470x_device *radio = usb_get_intfdata(intf); in si470x_usb_driver_disconnect() local
826 mutex_lock(&radio->lock); in si470x_usb_driver_disconnect()
827 v4l2_device_disconnect(&radio->v4l2_dev); in si470x_usb_driver_disconnect()
828 video_unregister_device(&radio->videodev); in si470x_usb_driver_disconnect()
829 usb_kill_urb(radio->int_in_urb); in si470x_usb_driver_disconnect()
831 mutex_unlock(&radio->lock); in si470x_usb_driver_disconnect()
832 v4l2_device_put(&radio->v4l2_dev); in si470x_usb_driver_disconnect()