// SPDX-License-Identifier: GPL-2.0-or-later /* * Driver for the MasterKit MA901 USB FM radio. This device plugs * into the USB port and an analog audio input or headphones, so this thing * only deals with initialization, frequency setting, volume. * * Copyright (c) 2012 Alexey Klimov <klimov.linux@gmail.com>
*/
/* Commands that device should understand * List isn't full and will be updated with implementation of new functions
*/ #define MA901_RADIO_SET_FREQ 0x03 #define MA901_RADIO_SET_VOLUME 0x04 #define MA901_RADIO_SET_MONO_STEREO 0x05
/* Data for one (physical) device */ struct ma901radio_device { /* reference to USB and video device */ struct usb_device *usbdev; struct usb_interface *intf; struct video_device vdev; struct v4l2_device v4l2_dev; struct v4l2_ctrl_handler hdl;
u8 *buffer; struct mutex lock; /* buffer locking */ int curfreq;
u16 volume; int stereo; bool muted;
};
/* set a frequency, freq is defined by v4l's TUNER_LOW, i.e. 1/16th kHz */ staticint ma901radio_set_freq(struct ma901radio_device *radio, int freq)
{ unsignedint freq_send = 0x300 + (freq >> 5) / 25; int retval;
/* Handle unplugging the device. * We call video_unregister_device in any case. * The last function called in this procedure is * usb_ma901radio_device_release.
*/ staticvoid usb_ma901radio_disconnect(struct usb_interface *intf)
{ struct ma901radio_device *radio = to_ma901radio_dev(usb_get_intfdata(intf));
/* TODO: the same words like in _probe() goes here. * When receiving of stats will be implemented then we can call * ma901radio_get_stat(). * retval = ma901radio_get_stat(radio, &is_stereo, &v->signal);
*/
switch (ctrl->id) { case V4L2_CID_AUDIO_VOLUME: /* set volume */ return ma901radio_set_volume(radio, (u16)ctrl->val);
}
return -EINVAL;
}
/* TODO: Should we really need to implement suspend and resume functions? * Radio has it's own memory and will continue playing if power is present * on usb port and on resume it will start to play again based on freq, volume * values in device memory.
*/ staticint usb_ma901radio_suspend(struct usb_interface *intf, pm_message_t message)
{ return 0;
}
/* check if the device is present and register with v4l and usb if it is */ staticint usb_ma901radio_probe(struct usb_interface *intf, conststruct usb_device_id *id)
{ struct usb_device *dev = interface_to_usbdev(intf); struct ma901radio_device *radio; int retval = 0;
/* Masterkit MA901 usb radio has the same USB ID as many others * Atmel V-USB devices. Let's make additional checks to be sure * that this is our device.
*/
/* TODO:It looks like this radio doesn't have mute/unmute control * and windows program just emulate it using volume control. * Let's plan to do the same in this driver. * * v4l2_ctrl_new_std(&radio->hdl, &usb_ma901radio_ctrl_ops, * V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1);
*/
/* TODO: we can get some statistics (freq, volume) from device * but it's not implemented yet. After insertion in usb-port radio * setups frequency and starts playing without any initialization. * So we don't call usb_ma901radio_init/get_stat() here. * retval = usb_ma901radio_init(radio);
*/
retval = video_register_device(&radio->vdev, VFL_TYPE_RADIO,
radio_nr); if (retval < 0) {
dev_err(&intf->dev, "could not register video device\n"); goto err_vdev;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.