si4713 : USB driver
Subsystems (4)
cover si4713 : USB driver
This patch series adds USB support for the SiLabs development board which contains the Si4713 FM transmitter chip.
This device can transmit audio through FM.
It can transmit RDS and RBDS signals as well.
Documentation for this product can be accessed here :
http://www.silabs.com/products/audiovideo/fmtransmitters/Pages/si471213.aspx
Note : All the patches are on top of the latest version of the media-git tree as on 20-August-2013 (15:30 Europe time)
In the source tree, drivers/media/radio has been reorganized to include a new folder drivers/media/radio/si4713 which contains all the si4713 related files.
Modified and renamed files :
-----------------------------------drivers/media/radio/si4713-i2c.c ==> drivers/media/radio/si4713/si4713.c drivers/media/radio/si4713-i2c.h ==> drivers/media/radio/si4713/si4713.h drivers/media/radio/radio-si4713.c ==> drivers/media/radio/si4713/radio-i2c-si4713.c
New files :
-------------drivers/media/radio/si4713/radio-usb-si4713.c
The existing i2c driver has been modified to add support for cases where the interrupt is not enabled.
Checks have been introduced at several places in the code to test if an interrupt is set or not. The development board is plugged into the host through USB and does not use interrupts. To get a valid response, within a specified timeout, the device is polled instead.
The USB driver has been developed by analyzing the the USB traffic obtained by sniffing the USB bus. A sequence of commands are sent during device startup, the specifics of which are not obvious. Nevertheless they seem to be necessary for the proper fuctioning of the device.
The i2c driver assumes a 2-wire bus mode.
RFC PATCH 2/5 si4713 : Modified i2c driver to handle cases where interrupts are not used
Checks have been introduced at several places in the code to test if an interrupt is set or not. For devices which do not use the interrupt, to get a valid response, within a specified timeout, the device is polled instead.
--- drivers/media/radio/si4713/si4713.c | 110 ++++++++++++++++++++---------------- drivers/media/radio/si4713/si4713.h | 1 + 2 files changed, 63 insertions(+), 48 deletions(-)
drivers/media/radio/si4713/si4713.c +62 -48
@@ -27,7 +27,6 @@#include <linux/i2c.h> #include <linux/slab.h> #include <linux/gpio.h> -#include <linux/regulator/consumer.h> #include <linux/module.h> #include <media/v4l2-device.h> #include <media/v4l2-ioctl.h>
@@ -213,6 +212,7 @@ static int si4713_send_command(struct si4713_device *sdev, const u8 command, u8 response[], const int respn, const int usecs) { struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd); +unsigned long until_jiffies;u8 data1[MAX_ARGS +1 ];int err;
@@ -228,30 +228,39 @@ static int si4713_send_command(struct si4713_device *sdev, const u8 command,if (err != argn +1 ) {v4l2_err (&sdev->sd,"Error while sending command 0x%02x\n" , command); -return (err >0 ) ? -EIO : err; +return err <0 ? err : -EIO ; } + until_jiffies = jiffies +usecs_to_jiffies (usecs) +1 ; +/* Wait response from interrupt */ -if (!wait_for_completion_timeout (&sdev->work, +if (client->irq) { +if (!wait_for_completion_timeout (&sdev->work,usecs_to_jiffies (usecs) +1 )) -v4l2_warn (&sdev->sd, +v4l2_warn (&sdev->sd,"(%s) Device took too much time to answer.\n" , __func__); - -/* Then get the response */ - err =i2c_master_recv (client, response, respn); -if (err != respn) { -v4l2_err (&sdev->sd, -"Error while reading response for command 0x%02x\n" , - command); -return (err >0 ) ? -EIO : err; } -DBG_BUFFER (&sdev->sd,"Response" , response, respn); -if (check_command_failed (response[0 ])) -return -EBUSY ; +do { + err =i2c_master_recv (client, response, respn); +if (err != respn) { +v4l2_err (&sdev->sd, +"Error %d while reading response for command 0x%02x\n" , + err, command); +return err <0 ? err : -EIO ; + } -return 0 ; +DBG_BUFFER (&sdev->sd,"Response" , response, respn); +if (!check_command_failed (response[0 ])) +return 0 ; + +if (client->irq) +return -EBUSY ; +msleep (1 ); + }while (jiffies <= until_jiffies); + +return -EBUSY ; }/*
@@ -344,14 +353,15 @@ static int si4713_write_property(struct si4713_device *sdev, u16 prop, u16 val)*/ static int si4713_powerup (struct si4713_device *sdev) { +struct i2c_client *client =v4l2_get_subdevdata (&sdev->sd);int err;u8 resp[SI4713_PWUP_NRESP ];/* * .First byte = Enabled interrupts and boot function * .Second byte = Input operation mode */ -const u8 args[SI4713_PWUP_NARGS ] = { -SI4713_PWUP_CTSIEN |SI4713_PWUP_GPO2OEN |SI4713_PWUP_FUNC_TX , +u8 args[SI4713_PWUP_NARGS ] = { +SI4713_PWUP_GPO2OEN |SI4713_PWUP_FUNC_TX ,SI4713_PWUP_OPMOD_ANALOG , };
@@ -369,18 +379,22 @@ static int si4713_powerup(struct si4713_device *sdev)gpio_set_value (sdev->gpio_reset,1 ); } +if (client->irq) + args[0 ] |=SI4713_PWUP_CTSIEN ; + err =si4713_send_command (sdev,SI4713_CMD_POWER_UP , args,ARRAY_SIZE (args), resp,ARRAY_SIZE (resp),TIMEOUT_POWER_UP ); - +if (!err) {v4l2_dbg (1 , debug, &sdev->sd,"Powerup response: 0x%02x\n" , resp[0 ]);v4l2_dbg (1 , debug, &sdev->sd,"Device in power up mode\n" ); sdev->power_state =POWER_ON ; - err =si4713_write_property (sdev,SI4713_GPO_IEN , +if (client->irq) + err =si4713_write_property (sdev,SI4713_GPO_IEN ,SI4713_STC_INT |SI4713_CTS ); }else {if (gpio_is_valid (sdev->gpio_reset))
@@ -447,7 +461,7 @@ static int si4713_checkrev(struct si4713_device *sdev)if (rval <0 )return rval; -if (resp[1 ] ==SI4713_PRODUCT_NUMBER ) { +if (resp[1 ] ==SI4713_PRODUCT_NUMBER ) {v4l2_info (&sdev->sd,"chip found @ 0x%02x (%s)\n" , client->addr <<1 , client->adapter->name); }else {
@@ -465,33 +479,34 @@ static int si4713_checkrev(struct si4713_device *sdev)*/ static int si4713_wait_stc (struct si4713_device *sdev,const int usecs) { -int err; +struct i2c_client *client =v4l2_get_subdevdata (&sdev->sd);u8 resp[SI4713_GET_STATUS_NRESP ]; - -/* Wait response from STC interrupt */ -if (!wait_for_completion_timeout (&sdev->work, -usecs_to_jiffies (usecs) +1 )) -v4l2_warn (&sdev->sd, -"%s: device took too much time to answer (%d usec).\n" , - __func__, usecs); - -/* Clear status bits */ - err =si4713_send_command (sdev,SI4713_CMD_GET_INT_STATUS , -NULL ,0 , - resp,ARRAY_SIZE (resp), -DEFAULT_TIMEOUT ); - -if (err <0 ) - goto exit; - -v4l2_dbg (1 , debug, &sdev->sd, -"%s: status bits: 0x%02x\n" , __func__, resp[0 ]); - -if (!(resp[0 ] &SI4713_STC_INT )) - err = -EIO ; - -exit: -return err; +unsigned long start_jiffies = jiffies; +int err; + +if (client->irq && + !wait_for_completion_timeout (&sdev->work,usecs_to_jiffies (usecs) +1 )) +v4l2_warn (&sdev->sd, +"(%s) Device took too much time to answer.\n" , __func__); + +for (;;) { +/* Clear status bits */ + err =si4713_send_command (sdev,SI4713_CMD_GET_INT_STATUS , +NULL ,0 , + resp,ARRAY_SIZE (resp), +DEFAULT_TIMEOUT ); + +if (err >=0 ) { +v4l2_dbg (1 , debug, &sdev->sd, +"%s: status bits: 0x%02x\n" , __func__, resp[0 ]); + +if (resp[0 ] &SI4713_STC_INT ) +return 0 ; + } +if (jiffies_to_usecs (jiffies - start_jiffies) > usecs) +return -EIO ; +msleep (3 ); + } }/*
@@ -1024,7 +1039,6 @@ static int si4713_initialize(struct si4713_device *sdev)if (rval <0 )return rval; - sdev->frequency =DEFAULT_FREQUENCY ; sdev->stereo =1 ; sdev->tune_rnl =DEFAULT_TUNE_RNL ;
drivers/media/radio/si4713/si4713.h +1 -0
@@ -15,6 +15,7 @@#ifndef SI4713_I2C_H #define SI4713_I2C_H +#include <linux/regulator/consumer.h> #include <media/v4l2-subdev.h> #include <media/v4l2-ctrls.h> #include <media/si4713.h>
Signature · 1 line
1.8.4.rc2
RFC PATCH 3/5 si4713 : Bug fix for si4713_tx_tune_power() method in the i2c driver
In reply to Dinesh RamIn the si4713_tx_tune_power() method, the args array element 'power' can take values between SI4713_MIN_POWER and SI4713_MAX_POWER. power = 0 is also valid.
All the values (0 > power < SI4713_MIN_POWER) are illegal and hence
are all mapped to SI4713_MIN_POWER.
--- drivers/media/radio/si4713/si4713.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/media/radio/si4713/si4713.c +8 -8
@@ -550,14 +550,14 @@ static int si4713_tx_tune_freq(struct si4713_device *sdev, u16 frequency) }/* -* si4713_tx_tune_power - Sets the RF voltage level between 88 and 115 dBuV in +* si4713_tx_tune_power - Sets the RF voltage level between 88 and 120 dBuV in * 1 dB units. A value of 0x00 indicates off. The command * also sets the antenna tuning capacitance. A value of 0 * indicates autotuning, and a value of 1 - 191 indicates * a manual override, which results in a tuning * capacitance of 0.25 pF x @antcap. * @sdev: si4713_device structure for the device we are communicating -* @power: tuning power (88 - 115 dBuV, unit/step 1 dB) +* @power: tuning power (88 - 120 dBuV, unit/step 1 dB) * @antcap: value of antenna tuning capacitor (0 - 191) */ static int si4713_tx_tune_power(struct si4713_device *sdev, u8 power,
@@ -571,16 +571,16 @@ static int si4713_tx_tune_power(struct si4713_device *sdev, u8 power,* .Third byte = power * .Fourth byte = antcap */ -const u8 args[SI4713_TXPWR_NARGS ] = { +u8 args[SI4713_TXPWR_NARGS ] = {0x00 ,0x00 , power, antcap, }; -if (((power >0 ) && (power <SI4713_MIN_POWER )) || - power >SI4713_MAX_POWER || antcap >SI4713_MAX_ANTCAP ) -return -EDOM ; +/* Map power values 1-87 to MIN_POWER (88) */ +if (power >0 && power <SI4713_MIN_POWER ) + args[2 ] = power =SI4713_MIN_POWER ; err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_POWER, args, ARRAY_SIZE(args), val,
@@ -1457,9 +1457,9 @@ static int si4713_probe(struct i2c_client *client,V4L2_CID_TUNE_PREEMPHASIS , V4L2_PREEMPHASIS_75_uS, 0, V4L2_PREEMPHASIS_50_uS); sdev->tune_pwr_level =v4l2_ctrl_new_std (hdl, &si4713_ctrl_ops, -V4L2_CID_TUNE_POWER_LEVEL ,0 ,120 ,1 ,DEFAULT_POWER_LEVEL ); +V4L2_CID_TUNE_POWER_LEVEL ,0 ,SI4713_MAX_POWER ,1 ,DEFAULT_POWER_LEVEL ); sdev->tune_ant_cap =v4l2_ctrl_new_std (hdl, &si4713_ctrl_ops, -V4L2_CID_TUNE_ANTENNA_CAPACITOR ,0 ,191 ,1 ,0 ); +V4L2_CID_TUNE_ANTENNA_CAPACITOR ,0 ,SI4713_MAX_ANTCAP ,1 ,0 );if (hdl->error) { rval = hdl->error;
Signature · 1 line
1.8.4.rc2
RFC PATCH 4/5 si4713 : HID blacklist Si4713 USB development board
In reply to Dinesh RamThe Si4713 development board contains a Si4713 FM transmitter chip and is handled by the radio-usb-si4713 driver.
The board reports itself as (10c4:8244) Cygnal Integrated Products, Inc. and misidentifies itself as a HID device in its USB interface descriptor. This patch ignores this device as an HID device and hence loads the custom driver.
--- drivers/hid/hid-core.c | 1 + drivers/hid/hid-ids.h | 2 ++ 2 files changed, 3 insertions(+)
drivers/hid/hid-core.c +1 -0
@@ -1977,6 +1977,7 @@ static const struct hid_device_id hid_ignore_list[] = { { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) }, { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) }, { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) }, + { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI4713) }, { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) }, { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) }, { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) },
drivers/hid/hid-ids.h +2 -0
@@ -241,6 +241,8 @@#define USB_VENDOR_ID_CYGNAL 0x10c4#define USB_DEVICE_ID_CYGNAL_RADIO_SI470X 0x818a +#define USB_DEVICE_ID_CYGNAL_RADIO_SI4713 0x8244 +#define USB_VENDOR_ID_CYPRESS 0x04b4#define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001#define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500
Signature · 1 line
1.8.4.rc2
RFC PATCH 1/5 si4713 : Reorganized drivers/media/radio directory
In reply to Dinesh RamAdded a new si4713 directory which will contain all si4713 related files. Also updated Makefile and Kconfig
--- drivers/media/radio/Kconfig | 29 +- drivers/media/radio/Makefile | 3 +- drivers/media/radio/radio-si4713.c | 246 ---- drivers/media/radio/si4713-i2c.c | 1532 ------------------------- drivers/media/radio/si4713-i2c.h | 238 ---- drivers/media/radio/si4713/Kconfig | 25 + drivers/media/radio/si4713/Makefile | 7 + drivers/media/radio/si4713/radio-i2c-si4713.c | 246 ++++ drivers/media/radio/si4713/si4713.c | 1532 +++++++++++++++++++++++++ drivers/media/radio/si4713/si4713.h | 238 ++++ 10 files changed, 2055 insertions(+), 2041 deletions(-) delete mode 100644 drivers/media/radio/radio-si4713.c delete mode 100644 drivers/media/radio/si4713-i2c.c delete mode 100644 drivers/media/radio/si4713-i2c.h create mode 100644 drivers/media/radio/si4713/Kconfig create mode 100644 drivers/media/radio/si4713/Makefile create mode 100644 drivers/media/radio/si4713/radio-i2c-si4713.c create mode 100644 drivers/media/radio/si4713/si4713.c create mode 100644 drivers/media/radio/si4713/si4713.h
drivers/media/radio/Kconfig +6 -23
@@ -15,6 +15,12 @@ if RADIO_ADAPTERS && VIDEO_V4L2 config RADIO_TEA575X tristate +config RADIO_SI4713 + tristate "Silicon Labs Si4713 FM Radio with RDS Transmitter support" + depends on VIDEO_V4L2 + +source "drivers/media/radio/si4713/Kconfig" + config RADIO_SI470X bool "Silicon Labs Si470x FM Radio Receiver support" depends on VIDEO_V4L2
@@ -113,29 +119,6 @@ config RADIO_SHARK2 To compile this driver as a module, choose M here: the module will be called radio-shark2. -config I2C_SI4713 - tristate "I2C driver for Silicon Labs Si4713 device" - depends on I2C && VIDEO_V4L2 - ---help--- - Say Y here if you want support to Si4713 I2C device. - This device driver supports only i2c bus. - - To compile this driver as a module, choose M here: the - module will be called si4713. - -config RADIO_SI4713 - tristate "Silicon Labs Si4713 FM Radio Transmitter support" - depends on I2C && VIDEO_V4L2 - select I2C_SI4713 - ---help--- - Say Y here if you want support to Si4713 FM Radio Transmitter. - This device can transmit audio through FM. It can transmit - RDS and RBDS signals as well. This module is the v4l2 radio - interface for the i2c driver of this device. - - To compile this driver as a module, choose M here: the - module will be called radio-si4713. - config USB_KEENE tristate "Keene FM Transmitter USB support" depends on USB && VIDEO_V4L2
drivers/media/radio/Makefile +1 -2
@@ -17,12 +17,11 @@ obj-$(CONFIG_RADIO_RTRACK) += radio-aimslab.o obj-$(CONFIG_RADIO_ZOLTRIX) += radio-zoltrix.o obj-$(CONFIG_RADIO_GEMTEK) += radio-gemtek.o obj-$(CONFIG_RADIO_TRUST) += radio-trust.o -obj-$(CONFIG_I2C_SI4713) += si4713-i2c.o -obj-$(CONFIG_RADIO_SI4713) += radio-si4713.o obj-$(CONFIG_RADIO_SI476X) += radio-si476x.o obj-$(CONFIG_RADIO_MIROPCM20) += radio-miropcm20.o obj-$(CONFIG_USB_DSBR) += dsbr100.o obj-$(CONFIG_RADIO_SI470X) += si470x/ +obj-$(CONFIG_RADIO_SI4713) += si4713/ obj-$(CONFIG_USB_MR800) += radio-mr800.o obj-$(CONFIG_USB_KEENE) += radio-keene.o obj-$(CONFIG_USB_MA901) += radio-ma901.o
drivers/media/radio/radio-si4713.c deleted +0 -246
246 lines not on this page · raw message
drivers/media/radio/si4713-i2c.c deleted +0 -1532
1,532 lines not on this page · raw message
drivers/media/radio/si4713-i2c.h deleted +0 -238
238 lines not on this page · raw message
drivers/media/radio/si4713/Kconfig new file +25 -0
@@ -0,0 +1,25 @@ +config I2C_SI4713 + tristate "Silicon Labs Si4713 FM Radio Transmitter support with I2C" + depends on I2C && RADIO_SI4713 + select SI4713 + ---help--- + This is a driver for I2C devices with the Silicon Labs SI4713 + chip. + + Say Y here if you want to connect this type of radio to your + computer's I2C port. + + To compile this driver as a module, choose M here: the + module will be called radio-i2c-si4713. + +config SI4713 + tristate "Silicon Labs Si4713 FM Radio Transmitter support" + depends on I2C && RADIO_SI4713 + ---help--- + Say Y here if you want support to Si4713 FM Radio Transmitter. + This device can transmit audio through FM. It can transmit + RDS and RBDS signals as well. This module is the v4l2 radio + interface for the i2c driver of this device. + + To compile this driver as a module, choose M here: the + module will be called si4713.
drivers/media/radio/si4713/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# +# Makefile for radios with Silicon Labs Si4713 FM Radio Transmitters +# + +obj-$(CONFIG_SI4713) += si4713.o +obj-$(CONFIG_I2C_SI4713) += radio-i2c-si4713.o +
drivers/media/radio/si4713/radio-i2c-si4713.c new file +246 -0
246 lines not on this page · raw message
drivers/media/radio/si4713/si4713.c new file +1532 -0
652 lines not on this page · raw message
drivers/media/radio/si4713/si4713.h new file +238 -0
238 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.8.4.rc2
Part of the diff is not shown here. View the raw message.
RFC PATCH 5/5 si4713 : Added the USB driver for Si4713
In reply to Dinesh RamThis is the USB driver for the Silicon Labs development board. It contains the Si4713 FM transmitter chip.
--- drivers/media/radio/si4713/Kconfig | 15 + drivers/media/radio/si4713/Makefile | 1 + drivers/media/radio/si4713/radio-usb-si4713.c | 538 ++++++++++++++++++++++++++ 3 files changed, 554 insertions(+) create mode 100644 drivers/media/radio/si4713/radio-usb-si4713.c
drivers/media/radio/si4713/Kconfig +15 -0
@@ -1,3 +1,18 @@ +config USB_SI4713 + tristate "Silicon Labs Si4713 FM Radio Transmitter support with USB" + depends on USB && RADIO_SI4713 + select SI4713 + ---help--- + This is a driver for USB devices with the Silicon Labs SI4713 + chip. Currently these devices are known to work. + - 10c4:8244: Silicon Labs FM Transmitter USB device. + + 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-si4713. + config I2C_SI4713 tristate "Silicon Labs Si4713 FM Radio Transmitter support with I2C" depends on I2C && RADIO_SI4713
drivers/media/radio/si4713/Makefile +1 -0
@@ -3,5 +3,6 @@ # obj-$(CONFIG_SI4713) += si4713.o +obj-$(CONFIG_USB_SI4713) += radio-usb-si4713.o obj-$(CONFIG_I2C_SI4713) += radio-i2c-si4713.o
drivers/media/radio/si4713/radio-usb-si4713.c new file +538 -0
538 lines not on this page · raw message
Signature · 1 line
1.8.4.rc2