You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
V4L/DVB (12413): radio-si470x: separate common and usb code
This patch is a preceding work to add the i2c interface of si470x. The si470x directory includes a common file and usb specific file and header file. The part unrelated with usb interface and i2c interface exists in radio-si470x-common.c file, and The usb specific part exists in radio-si470x-usb.c file. Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com> [tobias.lorenz@gmx.net: Small changes, due to new include "linux/smp_lock.h"] Signed-off-by: Tobias Lorenz <tobias.lorenz@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
committed by
Mauro Carvalho Chehab
parent
4efa2d75d4
commit
b09cd16354
@@ -351,29 +351,11 @@ config USB_DSBR
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called dsbr100.
|
||||
|
||||
config USB_SI470X
|
||||
tristate "Silicon Labs Si470x FM Radio Receiver support"
|
||||
depends on USB && VIDEO_V4L2
|
||||
---help---
|
||||
This is a driver for USB devices with the Silicon Labs SI470x
|
||||
chip. Currently these devices are known to work:
|
||||
- 10c4:818a: Silicon Labs USB FM Radio Reference Design
|
||||
- 06e1:a155: ADS/Tech FM Radio Receiver (formerly Instant FM Music)
|
||||
- 1b80:d700: KWorld USB FM Radio SnapMusic Mobile 700 (FM700)
|
||||
config RADIO_SI470X
|
||||
bool "Silicon Labs Si470x FM Radio Receiver support"
|
||||
depends on VIDEO_V4L2
|
||||
|
||||
Sound is provided by the ALSA USB Audio/MIDI driver. Therefore
|
||||
if you don't want to use the device solely for RDS receiving,
|
||||
it is recommended to also select SND_USB_AUDIO.
|
||||
|
||||
Please have a look at the documentation, especially on how
|
||||
to redirect the audio stream from the radio to your sound device:
|
||||
Documentation/video4linux/si470x.txt
|
||||
|
||||
Say Y here if you want to connect this type of radio to your
|
||||
computer's USB port.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called radio-si470x.
|
||||
source "drivers/media/radio/si470x/Kconfig"
|
||||
|
||||
config USB_MR800
|
||||
tristate "AverMedia MR 800 USB FM radio support"
|
||||
|
||||
@@ -17,7 +17,7 @@ obj-$(CONFIG_RADIO_GEMTEK_PCI) += radio-gemtek-pci.o
|
||||
obj-$(CONFIG_RADIO_TRUST) += radio-trust.o
|
||||
obj-$(CONFIG_RADIO_MAESTRO) += radio-maestro.o
|
||||
obj-$(CONFIG_USB_DSBR) += dsbr100.o
|
||||
obj-$(CONFIG_USB_SI470X) += radio-si470x.o
|
||||
obj-$(CONFIG_RADIO_SI470X) += si470x/
|
||||
obj-$(CONFIG_USB_MR800) += radio-mr800.o
|
||||
obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,24 @@
|
||||
config USB_SI470X
|
||||
tristate "Silicon Labs Si470x FM Radio Receiver support with USB"
|
||||
depends on USB && RADIO_SI470X
|
||||
---help---
|
||||
This is a driver for USB devices with the Silicon Labs SI470x
|
||||
chip. Currently these devices are known to work:
|
||||
- 10c4:818a: Silicon Labs USB FM Radio Reference Design
|
||||
- 06e1:a155: ADS/Tech FM Radio Receiver (formerly Instant FM Music)
|
||||
- 1b80:d700: KWorld USB FM Radio SnapMusic Mobile 700 (FM700)
|
||||
- 10c5:819a: Sanei Electric FM USB Radio (aka DealExtreme.com PCear)
|
||||
|
||||
Sound is provided by the ALSA USB Audio/MIDI driver. Therefore
|
||||
if you don't want to use the device solely for RDS receiving,
|
||||
it is recommended to also select SND_USB_AUDIO.
|
||||
|
||||
Please have a look at the documentation, especially on how
|
||||
to redirect the audio stream from the radio to your sound device:
|
||||
Documentation/video4linux/si470x.txt
|
||||
|
||||
Say Y here if you want to connect this type of radio to your
|
||||
computer's USB port.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called radio-usb-si470x.
|
||||
@@ -0,0 +1,7 @@
|
||||
#
|
||||
# Makefile for radios with Silicon Labs Si470x FM Radio Receivers
|
||||
#
|
||||
|
||||
radio-usb-si470x-objs := radio-si470x-usb.o radio-si470x-common.o
|
||||
|
||||
obj-$(CONFIG_USB_SI470X) += radio-usb-si470x.o
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* drivers/media/radio/si470x/radio-si470x.h
|
||||
*
|
||||
* Driver for radios with Silicon Labs Si470x FM Radio Receivers
|
||||
*
|
||||
* Copyright (c) 2009 Tobias Lorenz <tobias.lorenz@gmx.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
/* driver definitions */
|
||||
#define DRIVER_NAME "radio-si470x"
|
||||
|
||||
|
||||
/* kernel includes */
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/smp_lock.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/videodev2.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-ioctl.h>
|
||||
#include <media/rds.h>
|
||||
#include <asm/unaligned.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Register Definitions
|
||||
**************************************************************************/
|
||||
#define RADIO_REGISTER_SIZE 2 /* 16 register bit width */
|
||||
#define RADIO_REGISTER_NUM 16 /* DEVICEID ... RDSD */
|
||||
#define RDS_REGISTER_NUM 6 /* STATUSRSSI ... RDSD */
|
||||
|
||||
#define DEVICEID 0 /* Device ID */
|
||||
#define DEVICEID_PN 0xf000 /* bits 15..12: Part Number */
|
||||
#define DEVICEID_MFGID 0x0fff /* bits 11..00: Manufacturer ID */
|
||||
|
||||
#define CHIPID 1 /* Chip ID */
|
||||
#define CHIPID_REV 0xfc00 /* bits 15..10: Chip Version */
|
||||
#define CHIPID_DEV 0x0200 /* bits 09..09: Device */
|
||||
#define CHIPID_FIRMWARE 0x01ff /* bits 08..00: Firmware Version */
|
||||
|
||||
#define POWERCFG 2 /* Power Configuration */
|
||||
#define POWERCFG_DSMUTE 0x8000 /* bits 15..15: Softmute Disable */
|
||||
#define POWERCFG_DMUTE 0x4000 /* bits 14..14: Mute Disable */
|
||||
#define POWERCFG_MONO 0x2000 /* bits 13..13: Mono Select */
|
||||
#define POWERCFG_RDSM 0x0800 /* bits 11..11: RDS Mode (Si4701 only) */
|
||||
#define POWERCFG_SKMODE 0x0400 /* bits 10..10: Seek Mode */
|
||||
#define POWERCFG_SEEKUP 0x0200 /* bits 09..09: Seek Direction */
|
||||
#define POWERCFG_SEEK 0x0100 /* bits 08..08: Seek */
|
||||
#define POWERCFG_DISABLE 0x0040 /* bits 06..06: Powerup Disable */
|
||||
#define POWERCFG_ENABLE 0x0001 /* bits 00..00: Powerup Enable */
|
||||
|
||||
#define CHANNEL 3 /* Channel */
|
||||
#define CHANNEL_TUNE 0x8000 /* bits 15..15: Tune */
|
||||
#define CHANNEL_CHAN 0x03ff /* bits 09..00: Channel Select */
|
||||
|
||||
#define SYSCONFIG1 4 /* System Configuration 1 */
|
||||
#define SYSCONFIG1_RDSIEN 0x8000 /* bits 15..15: RDS Interrupt Enable (Si4701 only) */
|
||||
#define SYSCONFIG1_STCIEN 0x4000 /* bits 14..14: Seek/Tune Complete Interrupt Enable */
|
||||
#define SYSCONFIG1_RDS 0x1000 /* bits 12..12: RDS Enable (Si4701 only) */
|
||||
#define SYSCONFIG1_DE 0x0800 /* bits 11..11: De-emphasis (0=75us 1=50us) */
|
||||
#define SYSCONFIG1_AGCD 0x0400 /* bits 10..10: AGC Disable */
|
||||
#define SYSCONFIG1_BLNDADJ 0x00c0 /* bits 07..06: Stereo/Mono Blend Level Adjustment */
|
||||
#define SYSCONFIG1_GPIO3 0x0030 /* bits 05..04: General Purpose I/O 3 */
|
||||
#define SYSCONFIG1_GPIO2 0x000c /* bits 03..02: General Purpose I/O 2 */
|
||||
#define SYSCONFIG1_GPIO1 0x0003 /* bits 01..00: General Purpose I/O 1 */
|
||||
|
||||
#define SYSCONFIG2 5 /* System Configuration 2 */
|
||||
#define SYSCONFIG2_SEEKTH 0xff00 /* bits 15..08: RSSI Seek Threshold */
|
||||
#define SYSCONFIG2_BAND 0x0080 /* bits 07..06: Band Select */
|
||||
#define SYSCONFIG2_SPACE 0x0030 /* bits 05..04: Channel Spacing */
|
||||
#define SYSCONFIG2_VOLUME 0x000f /* bits 03..00: Volume */
|
||||
|
||||
#define SYSCONFIG3 6 /* System Configuration 3 */
|
||||
#define SYSCONFIG3_SMUTER 0xc000 /* bits 15..14: Softmute Attack/Recover Rate */
|
||||
#define SYSCONFIG3_SMUTEA 0x3000 /* bits 13..12: Softmute Attenuation */
|
||||
#define SYSCONFIG3_SKSNR 0x00f0 /* bits 07..04: Seek SNR Threshold */
|
||||
#define SYSCONFIG3_SKCNT 0x000f /* bits 03..00: Seek FM Impulse Detection Threshold */
|
||||
|
||||
#define TEST1 7 /* Test 1 */
|
||||
#define TEST1_AHIZEN 0x4000 /* bits 14..14: Audio High-Z Enable */
|
||||
|
||||
#define TEST2 8 /* Test 2 */
|
||||
/* TEST2 only contains reserved bits */
|
||||
|
||||
#define BOOTCONFIG 9 /* Boot Configuration */
|
||||
/* BOOTCONFIG only contains reserved bits */
|
||||
|
||||
#define STATUSRSSI 10 /* Status RSSI */
|
||||
#define STATUSRSSI_RDSR 0x8000 /* bits 15..15: RDS Ready (Si4701 only) */
|
||||
#define STATUSRSSI_STC 0x4000 /* bits 14..14: Seek/Tune Complete */
|
||||
#define STATUSRSSI_SF 0x2000 /* bits 13..13: Seek Fail/Band Limit */
|
||||
#define STATUSRSSI_AFCRL 0x1000 /* bits 12..12: AFC Rail */
|
||||
#define STATUSRSSI_RDSS 0x0800 /* bits 11..11: RDS Synchronized (Si4701 only) */
|
||||
#define STATUSRSSI_BLERA 0x0600 /* bits 10..09: RDS Block A Errors (Si4701 only) */
|
||||
#define STATUSRSSI_ST 0x0100 /* bits 08..08: Stereo Indicator */
|
||||
#define STATUSRSSI_RSSI 0x00ff /* bits 07..00: RSSI (Received Signal Strength Indicator) */
|
||||
|
||||
#define READCHAN 11 /* Read Channel */
|
||||
#define READCHAN_BLERB 0xc000 /* bits 15..14: RDS Block D Errors (Si4701 only) */
|
||||
#define READCHAN_BLERC 0x3000 /* bits 13..12: RDS Block C Errors (Si4701 only) */
|
||||
#define READCHAN_BLERD 0x0c00 /* bits 11..10: RDS Block B Errors (Si4701 only) */
|
||||
#define READCHAN_READCHAN 0x03ff /* bits 09..00: Read Channel */
|
||||
|
||||
#define RDSA 12 /* RDSA */
|
||||
#define RDSA_RDSA 0xffff /* bits 15..00: RDS Block A Data (Si4701 only) */
|
||||
|
||||
#define RDSB 13 /* RDSB */
|
||||
#define RDSB_RDSB 0xffff /* bits 15..00: RDS Block B Data (Si4701 only) */
|
||||
|
||||
#define RDSC 14 /* RDSC */
|
||||
#define RDSC_RDSC 0xffff /* bits 15..00: RDS Block C Data (Si4701 only) */
|
||||
|
||||
#define RDSD 15 /* RDSD */
|
||||
#define RDSD_RDSD 0xffff /* bits 15..00: RDS Block D Data (Si4701 only) */
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* General Driver Definitions
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* si470x_device - private data
|
||||
*/
|
||||
struct si470x_device {
|
||||
struct video_device *videodev;
|
||||
|
||||
/* reference to USB and video device */
|
||||
struct usb_device *usbdev;
|
||||
struct usb_interface *intf;
|
||||
|
||||
/* Interrupt endpoint handling */
|
||||
char *int_in_buffer;
|
||||
struct usb_endpoint_descriptor *int_in_endpoint;
|
||||
struct urb *int_in_urb;
|
||||
int int_in_running;
|
||||
|
||||
/* scratch page */
|
||||
unsigned char software_version;
|
||||
unsigned char hardware_version;
|
||||
|
||||
/* driver management */
|
||||
unsigned char disconnected;
|
||||
struct mutex disconnect_lock;
|
||||
unsigned int users;
|
||||
|
||||
/* Silabs internal registers (0..15) */
|
||||
unsigned short registers[RADIO_REGISTER_NUM];
|
||||
|
||||
/* RDS receive buffer */
|
||||
wait_queue_head_t read_queue;
|
||||
struct mutex lock; /* buffer locking */
|
||||
unsigned char *buffer; /* size is always multiple of three */
|
||||
unsigned int buf_size;
|
||||
unsigned int rd_index;
|
||||
unsigned int wr_index;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* The frequency is set in units of 62.5 Hz when using V4L2_TUNER_CAP_LOW,
|
||||
* 62.5 kHz otherwise.
|
||||
* The tuner is able to have a channel spacing of 50, 100 or 200 kHz.
|
||||
* tuner->capability is therefore set to V4L2_TUNER_CAP_LOW
|
||||
* The FREQ_MUL is then: 1 MHz / 62.5 Hz = 16000
|
||||
*/
|
||||
#define FREQ_MUL (1000000 / 62.5)
|
||||
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Common Functions
|
||||
**************************************************************************/
|
||||
extern const struct v4l2_file_operations si470x_fops;
|
||||
extern struct video_device si470x_viddev_template;
|
||||
int si470x_get_register(struct si470x_device *radio, int regnr);
|
||||
int si470x_set_register(struct si470x_device *radio, int regnr);
|
||||
int si470x_set_freq(struct si470x_device *radio, unsigned int freq);
|
||||
int si470x_start(struct si470x_device *radio);
|
||||
int si470x_stop(struct si470x_device *radio);
|
||||
int si470x_rds_on(struct si470x_device *radio);
|
||||
int si470x_vidioc_querycap(struct file *file, void *priv,
|
||||
struct v4l2_capability *capability);
|
||||
Reference in New Issue
Block a user