linux/drivers/media/radio/radio-ma901.c

// 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 <[email protected]>
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/input.h>
#include <linux/videodev2.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-event.h>
#include <linux/usb.h>
#include <linux/mutex.h>

#define DRIVER_AUTHOR
#define DRIVER_DESC
#define DRIVER_VERSION

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_VERSION();

#define USB_MA901_VENDOR
#define USB_MA901_PRODUCT

/* dev_warn macro with driver name */
#define MA901_DRIVER_NAME
#define ma901radio_dev_warn(dev, fmt, arg...)

#define ma901radio_dev_err(dev, fmt, arg...)

/* Probably USB_TIMEOUT should be modified in module parameter */
#define BUFFER_LENGTH
#define USB_TIMEOUT

#define FREQ_MIN
#define FREQ_MAX
#define FREQ_MUL

#define MA901_VOLUME_MAX
#define MA901_VOLUME_MIN

/* Commands that device should understand
 * List isn't full and will be updated with implementation of new functions
 */
#define MA901_RADIO_SET_FREQ
#define MA901_RADIO_SET_VOLUME
#define MA901_RADIO_SET_MONO_STEREO

/* Comfortable defines for ma901radio_set_stereo */
#define MA901_WANT_STEREO
#define MA901_WANT_MONO

/* module parameter */
static int radio_nr =;
module_param(radio_nr, int, 0);
MODULE_PARM_DESC();

/* Data for one (physical) device */
struct ma901radio_device {};

static inline struct ma901radio_device *to_ma901radio_dev(struct v4l2_device *v4l2_dev)
{}

/* set a frequency, freq is defined by v4l's TUNER_LOW, i.e. 1/16th kHz */
static int ma901radio_set_freq(struct ma901radio_device *radio, int freq)
{}

static int ma901radio_set_volume(struct ma901radio_device *radio, u16 vol_to_set)
{}

static int ma901_set_stereo(struct ma901radio_device *radio, u8 stereo)
{}

/* Handle unplugging the device.
 * We call video_unregister_device in any case.
 * The last function called in this procedure is
 * usb_ma901radio_device_release.
 */
static void usb_ma901radio_disconnect(struct usb_interface *intf)
{}

/* vidioc_querycap - query device capabilities */
static int vidioc_querycap(struct file *file, void *priv,
					struct v4l2_capability *v)
{}

/* vidioc_g_tuner - get tuner attributes */
static int vidioc_g_tuner(struct file *file, void *priv,
				struct v4l2_tuner *v)
{}

/* vidioc_s_tuner - set tuner attributes */
static int vidioc_s_tuner(struct file *file, void *priv,
				const struct v4l2_tuner *v)
{}

/* vidioc_s_frequency - set tuner radio frequency */
static int vidioc_s_frequency(struct file *file, void *priv,
				const struct v4l2_frequency *f)
{}

/* vidioc_g_frequency - get tuner radio frequency */
static int vidioc_g_frequency(struct file *file, void *priv,
				struct v4l2_frequency *f)
{}

static int usb_ma901radio_s_ctrl(struct v4l2_ctrl *ctrl)
{}

/* 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.
 */
static int usb_ma901radio_suspend(struct usb_interface *intf, pm_message_t message)
{}

static int usb_ma901radio_resume(struct usb_interface *intf)
{}

static const struct v4l2_ctrl_ops usb_ma901radio_ctrl_ops =;

/* File system interface */
static const struct v4l2_file_operations usb_ma901radio_fops =;

static const struct v4l2_ioctl_ops usb_ma901radio_ioctl_ops =;

static void usb_ma901radio_release(struct v4l2_device *v4l2_dev)
{}

/* check if the device is present and register with v4l and usb if it is */
static int usb_ma901radio_probe(struct usb_interface *intf,
				const struct usb_device_id *id)
{}

/* USB Device ID List */
static const struct usb_device_id usb_ma901radio_device_table[] =;

MODULE_DEVICE_TABLE(usb, usb_ma901radio_device_table);

/* USB subsystem interface */
static struct usb_driver usb_ma901radio_driver =;

module_usb_driver();