FM Transmitter driver
cover FM Transmitter driver
Hello Mauro and v4l guys,
This series contains a v4l2 radio driver which adds support for Silabs si4713 devices. That is a FM transmitter device.
As you should know, v4l2 does not contain representation of FM Transmitters (at least that I know). So this driver was written highly based on FM receivers API, which can cover most of basic functionality. However, as expected, there are some properties which were not covered. For those properties, sysfs nodes were added in order to get user interactions.
Comments are wellcome.
Eduardo Valentin (3):
FMTx: si4713: Add files to handle si4713 device
FMTx: si4713: Add files to add radio interface for si4713
FMTx: si4713: Add Kconfig and Makefile entries
drivers/media/radio/Kconfig | 12 + drivers/media/radio/Makefile | 2 + drivers/media/radio/radio-si4713.c | 834 ++++++++++++++ drivers/media/radio/radio-si4713.h | 32 + drivers/media/radio/si4713.c | 2238 ++++++++++++++++++++++++++++++++++++ drivers/media/radio/si4713.h | 294 +++++ 6 files changed, 3412 insertions(+), 0 deletions(-) create mode 100644 drivers/media/radio/radio-si4713.c create mode 100644 drivers/media/radio/radio-si4713.h create mode 100644 drivers/media/radio/si4713.c create mode 100644 drivers/media/radio/si4713.h
PATCH 1/3 FMTx: si4713: Add files to handle si4713 device
This patch adds files to control si4713 devices. Internal functions to control device properties and initialization procedures are into these files.
--- drivers/media/radio/si4713.c | 2238 ++++++++++++++++++++++++++++++++++++++++++ drivers/media/radio/si4713.h | 294 ++++++ 2 files changed, 2532 insertions(+), 0 deletions(-) create mode 100644 drivers/media/radio/si4713.c create mode 100644 drivers/media/radio/si4713.h
drivers/media/radio/si4713.c new file +2238 -0
@@ -0,0 +1,2238 @@ +/* +* drivers/media/radio/si4713.c +* +* Silicon Labs Si4713 FM Radio Transmitter I2C commands. +* +* Copyright (c) 2008 Instituto Nokia de Tecnologia - INdT +* Author: Eduardo Valentin <[email protected]> +* +* 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 +*/ + +#include <linux/mutex.h> +#include <linux/completion.h> +#include <linux/delay.h> +#include <linux/i2c.h> + +#include "si4713.h" + +#define MAX_ARGS 7 + +#define RDS_BLOCK 8 +#define RDS_BLOCK_CLEAR 0x03 +#define RDS_BLOCK_LOAD 0x04 +#define RDS_RADIOTEXT_2A 0x20 +#define RDS_RADIOTEXT_BLK_SIZE 4 +#define RDS_RADIOTEXT_INDEX_MAX 0x0F +#define RDS_CARRIAGE_RETURN 0x0D + +#define rds_ps_nblocks (len) ((len / RDS_BLOCK) + (len % RDS_BLOCK ? 1 : 0)) +#define enable_rds (p) (p | (1 << 2)) +#define disable_rds (p) (p & ~(1 << 2)) +#define get_rds_status (p) ((p >> 2) & 0x01) + +#define enable_stereo (p) (p | (1 << 1)) +#define disable_stereo (p) (p & ~(1 << 1)) +#define get_stereo_status (p) ((p >> 1) & 0x01) + +#define enable_limiter (p) (p | (1 << 1)) +#define disable_limiter (p) (p & ~(1 << 1)) +#define get_limiter_status (p) ((p >> 1) & 0x01) + +#define enable_pilot (p) (p | (1 << 0)) +#define disable_pilot (p) (p & ~(1 << 0)) +#define get_pilot_status (p) ((p >> 0) & 0x01) + +#define enable_acomp (p) (p | (1 << 0)) +#define disable_acomp (p) (p & ~(1 << 0)) +#define get_acomp_status (p) ((p >> 0) & 0x01) +#define ATTACK_TIME_UNIT 500 + +#define DEFAULT_RDS_PI 0x00 +#define DEFAULT_RDS_PTY 0x00 +#define DEFAULT_RDS_PS_NAME "Si4713 " +#define DEFAULT_RDS_RADIO_TEXT DEFAULT_RDS_PS_NAME +#define DEFAULT_RDS_DEVIATION 0x00C8 +#define DEFAULT_RDS_PS_REPEAT_COUNT 0x0003 +#define DEFAULT_LIMITER_RTIME 0x1392 +#define DEFAULT_LIMITER_DEV 0x102CA +#define DEFAULT_PILOT_FREQUENCY 0x4A38 +#define DEFAULT_PILOT_DEVIATION 0x1A5E +#define DEFAULT_ACOMP_ATIME 0x0000 +#define DEFAULT_ACOMP_RTIME 0xF4240L +#define DEFAULT_ACOMP_GAIN 0x0F +#define DEFAULT_ACOMP_THRESHOLD (-0x28) +#define DEFAULT_REGION_SETTINGS 0x02 +#define DEFAULT_MUTE 0x00 +#define DEFAULT_POWER_LEVEL 88 +#define DEFAULT_TUNE_RSSI 0xFF + +#define POWER_OFF 0x00 +#define POWER_ON 0x01 + +#define msb (x) ((u8)((u16) x >> 8)) +#define lsb (x) ((u8)((u16) x & 0x00FF)) +#define compose_u16 (msb, lsb) (((u16)msb << 8) | lsb) +#define check_command_failed (status) (!(status & SI4713_CTS) || \ + (status & SI4713_ERR)) +/* mute definition */ +#define set_mute (p) ((p & 1) | ((p & 1) << 1)); +#define get_mute (p) (p & 0x01) +#define set_pty (v, pty) ((v & 0xFC1F) | (pty << 5)) +#define get_pty (v) ((v >> 5) & 0x1F) + + +#ifdef DEBUG +#define DBG_BUFFER (device, message, buffer, size) \ + { \ + int i; \ + char str[(size)*5]; \ + for (i = 0; i < size; i++) \ + sprintf(str + i * 5, " 0x%02x", buffer[i]); \ + dev_dbg(device, "%s:%s\n", message, str); \ + } +#else +#define DBG_BUFFER (device, message, buffer, size) +#endif + +/* +* Values for limiter release time +* device release +* value time (us) +*/ +static unsigned long const limiter_times[] = { +2000 ,250 , +1000 ,500 , +510 ,1000 , +255 ,2000 , +170 ,3000 , +127 ,4020 , +102 ,5010 , +85 ,6020 , +73 ,7010 , +64 ,7990 , +57 ,8970 , +51 ,10030 , +25 ,20470 , +17 ,30110 , +13 ,39380 , +10 ,51190 , +8 ,63690 , +7 ,73140 , +6 ,85330 , +5 ,102390 , +}; + +/* +* Values for audio compression release time +* device release +* value time (us) +*/ +static unsigned long const acomp_rtimes[] = { +0 ,100000 , +1 ,200000 , +2 ,350000 , +3 ,525000 , +4 ,1000000 , +}; + +/* +* Values for region specific configurations +* (spacing, bottom and top frequencies, preemphasis) +*/ +static struct region_info region_configs[] = { +/* USA */ + { + .channel_spacing =20 , + .bottom_frequency =8750 , + .top_frequency =10800 , + .preemphasis =0 , + .region =0 , + }, +/* Australia */ + { + .channel_spacing =20 , + .bottom_frequency =8750 , + .top_frequency =10800 , + .preemphasis =1 , + .region =1 , + }, +/* Europe */ + { + .channel_spacing =10 , + .bottom_frequency =8750 , + .top_frequency =10800 , + .preemphasis =1 , + .region =2 , + }, +/* Japan */ + { + .channel_spacing =10 , + .bottom_frequency =7600 , + .top_frequency =9000 , + .preemphasis =1 , + .region =3 , + }, +/* Japan wide band */ + { + .channel_spacing =10 , + .bottom_frequency =7600 , + .top_frequency =10800 , + .preemphasis =1 , + .region =4 , + }, +}; + +static int usecs_to_dev (unsigned long usecs,unsigned long const array[], +int size) +{ +int i; +int rval = -EINVAL ; + +for (i =0 ; i < size /2 ; i++) +if (array[(i *2 ) +1 ] >= usecs) { + rval = array[i *2 ]; +break ; + } + +return rval; +} + +static unsigned long dev_to_usecs (int value,unsigned long const array[], +int size) +{ +int i; +int rval = -EINVAL ; + +for (i =0 ; i < size /2 ; i++) +if (array[i *2 ] == value) { + rval = array[(i *2 ) +1 ]; +break ; + } + +return rval; +} + +/* +* si4713_send_command - sends a command to si4713 and waits its response +* @sdev: si4713_device structure for the device we are communicating +* @command: command id +* @args: command arguments we are sending (up to 7) +* @argn: actual size of @args +* @response: buffer to place the expected response from the device (up to 15) +* @respn: actual size of @response +* @usecs: amount of time to wait before reading the response (in usecs) +*/ +static int si4713_send_command (struct si4713_device *sdev,const u8 command, +const u8 args[],const int argn, +u8 response[],const int respn,const int usecs) +{ +struct i2c_client *client = sdev->client; +u8 data1[MAX_ARGS +1 ]; +int err; + +if (!client->adapter) +return -ENODEV ; + +/* First send the command and its arguments */ + data1[0 ] = command; +memcpy (data1 +1 , args, argn); +DBG_BUFFER (&client->dev,"Parameters" , data1, argn +1 ); + + err =i2c_master_send (client, data1, argn +1 ); +if (err != argn +1 ) { +dev_err (&client->dev,"Error while sending command 0x%02x\n" , + command); +return (err >0 ) ? -EIO : err; + } + +/* Wait response from interrupt */ +if (!wait_for_completion_timeout (&sdev->work, +usecs_to_jiffies (usecs) +1 )) +dev_dbg (&client->dev,"Device took too much time.\n" ); + +/* Then get the response */ + err =i2c_master_recv (client, response, respn); +if (err != respn) { +dev_err (&client->dev, +"Error while reading response for command 0x%02x\n" , + command); +return (err >0 ) ? -EIO : err; + } + +DBG_BUFFER (&client->dev,"Response" , response, respn); +if (check_command_failed (response[0 ])) +return -EBUSY ; + +return 0 ; +} + +/* +* si4713_read_property - reads a si4713 property +* @sdev: si4713_device structure for the device we are communicating +* @prop: property identification number +*/ +static int si4713_read_property (struct si4713_device *sdev,u16 prop) +{ +int err; +u8 val[SI4713_GET_PROP_NRESP ]; +/* +* REVISIT: From Programming Manual +* .First byte = 0 +* .Second byte = property's MSB +* .Third byte = property's LSB +*/ +const u8 args[SI4713_GET_PROP_NARGS ] = { +0x00 , +msb (prop), +lsb (prop), + }; + + err =si4713_send_command (sdev,SI4713_CMD_GET_PROPERTY , + args,ARRAY_SIZE (args), val, +ARRAY_SIZE (val),DEFAULT_TIMEOUT ); + +if (err <0 ) +return err; + +dev_dbg (&sdev->client->dev,"Status from read prop: 0x%02x\n" , val[0 ]); + +return compose_u16 (val[2 ], val[3 ]); +} + +/* +* si4713_write_property - modifies a si4713 property +* @sdev: si4713_device structure for the device we are communicating +* @prop: property identification number +* @val: new value for that property +*/ +static int si4713_write_property (struct si4713_device *sdev,u16 prop,u16 val) +{ +int rval; +u8 resp[SI4713_SET_PROP_NRESP ]; +/* +* REVISIT: From Programming Manual +* .First byte = 0 +* .Second byte = property's MSB +* .Third byte = property's LSB +* .Fourth byte = value's MSB +* .Fifth byte = value's LSB +*/ +const u8 args[SI4713_SET_PROP_NARGS ] = { +0x00 , +msb (prop), +lsb (prop), +msb (val), +lsb (val), + }; + + rval =si4713_send_command (sdev,SI4713_CMD_SET_PROPERTY , + args,ARRAY_SIZE (args), + resp,ARRAY_SIZE (resp), +DEFAULT_TIMEOUT ); + +if (rval <0 ) +return rval; + +dev_dbg (&sdev->client->dev,"Status from write prop: 0x%02x\n" , + resp[0 ]); + +/* +* As there is no command response for SET_PROPERTY, +* wait Tcomp time to finish before proceed, in order +* to have property properly set. +*/ +msleep (TIMEOUT_SET_PROPERTY ); + +return rval; +} + +/* +* si4713_powerup - Powers the device up +* @sdev: si4713_device structure for the device we are communicating +*/ +static int si4713_powerup (struct si4713_device *sdev) +{ +int err; +u8 resp[SI4713_PWUP_NRESP ]; +/* +* REVISIT: From Programming Manual +* .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 , +SI4713_PWUP_OPMOD_ANALOG , + }; + +if (sdev->power_state) +return 0 ; + + sdev->platform_data->set_power (1 ); + err =si4713_send_command (sdev,SI4713_CMD_POWER_UP , + args,ARRAY_SIZE (args), + resp,ARRAY_SIZE (resp), +TIMEOUT_POWER_UP ); + +if (!err) { +dev_dbg (&sdev->client->dev,"Powerup response: 0x%02x\n" , + resp[0 ]); +dev_dbg (&sdev->client->dev,"Device in power up mode\n" ); + sdev->power_state =POWER_ON ; + + err =si4713_write_property (sdev,SI4713_GPO_IEN , +SI4713_STC_INT |SI4713_CTS ); + }else { + sdev->platform_data->set_power (0 ); + } + +return err; +} + +/* +* si4713_powerdown - Powers the device down +* @sdev: si4713_device structure for the device we are communicating +*/ +static int si4713_powerdown (struct si4713_device *sdev) +{ +int err; +u8 resp[SI4713_PWDN_NRESP ]; + +if (!sdev->power_state) +return 0 ; + + err =si4713_send_command (sdev,SI4713_CMD_POWER_DOWN , +NULL ,0 , + resp,ARRAY_SIZE (resp), +DEFAULT_TIMEOUT ); + +if (!err) { +dev_dbg (&sdev->client->dev,"Power down response: 0x%02x\n" , + resp[0 ]); +dev_dbg (&sdev->client->dev,"Device in reset mode\n" ); + sdev->platform_data->set_power (0 ); + sdev->power_state =POWER_OFF ; + } + +return err; +} + +/* +* si4713_checkrev - Checks if we are treating a device with the correct rev. +* @sdev: si4713_device structure for the device we are communicating +*/ +#define pr_revision (devicep, buffer) \ + dev_info(devicep, "Detected %s (0x%02x) Firmware: %d.%d" \ + " Patch ID: %02x:%02x Component: %d.%d" \ + " Chip Rev.: %s\n", \ + buffer[1] == SI4713_PRODUCT_NUMBER ? "Si4713" : "",\ + buffer[1], \ + buffer[2] & 0xF, buffer[3] & 0xF, \ + buffer[4], buffer[5], \ + buffer[6] & 0xF, buffer[7] & 0xF, \ + buffer[8] == 0x41 ? "revA" : "unknown") +static int si4713_checkrev (struct si4713_device *sdev) +{ +int rval; +u8 resp[SI4713_GETREV_NRESP ]; + +mutex_lock (&sdev->mutex); + + rval =si4713_send_command (sdev,SI4713_CMD_GET_REV , +NULL ,0 , + resp,ARRAY_SIZE (resp), +DEFAULT_TIMEOUT ); + +if (rval <0 ) + goto unlock; + +if (resp[1 ] ==SI4713_PRODUCT_NUMBER ) { +pr_revision (&sdev->client->dev, resp); + }else { +dev_err (&sdev->client->dev,"Invalid product number\n" ); + rval = -EINVAL ; + } + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +/* +* si4713_wait_stc - Waits STC interrupt and clears status bits. Usefull +* for TX_TUNE_POWER, TX_TUNE_FREQ and TX_TUNE_MEAS +* @sdev: si4713_device structure for the device we are communicating +* @usecs: timeout to wait for STC interrupt signal +*/ +static int si4713_wait_stc (struct si4713_device *sdev,const int usecs) +{ +int err; +u8 resp[SI4713_GET_STATUS_NRESP ]; + +/* Wait response from STC interrupt */ +if (!wait_for_completion_timeout (&sdev->work, +usecs_to_jiffies (TIMEOUT_TX_TUNE ) +1 )) +dev_dbg (&sdev->client->dev,"Device took too much time.\n" ); + +/* 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; + +dev_dbg (&sdev->client->dev,"Status bits: 0x%02x\n" , resp[0 ]); + +if (!(resp[0 ] &SI4713_STC_INT )) + err = -EIO ; + +exit: +return err; +} + +/* +* si4713_tx_tune_freq - Sets the state of the RF carrier and sets the tuning +* frequency between 76 and 108 MHz in 10 kHz units and +* steps of 50 kHz. +* @sdev: si4713_device structure for the device we are communicating +* @frequency: desired frequency (76 - 108 MHz, unit 10 KHz, step 50 kHz) +*/ +static int si4713_tx_tune_freq (struct si4713_device *sdev,u16 frequency) +{ +int err; +u8 val[SI4713_TXFREQ_NRESP ]; +/* +* REVISIT: From Programming Manual +* .First byte = 0 +* .Second byte = frequency's MSB +* .Third byte = frequency's LSB +*/ +const u8 args[SI4713_TXFREQ_NARGS ] = { +0x00 , +msb (frequency), +lsb ((frequency - + (frequency % sdev->region_info.channel_spacing))), + }; + +if (frequency < sdev->region_info.bottom_frequency || + frequency > sdev->region_info.top_frequency) +return -EDOM ; + + err =si4713_send_command (sdev,SI4713_CMD_TX_TUNE_FREQ , + args,ARRAY_SIZE (args), val, +ARRAY_SIZE (val),DEFAULT_TIMEOUT ); + +if (err <0 ) +return err; + +dev_dbg (&sdev->client->dev,"Status from tx tune freq: 0x%02x\n" , + val[0 ]); + + err =si4713_wait_stc (sdev,TIMEOUT_TX_TUNE ); +if (err <0 ) +return err; + +return compose_u16 (args[1 ], args[2 ]); +} + +/* +* si4713_tx_tune_power - Sets the RF voltage level between 88 and 115 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) +* @antcap: value of antenna tuning capacitor (0 - 191) +*/ +static int si4713_tx_tune_power (struct si4713_device *sdev,u8 power, +u8 antcap) +{ +int err; +u8 val[SI4713_TXPWR_NRESP ]; +/* +* REVISIT: From Programming Manual +* .First byte = 0 +* .Second byte = 0 +* .Third byte = power +* .Fourth byte = antcap +*/ +const 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 ; + + err =si4713_send_command (sdev,SI4713_CMD_TX_TUNE_POWER , + args,ARRAY_SIZE (args), val, +ARRAY_SIZE (val),DEFAULT_TIMEOUT ); + +if (err <0 ) +return err; + +dev_dbg (&sdev->client->dev,"Status from tx tune power: 0x%02x\n" , + val[0 ]); + +return si4713_wait_stc (sdev,TIMEOUT_TX_TUNE_POWER ); +} + +/* +* si4713_tx_tune_measure - Enters receive mode and measures the received noise +* level in units of dBuV on the selected frequency. +* The Frequency must be between 76 and 108 MHz in 10 kHz +* units and steps of 50 kHz. The command also sets the +* antenna tuning capacitance. A value of 0 means +* autotuning, and a value of 1 to 191 indicates manual +* override. +* @sdev: si4713_device structure for the device we are communicating +* @frequency: desired frequency (76 - 108 MHz, unit 10 KHz, step 50 kHz) +* @antcap: value of antenna tuning capacitor (0 - 191) +*/ +static int si4713_tx_tune_measure (struct si4713_device *sdev,u16 frequency, +u8 antcap) +{ +int err; +u8 val[SI4713_TXMEA_NRESP ]; +/* +* REVISIT: From Programming Manual +* .First byte = 0 +* .Second byte = frequency's MSB +* .Third byte = frequency's LSB +* .Fourth byte = antcap +*/ +const u8 args[SI4713_TXMEA_NARGS ] = { +0x00 , +msb (frequency), +lsb ((frequency - + (frequency % sdev->region_info.channel_spacing))), + antcap, + }; + + sdev->tune_rssi =DEFAULT_TUNE_RSSI ; + +if (frequency < sdev->region_info.bottom_frequency || + frequency > sdev->region_info.top_frequency || + antcap >SI4713_MAX_ANTCAP ) +return -EDOM ; + + err =si4713_send_command (sdev,SI4713_CMD_TX_TUNE_MEASURE , + args,ARRAY_SIZE (args), val, +ARRAY_SIZE (val),DEFAULT_TIMEOUT ); + +if (err <0 ) +return err; + +dev_dbg (&sdev->client->dev,"Status from tx tune measure: 0x%02x\n" , + val[0 ]); + +return si4713_wait_stc (sdev,TIMEOUT_TX_TUNE ); +} + +/* +* si4713_tx_tune_status- Returns the status of the tx_tune_freq, tx_tune_mea or +* tx_tune_power commands. This command return the current +* frequency, output voltage in dBuV, the antenna tunning +* capacitance value and the received noise level. The +* command also clears the stcint interrupt bit when the +* first bit of its arguments is high. +* @sdev: si4713_device structure for the device we are communicating +* @intack: 0x01 to clear the seek/tune complete interrupt status indicator. +* @frequency: returned frequency +* @power: returned power +* @antcap: returned antenna capacitance +* @noise: returned noise level +*/ +static int si4713_tx_tune_status (struct si4713_device *sdev,u8 intack, +u16 *frequency,u8 *power, +u8 *antcap,u8 *noise) +{ +int err; +u8 val[SI4713_TXSTATUS_NRESP ]; +/* +* REVISIT: From Programming Manual +* .First byte = intack bit +*/ +const u8 args[SI4713_TXSTATUS_NARGS ] = { + intack &SI4713_INTACK_MASK , + }; + + err =si4713_send_command (sdev,SI4713_CMD_TX_TUNE_STATUS , + args,ARRAY_SIZE (args), val, +ARRAY_SIZE (val),DEFAULT_TIMEOUT ); + +if (!err) { +dev_dbg (&sdev->client->dev, +"Status from tx tune status: 0x%02x\n" , val[0 ]); + *frequency =compose_u16 (val[2 ], val[3 ]); + sdev->frequency = *frequency; + *power = val[5 ]; + *antcap = val[6 ]; + *noise = val[7 ]; +dev_dbg (&sdev->client->dev,"Tune status: %d x 10 kHz " +"(power %d, antcap %d, rnl %d)\n" , + *frequency, *power, *antcap, *noise); + } + +return err; +} + +/* +* si4713_tx_rds_buff - Loads the RDS group buffer FIFO or circular buffer. +* @sdev: si4713_device structure for the device we are communicating +* @mode: the buffer operation mode. +* @rdsb: RDS Block B +* @rdsc: RDS Block C +* @rdsd: RDS Block D +* @intstatus: returns current interrupt status +* @cbavail: returns the number of available circular buffer blocks. +* @cbused: returns the number of used circular buffer blocks. +* @fifoavail: returns the number of available fifo buffer blocks. +* @fifoused: returns the number of used fifo buffer blocks. +*/ +static int si4713_tx_rds_buff (struct si4713_device *sdev,u8 mode,u16 rdsb, +u16 rdsc,u16 rdsd,u8 *intstatus,u8 *cbavail, +u8 *cbused,u8 *fifoavail,u8 *fifoused) +{ +int err; +u8 val[SI4713_RDSBUFF_NRESP ]; + +const u8 args[SI4713_RDSBUFF_NARGS ] = { + mode &SI4713_RDSBUFF_MODE_MASK , +msb (rdsb), +lsb (rdsb), +msb (rdsc), +lsb (rdsc), +msb (rdsd), +lsb (rdsd), + }; + + err =si4713_send_command (sdev,SI4713_CMD_TX_RDS_BUFF , + args,ARRAY_SIZE (args), val, +ARRAY_SIZE (val),DEFAULT_TIMEOUT ); + +if (!err) { +dev_dbg (&sdev->client->dev, +"Status from tx rds buff: 0x%02x\n" , val[0 ]); + *intstatus = val[1 ]; + *cbavail = val[2 ]; + *cbused = val[3 ]; + *fifoavail = val[4 ]; + *fifoused = val[5 ]; +dev_dbg (&sdev->client->dev,"rds buffer status: interrupts" +" 0x%02x cb avail: %d cb used %d fifo avail" +" %d fifo used %d\n" , *intstatus, *cbavail, + *cbused, *fifoavail, *fifoused); + } + +return err; +} + +/* +* si4713_tx_rds_ps - Loads the program service buffer. +* @sdev: si4713_device structure for the device we are communicating +* @psid: program service id to be loaded. +* @pschar: assumed 4 size char array to be loaded into the program service +*/ +static int si4713_tx_rds_ps (struct si4713_device *sdev,u8 psid, +unsigned char *pschar) +{ +int err; +u8 val[SI4713_RDSPS_NRESP ]; + +const u8 args[SI4713_RDSPS_NARGS ] = { + psid &SI4713_RDSPS_PSID_MASK , + pschar[0 ], + pschar[1 ], + pschar[2 ], + pschar[3 ], + }; + + err =si4713_send_command (sdev,SI4713_CMD_TX_RDS_PS , + args,ARRAY_SIZE (args), val, +ARRAY_SIZE (val),DEFAULT_TIMEOUT ); + +if (err <0 ) +return err; + +dev_dbg (&sdev->client->dev,"Status from tx rds ps: 0x%02x\n" , + val[0 ]); + +return err; +} + +/* +* si4713_init - Sets the device up with default configuration. +* @sdev: si4713_device structure for the device we are communicating +*/ +int si4713_init (struct si4713_device *sdev) +{ +int rval; + + rval =si4713_set_rds_pi (sdev,DEFAULT_RDS_PI ); +if (rval <0 ) + goto exit; + + rval =si4713_set_rds_pty (sdev,DEFAULT_RDS_PTY ); +if (rval <0 ) + goto exit; + + rval =si4713_set_rds_ps_name (sdev,DEFAULT_RDS_PS_NAME ); +if (rval <0 ) + goto exit; + + rval =si4713_set_rds_radio_text (sdev,DEFAULT_RDS_RADIO_TEXT ); +if (rval <0 ) + goto exit; + + rval =si4713_set_rds_enabled (sdev,1 ); +if (rval <0 ) + goto exit; + + rval =si4713_set_limiter_release_time (sdev,DEFAULT_LIMITER_RTIME ); +if (rval <0 ) + goto exit; + + rval =si4713_set_limiter_deviation (sdev,DEFAULT_LIMITER_DEV ); +if (rval <0 ) + goto exit; + + rval =si4713_set_limiter_enabled (sdev,1 ); +if (rval <0 ) + goto exit; + + rval =si4713_set_pilot_frequency (sdev,DEFAULT_PILOT_FREQUENCY ); +if (rval <0 ) + goto exit; + + rval =si4713_set_pilot_deviation (sdev,DEFAULT_PILOT_DEVIATION ); +if (rval <0 ) + goto exit; + + rval =si4713_set_pilot_enabled (sdev,1 ); +if (rval <0 ) + goto exit; + + rval =si4713_set_stereo_enabled (sdev,1 ); +if (rval <0 ) + goto exit; + + rval =si4713_set_acomp_attack_time (sdev,DEFAULT_ACOMP_ATIME ); +if (rval <0 ) + goto exit; + + rval =si4713_set_acomp_release_time (sdev,DEFAULT_ACOMP_RTIME ); +if (rval <0 ) + goto exit; + + rval =si4713_set_acomp_gain (sdev,DEFAULT_ACOMP_GAIN ); +if (rval <0 ) + goto exit; + + rval =si4713_set_acomp_threshold (sdev,DEFAULT_ACOMP_THRESHOLD ); +if (rval <0 ) + goto exit; + + rval =si4713_set_acomp_enabled (sdev,1 ); +if (rval <0 ) + goto exit; + + rval =si4713_set_region (sdev,DEFAULT_REGION_SETTINGS ); +if (rval <0 ) + goto exit; + + rval =si4713_set_mute (sdev,DEFAULT_MUTE ); +if (rval <0 ) + goto exit; + +exit: +return rval; +} + +/* +* si4713_setup - Sets the device up with current configuration. +* @sdev: si4713_device structure for the device we are communicating +*/ +int si4713_setup (struct si4713_device *sdev) +{ +struct si4713_device *tmp; +int rval; + + tmp =kmalloc (sizeof (*tmp),GFP_KERNEL ); +if (!tmp) +return -ENOMEM ; + +/* Get a local copy to avoid race */ +mutex_lock (&sdev->mutex); +memcpy (tmp, sdev,sizeof (*sdev)); +mutex_unlock (&sdev->mutex); + + rval =si4713_set_rds_pi (sdev, tmp->rds_info.pi); +if (rval <0 ) + goto exit; + + rval =si4713_set_rds_pty (sdev, tmp->rds_info.pty); +if (rval <0 ) + goto exit; + + rval =si4713_set_rds_ps_name (sdev, tmp->rds_info.ps_name); +if (rval <0 ) + goto exit; + + rval =si4713_set_rds_radio_text (sdev, tmp->rds_info.radio_text); +if (rval <0 ) + goto exit; + + rval =si4713_set_rds_enabled (sdev, tmp->rds_info.enabled); +if (rval <0 ) + goto exit; + + rval =si4713_set_limiter_release_time (sdev, + tmp->limiter_info.release_time); +if (rval <0 ) + goto exit; + + rval =si4713_set_limiter_deviation (sdev, tmp->limiter_info.deviation); +if (rval <0 ) + goto exit; + + rval =si4713_set_limiter_enabled (sdev, tmp->limiter_info.enabled); +if (rval <0 ) + goto exit; + + rval =si4713_set_region (sdev, tmp->region_info.region); +if (rval <0 ) + goto exit; + + rval =si4713_set_pilot_frequency (sdev, tmp->pilot_info.frequency); +if (rval <0 ) + goto exit; + + rval =si4713_set_pilot_deviation (sdev, tmp->pilot_info.deviation); +if (rval <0 ) + goto exit; + + rval =si4713_set_pilot_enabled (sdev, tmp->pilot_info.enabled); +if (rval <0 ) + goto exit; + + rval =si4713_set_stereo_enabled (sdev, tmp->stereo); +if (rval <0 ) + goto exit; + + rval =si4713_set_acomp_attack_time (sdev, tmp->acomp_info.attack_time); +if (rval <0 ) + goto exit; + + rval =si4713_set_acomp_release_time (sdev, + tmp->acomp_info.release_time); +if (rval <0 ) + goto exit; + + rval =si4713_set_acomp_gain (sdev, tmp->acomp_info.gain); +if (rval <0 ) + goto exit; + + rval =si4713_set_acomp_threshold (sdev, tmp->acomp_info.threshold); +if (rval <0 ) + goto exit; + + rval =si4713_set_acomp_enabled (sdev, tmp->acomp_info.enabled); +if (rval <0 ) + goto exit; + + rval =si4713_set_mute (sdev, tmp->mute); +if (rval <0 ) + goto exit; + + rval =si4713_set_frequency (sdev, tmp->frequency ? tmp->frequency : + tmp->region_info.bottom_frequency); +if (rval <0 ) + goto exit; + + rval =si4713_set_power_level (sdev, tmp->power_level ? + tmp->power_level : +DEFAULT_POWER_LEVEL ); +if (rval <0 ) + goto exit; + + rval =si4713_set_antenna_capacitor (sdev, tmp->antenna_capacitor); + +exit: +kfree (tmp); +return rval; +} + +int si4713_set_power_level (struct si4713_device *sdev,u8 power_level) +{ +int rval; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_tx_tune_power (sdev, power_level, + sdev->antenna_capacitor); + +if (rval <0 ) + goto unlock; + } + + sdev->power_level = power_level; + rval =0 ; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_get_power_level (struct si4713_device *sdev) +{ +int rval; +u16 f =0 ; +u8 p, a, n; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_tx_tune_status (sdev,0x00 , &f, &p, &a, &n); + +if (rval <0 ) + goto unlock; + + sdev->power_level = p; + } + + rval = sdev->power_level; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_set_antenna_capacitor (struct si4713_device *sdev,u8 value) +{ +int rval =0 ; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) + rval =si4713_tx_tune_power (sdev, sdev->power_level, value); + +if (!rval) + sdev->antenna_capacitor = value; + +mutex_unlock (&sdev->mutex); + +return rval; +} + +int si4713_get_antenna_capacitor (struct si4713_device *sdev) +{ +int rval = -EINVAL ; +u16 f =0 ; +u8 p, a, n; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_tx_tune_status (sdev,0x00 , &f, &p, &a, &n); + +if (rval <0 ) + goto unlock; + + rval = a; + } + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_set_power_state (struct si4713_device *sdev,u8 value) +{ +int rval; + +mutex_lock (&sdev->mutex); + +if (value) + rval =si4713_powerup (sdev); +else + rval =si4713_powerdown (sdev); + +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_probe (struct si4713_device *sdev) +{ +int rval; + + rval =si4713_set_power_state (sdev,POWER_ON ); +if (rval <0 ) + goto exit; + + rval =si4713_checkrev (sdev); +if (rval <0 ) + goto exit; + + rval =si4713_init (sdev); +if (rval <0 ) + goto exit; + + rval =si4713_set_power_state (sdev,POWER_OFF ); + +exit: +return rval; +} + +int si4713_set_frequency (struct si4713_device *sdev,u16 frequency) +{ +int rval =0 ; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_tx_tune_freq (sdev, frequency); +if (rval <0 ) + goto unlock; + sdev->frequency = rval; + }else { + rval = -ENODEV ; + } + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_get_frequency (struct si4713_device *sdev) +{ +int rval; +u16 f =0 ; +u8 p, a, n; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_tx_tune_status (sdev,0x00 , &f, &p, &a, &n); + +if (rval <0 ) + goto unlock; + + sdev->frequency = f; + } + + rval = sdev->frequency; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_set_mute (struct si4713_device *sdev,u16 mute) +{ +int rval =0 ; + + mute =set_mute (mute); + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) + rval =si4713_write_property (sdev, +SI4713_TX_LINE_INPUT_MUTE , mute); + +if (rval >=0 ) + sdev->mute =get_mute (mute); + +mutex_unlock (&sdev->mutex); + +return rval; +} + +int si4713_get_mute (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_LINE_INPUT_MUTE ); + +if (rval <0 ) + goto unlock; + + sdev->mute = rval; + } + + rval =get_mute (sdev->mute); + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_set_rds_pi (struct si4713_device *sdev,u16 pi) +{ +int rval =0 ; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) + rval =si4713_write_property (sdev,SI4713_TX_RDS_PI , pi); + +if (rval >=0 ) + sdev->rds_info.pi = pi; + +mutex_unlock (&sdev->mutex); + +return rval; +} + +int si4713_get_rds_pi (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_RDS_PI ); + +if (rval <0 ) + goto unlock; + + sdev->rds_info.pi = rval; + } + + rval = sdev->rds_info.pi; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_set_rds_pty (struct si4713_device *sdev,u8 pty) +{ +int rval =0 ; +u16 p; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_RDS_PS_MISC ); +if (rval <0 ) + goto unlock; + + p =set_pty (rval, pty); + + rval =si4713_write_property (sdev,SI4713_TX_RDS_PS_MISC , p); +if (rval <0 ) + goto unlock; + } + + sdev->rds_info.pty = pty; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_get_rds_pty (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_RDS_PS_MISC ); + +if (rval <0 ) + goto unlock; + + sdev->rds_info.pty =get_pty (rval); + } + + rval = sdev->rds_info.pty; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_set_rds_ps_name (struct si4713_device *sdev,char *ps_name) +{ +int rval =0 , i; +u8 len =0 ; +u8 *tmp; + +if (!strlen (ps_name)) +return -EINVAL ; + + tmp =kzalloc (MAX_RDS_PS_NAME +1 ,GFP_KERNEL ); +if (!tmp) +return -ENOMEM ; + +strncpy (tmp, ps_name,MAX_RDS_PS_NAME ); + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { +/* Write the new ps name and clear the padding */ +for (i =0 ; i <MAX_RDS_PS_NAME ; i += (RDS_BLOCK /2 )) { + rval =si4713_tx_rds_ps (sdev, (i / (RDS_BLOCK /2 )), + tmp + i); +if (rval <0 ) + goto unlock; + } + +/* Setup the size to be sent */ + len =strlen (tmp) -1 ; + + rval =si4713_write_property (sdev, +SI4713_TX_RDS_PS_MESSAGE_COUNT , +rds_ps_nblocks (len)); +if (rval <0 ) + goto unlock; + + rval =si4713_write_property (sdev, +SI4713_TX_RDS_PS_REPEAT_COUNT , +DEFAULT_RDS_PS_REPEAT_COUNT *2 ); +if (rval <0 ) + goto unlock; + } + +strncpy (sdev->rds_info.ps_name, tmp,MAX_RDS_PS_NAME ); + +unlock: +mutex_unlock (&sdev->mutex); +kfree (tmp); +return rval; +} + +int si4713_get_rds_ps_name (struct si4713_device *sdev,char *ps_name) +{ +mutex_lock (&sdev->mutex); +strncpy (ps_name, sdev->rds_info.ps_name,MAX_RDS_PS_NAME ); +mutex_unlock (&sdev->mutex); + +return 0 ; +} + +int si4713_set_rds_radio_text (struct si4713_device *sdev,char *radio_text) +{ +int rval =0 , i; +u16 t_index =0 ; +u8 s, a, u, fa, fu, b_index =0 , cr_inserted =0 ; +u8 *tmp; + +if (!strlen (radio_text)) +return -EINVAL ; + + tmp =kzalloc (MAX_RDS_RADIO_TEXT +1 ,GFP_KERNEL ); +if (!tmp) +return -ENOMEM ; + +strncpy (tmp, radio_text,MAX_RDS_RADIO_TEXT ); + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_tx_rds_buff (sdev,RDS_BLOCK_CLEAR ,0 ,0 ,0 , + &s, &a, &u, &fa, &fu); +if (rval <0 ) + goto unlock; +do { +/* RDS spec says that if the last block isn't used, +* then apply a carriage return +*/ +if (t_index < (RDS_RADIOTEXT_INDEX_MAX * \ +RDS_RADIOTEXT_BLK_SIZE )) { +for (i =0 ; i <RDS_RADIOTEXT_BLK_SIZE ; i++) { +if (!tmp[t_index + i] || + tmp[t_index + i] == \ +RDS_CARRIAGE_RETURN ) { + tmp[t_index + i] = +RDS_CARRIAGE_RETURN ; + cr_inserted =1 ; +break ; + } + } + } + + rval =si4713_tx_rds_buff (sdev,RDS_BLOCK_LOAD , +compose_u16 (RDS_RADIOTEXT_2A , + b_index++), +compose_u16 (tmp[t_index], + tmp[t_index +1 ]), +compose_u16 (tmp[t_index +2 ], + tmp[t_index +3 ]), + &s, &a, &u, &fa, &fu); +if (rval <0 ) + goto unlock; + + t_index +=RDS_RADIOTEXT_BLK_SIZE ; + +if (cr_inserted) +break ; + }while (u < a); + } + +strncpy (sdev->rds_info.radio_text, tmp,MAX_RDS_RADIO_TEXT ); + +unlock: +mutex_unlock (&sdev->mutex); +kfree (tmp); +return rval; +} + +int si4713_get_rds_radio_text (struct si4713_device *sdev,char *radio_text) +{ +mutex_lock (&sdev->mutex); +strncpy (radio_text, sdev->rds_info.radio_text,MAX_RDS_RADIO_TEXT ); +mutex_unlock (&sdev->mutex); + +return 0 ; +} + +int si4713_set_rds_enabled (struct si4713_device *sdev,u8 enabled) +{ +int rval =0 ; +u16 p; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_COMPONENT_ENABLE ); +if (rval <0 ) + goto unlock; + + p = rval; +if (enabled) + p =enable_rds (p); +else + p =disable_rds (p); + + rval =si4713_write_property (sdev,SI4713_TX_COMPONENT_ENABLE , + p); +if (rval <0 ) + goto unlock; + +if (enabled) { + rval =si4713_write_property (sdev, +SI4713_TX_RDS_DEVIATION , +DEFAULT_RDS_DEVIATION ); +if (rval <0 ) + goto unlock; + } + } + + sdev->rds_info.enabled = enabled &0x01 ; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_get_rds_enabled (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_COMPONENT_ENABLE ); +if (rval <0 ) + goto unlock; + + sdev->rds_info.enabled =get_rds_status (rval); + } + + rval = sdev->rds_info.enabled; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_get_region_bottom_frequency (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); +/* Device works in 10kHz units */ + rval = sdev->region_info.bottom_frequency *10 ; +mutex_unlock (&sdev->mutex); + +return rval; +} + +int si4713_get_region_top_frequency (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); +/* Device works in 10kHz units */ + rval = sdev->region_info.top_frequency *10 ; +mutex_unlock (&sdev->mutex); + +return rval; +} + +int si4713_set_region_preemphasis (struct si4713_device *sdev,u8 preemphasis) +{ +int rval =0 ; + +switch (preemphasis) { +case PREEMPHASIS_USA : + preemphasis =FMPE_USA ; +break ; +case PREEMPHASIS_EU : + preemphasis =FMPE_EU ; +break ; +case PREEMPHASIS_DISABLED : + preemphasis =FMPE_DISABLED ; +break ; +default : +return -EINVAL ; + } + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) + rval =si4713_write_property (sdev,SI4713_TX_PREEMPHASIS , + preemphasis); + +if (rval >=0 ) + sdev->region_info.preemphasis = preemphasis; + +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_get_region_preemphasis (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_PREEMPHASIS ); + +if (rval <0 ) + goto unlock; + + sdev->region_info.preemphasis = rval; + } + +switch (sdev->region_info.preemphasis) { +case FMPE_USA : + rval =PREEMPHASIS_USA ; +break ; +case FMPE_EU : + rval =PREEMPHASIS_EU ; +break ; +case FMPE_DISABLED : + rval =PREEMPHASIS_DISABLED ; +break ; +default : + rval = -EINVAL ; + goto unlock; + } + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_get_region_channel_spacing (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); +/* Device works in 10kHz units */ + rval = sdev->region_info.channel_spacing *10 ; +mutex_unlock (&sdev->mutex); + +return rval; +} + +int si4713_set_region (struct si4713_device *sdev,u8 region) +{ +int rval =0 ; +u16 new_frequency =0 ; + +if (region >ARRAY_SIZE (region_configs)) +return -EINVAL ; + +mutex_lock (&sdev->mutex); + +if (sdev->frequency < region_configs[region].bottom_frequency || + sdev->frequency > region_configs[region].top_frequency) + new_frequency = region_configs[region].bottom_frequency; + +memcpy (&sdev->region_info, ®ion_configs[region], +sizeof (sdev->region_info)); + +if (sdev->power_state) { +if (new_frequency >0 ) { + rval =si4713_tx_tune_freq (sdev, new_frequency); + +if (rval <0 ) + goto unlock; + + new_frequency = rval; + } + + rval =si4713_write_property (sdev,SI4713_TX_PREEMPHASIS , + region_configs[region].preemphasis); +if (rval <0 ) + goto unlock; + } + + sdev->frequency = new_frequency; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_get_region (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); + rval = sdev->region_info.region; +mutex_unlock (&sdev->mutex); + +return rval; +} + +int si4713_set_limiter_enabled (struct si4713_device *sdev,u8 enabled) +{ +int rval =0 ; +u16 p; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_ACOMP_ENABLE ); +if (rval <0 ) + goto unlock; + + p = rval; +if (enabled) + p =enable_limiter (p); +else + p =disable_limiter (p); + + rval =si4713_write_property (sdev,SI4713_TX_ACOMP_ENABLE , + p); + +if (rval <0 ) + goto unlock; + } + + sdev->limiter_info.enabled = enabled &0x01 ; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_get_limiter_enabled (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_ACOMP_ENABLE ); +if (rval <0 ) + goto unlock; + + sdev->limiter_info.enabled =get_limiter_status (rval); + } + + rval = sdev->limiter_info.enabled; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_set_limiter_deviation (struct si4713_device *sdev, +unsigned long deviation) +{ +int rval =0 ; + +/* Device receives in 10Hz units */ + deviation /=10 ; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) + rval =si4713_write_property (sdev,SI4713_TX_AUDIO_DEVIATION , + deviation); + +/* Device returns in 10Hz units */ +if (rval >=0 ) + sdev->limiter_info.deviation = deviation *10 ; + +mutex_unlock (&sdev->mutex); + +return rval; +} + +long si4713_get_limiter_deviation (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_AUDIO_DEVIATION ); + +if (rval <0 ) + goto unlock; + +/* Device returns in 10Hz units */ + sdev->limiter_info.deviation = rval *10 ; + } + + rval = sdev->limiter_info.deviation; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_set_limiter_release_time (struct si4713_device *sdev, +unsigned long rtime) +{ +int rval; + + rval =usecs_to_dev (rtime, limiter_times,ARRAY_SIZE (limiter_times)); +if (rval <0 ) + goto exit; + + rtime = rval; + rval =0 ; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) + rval =si4713_write_property (sdev, +SI4713_TX_LIMITER_RELEASE_TIME , rtime); + +if (rval >=0 ) + sdev->limiter_info.release_time =dev_to_usecs (rtime, + limiter_times, +ARRAY_SIZE (limiter_times)); + +mutex_unlock (&sdev->mutex); + +exit: +return rval; +} + +long si4713_get_limiter_release_time (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev, +SI4713_TX_LIMITER_RELEASE_TIME ); + +if (rval <0 ) + goto unlock; + + sdev->limiter_info.release_time =dev_to_usecs (rval, + limiter_times, +ARRAY_SIZE (limiter_times)); + } + + rval = sdev->limiter_info.release_time; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_set_stereo_enabled (struct si4713_device *sdev,u8 enabled) +{ +int rval =0 ; +u16 p; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_COMPONENT_ENABLE ); +if (rval <0 ) + goto unlock; + + p = rval; +if (enabled) + p =enable_stereo (p); +else + p =disable_stereo (p); + + rval =si4713_write_property (sdev,SI4713_TX_COMPONENT_ENABLE , + p); + +if (rval <0 ) + goto unlock; + } + + sdev->stereo = enabled &0x01 ; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_get_stereo_enabled (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_COMPONENT_ENABLE ); +if (rval <0 ) + goto unlock; + + sdev->stereo =get_stereo_status (rval); + } + + rval = sdev->stereo; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_set_pilot_enabled (struct si4713_device *sdev,u8 enabled) +{ +int rval =0 ; +u16 p; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_COMPONENT_ENABLE ); +if (rval <0 ) + goto unlock; + + p = rval; +if (enabled) + p =enable_pilot (p); +else + p =disable_pilot (p); + + rval =si4713_write_property (sdev,SI4713_TX_COMPONENT_ENABLE , + p); + +if (rval <0 ) + goto unlock; + } + + sdev->pilot_info.enabled = enabled &0x01 ; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_get_pilot_enabled (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_COMPONENT_ENABLE ); +if (rval <0 ) + goto unlock; + + sdev->pilot_info.enabled =get_pilot_status (rval); + } + + rval = sdev->pilot_info.enabled; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_set_pilot_deviation (struct si4713_device *sdev, +unsigned long deviation) +{ +int rval =0 ; + +/* Device receives in 10Hz units */ + deviation /=10 ; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) + rval =si4713_write_property (sdev,SI4713_TX_PILOT_DEVIATION , + deviation); + +/* Device returns in 10Hz units */ +if (rval >=0 ) + sdev->pilot_info.deviation = deviation *10 ; + +mutex_unlock (&sdev->mutex); + +return rval; +} + +long si4713_get_pilot_deviation (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_PILOT_DEVIATION ); + +if (rval <0 ) + goto unlock; + +/* Device returns in 10Hz units */ + sdev->pilot_info.deviation = rval *10 ; + } + + rval = sdev->pilot_info.deviation; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_set_pilot_frequency (struct si4713_device *sdev,u16 freq) +{ +int rval =0 ; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) + rval =si4713_write_property (sdev,SI4713_TX_PILOT_FREQUENCY , + freq); + +if (rval >=0 ) + sdev->pilot_info.frequency = freq; + +mutex_unlock (&sdev->mutex); + +return rval; +} + +int si4713_get_pilot_frequency (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_PILOT_FREQUENCY ); + +if (rval <0 ) + goto unlock; + + sdev->pilot_info.frequency = rval; + } + + rval = sdev->pilot_info.frequency; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_set_acomp_enabled (struct si4713_device *sdev,u8 enabled) +{ +int rval =0 ; +u16 p; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_ACOMP_ENABLE ); +if (rval <0 ) + goto unlock; + + p = rval; +if (enabled) + p =enable_acomp (p); +else + p =disable_acomp (p); + + rval =si4713_write_property (sdev,SI4713_TX_ACOMP_ENABLE , p); + +if (rval <0 ) + goto unlock; + } + + sdev->acomp_info.enabled = enabled &0x01 ; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_get_acomp_enabled (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_ACOMP_ENABLE ); +if (rval <0 ) + goto unlock; + + sdev->acomp_info.enabled =get_acomp_status (rval); + } + + rval = sdev->acomp_info.enabled; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_set_acomp_gain (struct si4713_device *sdev,u8 gain) +{ +int rval =0 ; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) + rval =si4713_write_property (sdev,SI4713_TX_ACOMP_GAIN , gain); + +if (rval >=0 ) + sdev->acomp_info.gain = gain; + +mutex_unlock (&sdev->mutex); + +return rval; +} + +int si4713_get_acomp_gain (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_ACOMP_GAIN ); + +if (rval <0 ) + goto unlock; + + sdev->acomp_info.gain = rval; + } + + rval = sdev->acomp_info.gain; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_set_acomp_threshold (struct si4713_device *sdev,s8 threshold) +{ +int rval =0 ; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) + rval =si4713_write_property (sdev,SI4713_TX_ACOMP_THRESHOLD , + threshold); + +if (rval >=0 ) + sdev->acomp_info.threshold = threshold; + +mutex_unlock (&sdev->mutex); + +return rval; +} + +int si4713_get_acomp_threshold (struct si4713_device *sdev,s8 *threshold) +{ +int rval; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev,SI4713_TX_ACOMP_THRESHOLD ); + +if (rval <0 ) + goto unlock; + + sdev->acomp_info.threshold = rval; + } + + *threshold = sdev->acomp_info.threshold; + rval =0 ; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_set_acomp_release_time (struct si4713_device *sdev, +unsigned long rtime) +{ +int rval; + + rval =usecs_to_dev (rtime, acomp_rtimes,ARRAY_SIZE (acomp_rtimes)); +if (rval <0 ) + goto exit; + + rtime = rval; + rval =0 ; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) + rval =si4713_write_property (sdev, +SI4713_TX_ACOMP_RELEASE_TIME , rtime); + +if (rval >=0 ) + sdev->acomp_info.release_time =dev_to_usecs (rtime, + acomp_rtimes, +ARRAY_SIZE (acomp_rtimes)); + +mutex_unlock (&sdev->mutex); + +exit: +return rval; +} + +long si4713_get_acomp_release_time (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev, +SI4713_TX_ACOMP_RELEASE_TIME ); + +if (rval <0 ) + goto unlock; + + sdev->acomp_info.release_time =dev_to_usecs (rval, + acomp_rtimes, +ARRAY_SIZE (acomp_rtimes)); + } + + rval = sdev->acomp_info.release_time; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + + +int si4713_set_acomp_attack_time (struct si4713_device *sdev,u16 atime) +{ +int rval =0 ; + +/* Device receives in 0.5 ms units */ + atime /=ATTACK_TIME_UNIT ; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) + rval =si4713_write_property (sdev, +SI4713_TX_ACOMP_ATTACK_TIME , atime); + +if (rval >=0 ) + sdev->acomp_info.attack_time = atime *ATTACK_TIME_UNIT ; + +mutex_unlock (&sdev->mutex); + +return rval; +} + +int si4713_get_acomp_attack_time (struct si4713_device *sdev) +{ +int rval; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_read_property (sdev, +SI4713_TX_ACOMP_RELEASE_TIME ); + +if (rval <0 ) + goto unlock; + + sdev->acomp_info.release_time = rval *ATTACK_TIME_UNIT ; + } + + rval = sdev->acomp_info.attack_time; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +} + +int si4713_set_tune_measure (struct si4713_device *sdev,u32 frequency) +{ +int rval = -ENODEV ; + +mutex_lock (&sdev->mutex); +if (sdev->power_state) + rval =si4713_tx_tune_measure (sdev, frequency /10 ,0 ); +mutex_unlock (&sdev->mutex); + +return rval; +} + +int si4713_get_tune_measure (struct si4713_device *sdev) +{ +int rval; +u16 f =0 ; +u8 p, a, n; + +mutex_lock (&sdev->mutex); + +if (sdev->power_state) { + rval =si4713_tx_tune_status (sdev,0x00 , &f, &p, &a, &n); + +if (rval <0 ) + goto unlock; + + sdev->tune_rssi = n; + } + + rval = sdev->tune_rssi; + +unlock: +mutex_unlock (&sdev->mutex); +return rval; +}
drivers/media/radio/si4713.h new file +294 -0
294 lines not on this page · raw message
Signature · 1 line
1.6.2.GIT
PATCH 2/3 FMTx: si4713: Add files to add radio interface for si4713
This patch adds files which creates the radio interface for si4713 FM transmitter devices.
--- drivers/media/radio/radio-si4713.c | 834 ++++++++++++++++++++++++++++++++++++ drivers/media/radio/radio-si4713.h | 32 ++ 2 files changed, 866 insertions(+), 0 deletions(-) create mode 100644 drivers/media/radio/radio-si4713.c create mode 100644 drivers/media/radio/radio-si4713.h
drivers/media/radio/radio-si4713.c new file +834 -0
@@ -0,0 +1,834 @@ +/* +* drivers/media/radio/radio-si4713.c +* +* Driver for I2C Silicon Labs Si4713 FM Radio Transmitter: +* +* Copyright (c) 2008 Instituto Nokia de Tecnologia - INdT +* Author: Eduardo Valentin <[email protected]> +* +* 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_AUTHOR "Eduardo Valentin <[email protected]>" +#define DRIVER_NAME SI4713_NAME +#define DRIVER_VERSION KERNEL_VERSION(0, 0, 1) +#define DRIVER_CARD "Silicon Labs Si4713 FM Radio Transmitter" +#define DRIVER_DESC "I2C driver for Si4713 FM Radio Transmitter" + +/* frequency domain transformation (using times 10 to avoid floats) */ +#define FREQDEV_UNIT 100000 +#define FREQV4L2_MULTI 625 +#define dev_to_v4l2 (f) ((f * FREQDEV_UNIT) / FREQV4L2_MULTI) +#define v4l2_to_dev (f) ((f * FREQV4L2_MULTI) / FREQDEV_UNIT) + +/* kernel includes */ +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/version.h> +#include <linux/interrupt.h> +#include <linux/sysfs.h> +#include <linux/completion.h> +#include <linux/delay.h> +#include <linux/i2c.h> +#include <linux/videodev2.h> +#include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> + +#include "radio-si4713.h" +#include "si4713.h" + +/* module parameters */ +static int radio_nr =-1 ;/* radio device minor (-1 ==> auto assign) */ + +/* +* Sysfs properties +* Read and write functions +*/ +#define property_write (prop, type, mask, check) \ +static ssize_t si4713_##prop##_write(struct device *dev, \ + struct device_attribute *attr, \ + const char *buf, \ + size_t count) \ +{ \ + struct si4713_device *sdev = dev_get_drvdata(dev); \ + type value; \ + int rval; \ + \ + if (!sdev) \ + return -ENODEV; \ + \ + sscanf(buf, mask, &value); \ + \ + if (check) \ + return -EDOM; \ + \ + rval = si4713_set_##prop(sdev, value); \ + \ + return rval < 0 ? rval : count; \ +} + +#define property_read (prop, size, mask) \ +static ssize_t si4713_##prop##_read(struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ +{ \ + struct si4713_device *sdev = dev_get_drvdata(dev); \ + size value; \ + \ + if (!sdev) \ + return -ENODEV; \ + \ + value = si4713_get_##prop(sdev); \ + \ + if (value >= 0) \ + value = sprintf(buf, mask "\n", value); \ + \ + return value; \ +} + +#define DEFINE_SYSFS_PROPERTY (prop, signal, size, mask, check) \ +property_write(prop, signal size, mask, check) \ +property_read(prop, size, mask) \ +static DEVICE_ATTR(prop, S_IRUGO | S_IWUSR, si4713_##prop##_read, \ + si4713_##prop##_write); +#define DEFINE_SYSFS_PROPERTY_RO (prop, signal, size, mask) \ +property_read(prop, size, mask) \ +static DEVICE_ATTR(prop, S_IRUGO, si4713_##prop##_read, NULL); + + +#define property_str_write (prop, size) \ +static ssize_t si4713_##prop##_write(struct device *dev, \ + struct device_attribute *attr, \ + const char *buf, \ + size_t count) \ +{ \ + struct si4713_device *sdev = dev_get_drvdata(dev); \ + int rval; \ + u8 *in; \ + \ + if (!sdev) \ + return -ENODEV; \ + \ + in = kzalloc(size + 1, GFP_KERNEL); \ + if (!in) \ + return -ENOMEM; \ + \ +/* We don't want to miss the spaces */ \ +strncpy (in, buf, size); \ + rval = si4713_set_##prop(sdev, in); \ + \ + kfree(in); \ + \ + return rval < 0 ? rval : count; \ +} + +#define property_str_read (prop, size) \ +static ssize_t si4713_##prop##_read(struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ +{ \ + struct si4713_device *sdev = dev_get_drvdata(dev); \ + int count; \ + u8 *out; \ + \ + if (!sdev) \ + return -ENODEV; \ + \ + out = kzalloc(size + 1, GFP_KERNEL); \ + if (!out) \ + return -ENOMEM; \ + \ + si4713_get_##prop(sdev, out); \ + count = sprintf(buf, "%s\n", out); \ + \ + kfree(out); \ + \ + return count; \ +} + +#define DEFINE_SYSFS_PROPERTY_STR (prop, size) \ +property_str_write(prop, size) \ +property_str_read(prop, size) \ +static DEVICE_ATTR(prop, S_IRUGO | S_IWUSR, si4713_##prop##_read, \ + si4713_##prop##_write); + +/* +* Power level property +*/ +/* power_level (rw) 88 - 115 or 0 */ +static ssize_t si4713_power_level_write (struct device *dev, +struct device_attribute *attr, +const char *buf, +size_t count) +{ +struct si4713_device *sdev =dev_get_drvdata (dev); +unsigned int p; +int rval, pl; + +if (!sdev) { + rval = -ENODEV ; + goto exit; + } + +sscanf (buf,"%u" , &p); + + pl =si4713_get_power_level (sdev); +if (pl <0 ) { + rval = pl; + goto exit; + } + + rval =si4713_set_power_level (sdev, p); + +exit: +return rval <0 ? rval : count; +} +property_read(power_level, unsigned int, "%u") +static DEVICE_ATTR(power_level, S_IRUGO | S_IWUSR, si4713_power_level_read, + si4713_power_level_write); + +DEFINE_SYSFS_PROPERTY (antenna_capacitor, unsigned, int,"%u" , + value >SI4713_MAX_ANTCAP ) +/* +* RDS properties +*/ +/* rds_pi (rw) 0 - 0xFFFF */ +DEFINE_SYSFS_PROPERTY (rds_pi, unsigned, int,"%x" ,0 ) +/* rds_pty (rw) 0 - 0x1F */ +DEFINE_SYSFS_PROPERTY (rds_pty, unsigned, int,"%u" , value >MAX_RDS_PTY ) +/* rds_enabled (rw) 0 - 1 */ +DEFINE_SYSFS_PROPERTY (rds_enabled, unsigned, int,"%u" ,0 ) +/* rds_ps_name (rw) strlen (8 - 96) */ +DEFINE_SYSFS_PROPERTY_STR (rds_ps_name,MAX_RDS_PS_NAME ) +/* rds_radio_text (rw) strlen (0 - 384) */ +DEFINE_SYSFS_PROPERTY_STR (rds_radio_text,MAX_RDS_RADIO_TEXT ) + +/* +* Limiter properties +*/ +/* limiter_release_time (rw) 0 - 102390 */ +DEFINE_SYSFS_PROPERTY (limiter_release_time, unsigned, long,"%lu" , + value >MAX_LIMITER_RELEASE_TIME ) +/* limiter_deviation (rw) 0 - 90000 */ +DEFINE_SYSFS_PROPERTY (limiter_deviation, unsigned, long,"%lu" , + value >MAX_LIMITER_DEVIATION ) +/* limiter_enabled (rw) 0 - 1 */ +DEFINE_SYSFS_PROPERTY (limiter_enabled, unsigned, int,"%u" ,0 ) + +/* +* Pilot tone properties +*/ +/* pilot_frequency (rw) 0 - 19000 */ +DEFINE_SYSFS_PROPERTY (pilot_frequency, unsigned, int,"%u" , + value >MAX_PILOT_FREQUENCY ) +/* pilot_deviation (rw) 0 - 90000 */ +DEFINE_SYSFS_PROPERTY (pilot_deviation, unsigned, long,"%lu" , + value >MAX_PILOT_DEVIATION ) +/* pilot_enabled (rw) 0 - 1 */ +DEFINE_SYSFS_PROPERTY (pilot_enabled, unsigned, int,"%u" ,0 ) + +/* +* Stereo properties +*/ +/* stereo_enabled (rw) 0 - 1 */ +DEFINE_SYSFS_PROPERTY (stereo_enabled, unsigned, int,"%u" ,0 ) + +/* +* Audio Compression properties +*/ +/* acomp_release_time (rw) 0 - 1000000 */ +DEFINE_SYSFS_PROPERTY (acomp_release_time, unsigned, long,"%lu" , + value >MAX_ACOMP_RELEASE_TIME ) +/* acomp_attack_time (rw) 0 - 5000 */ +DEFINE_SYSFS_PROPERTY (acomp_attack_time, unsigned, int,"%u" , + value >MAX_ACOMP_ATTACK_TIME ) +/* acomp_threshold (rw) -40 - 0 */ +property_write (acomp_threshold, int,"%d" , + value >MAX_ACOMP_THRESHOLD || + value < MIN_ACOMP_THRESHOLD) + +static ssize_t si4713_acomp_threshold_read (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct si4713_device *sdev =dev_get_drvdata (dev); +int count; +s8 thres; + +if (!sdev) +return -ENODEV ; + + count =si4713_get_acomp_threshold (sdev, &thres); + +if (count >=0 ) + count =sprintf (buf,"%d\n" , thres); + +return count; +} +static DEVICE_ATTR(acomp_threshold, S_IRUGO | S_IWUSR, + si4713_acomp_threshold_read, + si4713_acomp_threshold_write); + +/* acomp_gain (rw) 0 - 20 */ +DEFINE_SYSFS_PROPERTY (acomp_gain, unsigned, int,"%u" , value >MAX_ACOMP_GAIN ) +/* acomp_enabled (rw) 0 - 1 */ +DEFINE_SYSFS_PROPERTY (acomp_enabled, unsigned, int,"%u" ,0 ) + +/* Tune_measure (rw) */ +DEFINE_SYSFS_PROPERTY (tune_measure, unsigned, int,"%u" ,0 ) + +/* +* Region properties + */ +DEFINE_SYSFS_PROPERTY_RO(region_bottom_frequency, unsigned, int, "%u") +DEFINE_SYSFS_PROPERTY_RO(region_top_frequency, unsigned, int, "%u") +DEFINE_SYSFS_PROPERTY_RO(region_channel_spacing, unsigned, int, "%u") +DEFINE_SYSFS_PROPERTY (region_preemphasis, unsigned, int,"%u" , + ((value !=PREEMPHASIS_USA ) && + (value !=PREEMPHASIS_EU ) && + (value != PREEMPHASIS_DISABLED))) +DEFINE_SYSFS_PROPERTY(region, unsigned, int, "%u", 0) + +static struct attribute *attrs[] = { + &dev_attr_power_level.attr, + &dev_attr_antenna_capacitor.attr, + &dev_attr_rds_pi.attr, + &dev_attr_rds_pty.attr, + &dev_attr_rds_ps_name.attr, + &dev_attr_rds_radio_text.attr, + &dev_attr_rds_enabled.attr, + &dev_attr_limiter_release_time.attr, + &dev_attr_limiter_deviation.attr, + &dev_attr_limiter_enabled.attr, + &dev_attr_pilot_frequency.attr, + &dev_attr_pilot_deviation.attr, + &dev_attr_pilot_enabled.attr, + &dev_attr_stereo_enabled.attr, + &dev_attr_acomp_release_time.attr, + &dev_attr_acomp_attack_time.attr, + &dev_attr_acomp_threshold.attr, + &dev_attr_acomp_gain.attr, + &dev_attr_acomp_enabled.attr, + &dev_attr_region_bottom_frequency.attr, + &dev_attr_region_top_frequency.attr, + &dev_attr_region_preemphasis.attr, + &dev_attr_region_channel_spacing.attr, + &dev_attr_region.attr, + &dev_attr_tune_measure.attr, +NULL , +}; + +static const struct attribute_group attr_group = { + .attrs = attrs, +}; + +static irqreturn_t si4713_handler (int irq,void *dev) +{ +struct si4713_device *sdev = dev; + +dev_dbg (&sdev->client->dev,"IRQ called, signaling completion work\n" ); +complete (&sdev->work); + +return IRQ_HANDLED ; +} + +/* +* si4713_fops - file operations interface +*/ +static const struct v4l2_file_operations si4713_fops = { + .owner =THIS_MODULE , + .ioctl = video_ioctl2, +}; + +/* +* Video4Linux Interface +*/ +/* +* si4713_v4l2_queryctrl - query control +*/ +static struct v4l2_queryctrl si4713_v4l2_queryctrl[] = { +/* HINT: the disabled controls are only here to satify kradio and such apps */ + { + .id =V4L2_CID_AUDIO_VOLUME , + .flags =V4L2_CTRL_FLAG_DISABLED , + }, + { + .id =V4L2_CID_AUDIO_BALANCE , + .flags =V4L2_CTRL_FLAG_DISABLED , + }, + { + .id =V4L2_CID_AUDIO_BASS , + .flags =V4L2_CTRL_FLAG_DISABLED , + }, + { + .id =V4L2_CID_AUDIO_TREBLE , + .flags =V4L2_CTRL_FLAG_DISABLED , + }, + { + .id =V4L2_CID_AUDIO_MUTE , + .type =V4L2_CTRL_TYPE_BOOLEAN , + .name ="Mute" , + .minimum =0 , + .maximum =1 , + .step =1 , + .default_value =1 , + }, + { + .id =V4L2_CID_AUDIO_LOUDNESS , + .flags =V4L2_CTRL_FLAG_DISABLED , + }, +}; + +/* +* si4713_vidioc_querycap - query device capabilities +*/ +static int si4713_vidioc_querycap (struct file *file,void *priv, +struct v4l2_capability *capability) +{ +struct si4713_device *sdev =video_get_drvdata (video_devdata (file)); + +strlcpy (capability->driver,DRIVER_NAME ,sizeof (capability->driver)); +strlcpy (capability->card,DRIVER_CARD ,sizeof (capability->card)); +snprintf (capability->bus_info,32 ,"I2C: 0x%X" , sdev->client->addr); + capability->version =DRIVER_VERSION ; + capability->capabilities =V4L2_CAP_TUNER ; + +return 0 ; +} + +/* +* si4713_vidioc_g_input - get input +*/ +static int si4713_vidioc_g_input (struct file *filp,void *priv, +unsigned int *i) +{ + *i =0 ; + +return 0 ; +} + +/* +* si4713_vidioc_s_input - set input +*/ +static int si4713_vidioc_s_input (struct file *filp,void *priv,unsigned int i) +{ +if (i) +return -EINVAL ; + +return 0 ; +} + +/* +* si4713_vidioc_queryctrl - enumerate control items +*/ +static int si4713_vidioc_queryctrl (struct file *file,void *priv, +struct v4l2_queryctrl *qc) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (si4713_v4l2_queryctrl); i++) { +if (qc->id && qc->id == si4713_v4l2_queryctrl[i].id) { +memcpy (qc, &(si4713_v4l2_queryctrl[i]),sizeof (*qc)); +return 0 ; + } + } + +return -EINVAL ; +} + +/* +* si4713_vidioc_g_ctrl - get the value of a control +*/ +static int si4713_vidioc_g_ctrl (struct file *file,void *priv, +struct v4l2_control *ctrl) +{ +struct si4713_device *sdev =video_get_drvdata (video_devdata (file)); +int rval =0 ; + +if (!sdev) +return -ENODEV ; + +switch (ctrl->id) { +case V4L2_CID_AUDIO_MUTE : + rval =si4713_get_mute (sdev); +if (rval >=0 ) + ctrl->value = rval; +break ; + } + +return rval; +} + +/* +* si4713_vidioc_s_ctrl - set the value of a control +*/ +static int si4713_vidioc_s_ctrl (struct file *file,void *priv, +struct v4l2_control *ctrl) +{ +struct si4713_device *sdev =video_get_drvdata (video_devdata (file)); +int rval =0 ; + +if (!sdev) +return -ENODEV ; + +switch (ctrl->id) { +case V4L2_CID_AUDIO_MUTE : +if (ctrl->value) { + rval =si4713_set_mute (sdev, ctrl->value); +if (rval <0 ) + goto exit; + + rval =si4713_set_power_state (sdev,POWER_DOWN ); + }else { + rval =si4713_set_power_state (sdev,POWER_UP ); +if (rval <0 ) + goto exit; + + rval =si4713_setup (sdev); +if (rval <0 ) + goto exit; + + rval =si4713_set_mute (sdev, ctrl->value); + } +break ; + } + +exit: +return rval; +} + +/* +* si4713_vidioc_g_audio - get audio attributes +*/ +static int si4713_vidioc_g_audio (struct file *file,void *priv, +struct v4l2_audio *audio) +{ +if (audio->index >1 ) +return -EINVAL ; + +strncpy (audio->name,"Radio" ,32 ); + audio->capability =V4L2_AUDCAP_STEREO ; + +return 0 ; +} + +/* +* si4713_vidioc_s_audio - set audio attributes +*/ +static int si4713_vidioc_s_audio (struct file *file,void *priv, +struct v4l2_audio *audio) +{ +if (audio->index !=0 ) +return -EINVAL ; + +return 0 ; +} + +/* +* si4713_vidioc_g_tuner - get tuner attributes +*/ +static int si4713_vidioc_g_tuner (struct file *file,void *priv, +struct v4l2_tuner *tuner) +{ +struct si4713_device *sdev =video_get_drvdata (video_devdata (file)); + +if (!sdev) +return -ENODEV ; + +if (tuner->index >0 ) +return -EINVAL ; + +strncpy (tuner->name,"FM Transmitter" ,32 ); + tuner->type =V4L2_TUNER_RADIO ; + tuner->rangelow = +dev_to_v4l2 (si4713_get_region_bottom_frequency (sdev) /10 ); + tuner->rangehigh = +dev_to_v4l2 (si4713_get_region_top_frequency (sdev) /10 ); + tuner->rxsubchans =V4L2_TUNER_SUB_STEREO ; + tuner->capability =V4L2_TUNER_CAP_STEREO |V4L2_TUNER_CAP_LOW ; + tuner->audmode =V4L2_TUNER_MODE_STEREO ; + +/* automatic frequency control: -1: freq to low, 1 freq to high */ + tuner->afc =0 ; + +return 0 ; +} + +/* +* si4713_vidioc_s_tuner - set tuner attributes +*/ +static int si4713_vidioc_s_tuner (struct file *file,void *priv, +struct v4l2_tuner *tuner) +{ +struct si4713_device *sdev =video_get_drvdata (video_devdata (file)); + +if (!sdev) +return -ENODEV ; + +if (tuner->index >0 ) +return -EINVAL ; + +return 0 ; +} + +/* +* si4713_vidioc_g_frequency - get tuner or modulator radio frequency +*/ +static int si4713_vidioc_g_frequency (struct file *file,void *priv, +struct v4l2_frequency *freq) +{ +struct si4713_device *sdev =video_get_drvdata (video_devdata (file)); +int rval =0 ; +int f; + + freq->type =V4L2_TUNER_RADIO ; + f =si4713_get_frequency (sdev); + +if (f <0 ) + rval = f; +else + freq->frequency =dev_to_v4l2 (f); + +return rval; +} + +/* +* si4713_vidioc_s_frequency - set tuner or modulator radio frequency +*/ +static int si4713_vidioc_s_frequency (struct file *file,void *priv, +struct v4l2_frequency *freq) +{ +struct si4713_device *sdev =video_get_drvdata (video_devdata (file)); +int rval =0 ; + +if (freq->type !=V4L2_TUNER_RADIO ) { + rval = -EINVAL ; + goto exit; + } + + rval =si4713_set_frequency (sdev,v4l2_to_dev (freq->frequency)); + +exit: +return rval; +} + +static struct v4l2_ioctl_ops si4713_ioctl_ops = { + .vidioc_querycap = si4713_vidioc_querycap, + .vidioc_g_input = si4713_vidioc_g_input, + .vidioc_s_input = si4713_vidioc_s_input, + .vidioc_queryctrl = si4713_vidioc_queryctrl, + .vidioc_g_ctrl = si4713_vidioc_g_ctrl, + .vidioc_s_ctrl = si4713_vidioc_s_ctrl, + .vidioc_g_audio = si4713_vidioc_g_audio, + .vidioc_s_audio = si4713_vidioc_s_audio, + .vidioc_g_tuner = si4713_vidioc_g_tuner, + .vidioc_s_tuner = si4713_vidioc_s_tuner, + .vidioc_g_frequency = si4713_vidioc_g_frequency, + .vidioc_s_frequency = si4713_vidioc_s_frequency, +}; + +/* +* si4713_viddev_tamples - video device interface +*/ +static struct video_device si4713_viddev_template = { + .fops = &si4713_fops, + .name =DRIVER_NAME , + .release = video_device_release, + .ioctl_ops = &si4713_ioctl_ops, +}; + +/* +* I2C driver interface +*/ +/* +* si4713_i2c_driver_probe - probe for the device +*/ +static int si4713_i2c_driver_probe (struct i2c_client *client, +const struct i2c_device_id *id) +{ +struct si4713_device *sdev; +int rval, skip_release =0 ; + + sdev =kzalloc (sizeof *sdev,GFP_KERNEL ); +if (!sdev) { +dev_dbg (&client->dev,"Failed to alloc video device.\n" ); + rval = -ENOMEM ; + goto exit; + } + + sdev->videodev =video_device_alloc (); +if (!sdev->videodev) { +dev_dbg (&client->dev,"Failed to alloc video device.\n" ); + rval = -ENOMEM ; + goto free_sdev; + } + + sdev->platform_data = client->dev.platform_data; +if (!sdev->platform_data) { +dev_dbg (&client->dev,"No platform data registered.\n" ); + rval = -ENODEV ; + goto free_vdev; + } + + sdev->client = client; +i2c_set_clientdata (client, sdev); + +mutex_init (&sdev->mutex); +init_completion (&sdev->work); + +if (client->irq) { + rval =request_irq (client->irq, + si4713_handler,IRQF_TRIGGER_FALLING |IRQF_DISABLED , + client->name, sdev); +if (rval <0 ) { +dev_err (&client->dev,"Could not request IRQ\n" ); + goto free_vdev; + } +dev_dbg (&client->dev,"IRQ requested.\n" ); + }else { +dev_dbg (&client->dev,"IRQ not configure. Using timeouts.\n" ); + } + +memcpy (sdev->videodev, &si4713_viddev_template, +sizeof (si4713_viddev_template)); +video_set_drvdata (sdev->videodev, sdev); +if (video_register_device (sdev->videodev,VFL_TYPE_RADIO , radio_nr)) { +dev_dbg (&client->dev,"Could not register video device.\n" ); + rval = -EIO ; + goto free_irq; + } + + rval =sysfs_create_group (&sdev->client->dev.kobj, &attr_group); +if (rval <0 ) { +dev_dbg (&client->dev,"Could not register sysfs interface.\n" ); + goto free_registration; + } + + rval =si4713_probe (sdev); +if (rval <0 ) { +dev_dbg (&client->dev,"Failed to probe device information.\n" ); + goto free_sysfs; + } + +return 0 ; + +free_sysfs: +sysfs_remove_group (&sdev->client->dev.kobj, &attr_group); +free_registration: +video_unregister_device (sdev->videodev); + skip_release =1 ; +free_irq: +if (client->irq) +free_irq (client->irq, sdev); +free_vdev: +if (!skip_release) +video_device_release (sdev->videodev); +free_sdev: +kfree (sdev); +exit: +return rval; +} + +/* +* si4713_i2c_driver_remove - remove the device +*/ +static int __exit si4713_i2c_driver_remove(struct i2c_client *client) +{ +struct si4713_device *sdev =i2c_get_clientdata (client); +struct video_device *vd; + +/* our client isn't attached */ +if (!client->adapter) +return -ENODEV ; + +if (sdev) { + vd = sdev->videodev; + +sysfs_remove_group (&sdev->client->dev.kobj, &attr_group); + +if (vd) +video_unregister_device (vd); + +if (sdev->power_state) +si4713_set_power_state (sdev,POWER_DOWN ); + +if (client->irq >0 ) +free_irq (client->irq, sdev); + +kfree (sdev); + } +i2c_set_clientdata (client,NULL ); + +return 0 ; +} + +/* +* si4713_i2c_driver - i2c driver interface +*/ +static const struct i2c_device_id si4713_id[] = { + {"si4713" ,0 }, + { }, +}; +MODULE_DEVICE_TABLE (i2c, si4713_id); + +static struct i2c_driver si4713_i2c_driver = { + .driver = { + .name =DRIVER_NAME , + }, + .probe = si4713_i2c_driver_probe, + .remove =__exit_p (si4713_i2c_driver_remove), + .id_table = si4713_id, +}; + +/* +* Module Interface +*/ +/* +* si4713_module_init - module init +*/ +static int __init si4713_module_init (void ) +{ +int rval; + + printk(KERN_INFO DRIVER_DESC "\n"); + + rval =i2c_add_driver (&si4713_i2c_driver); +if (rval <0 ) + printk(KERN_ERR DRIVER_NAME ": driver registration failed\n"); + +return rval; +} + +/* +* si4713_module_exit - module exit +*/ +static void __exit si4713_module_exit(void) +{ +i2c_del_driver (&si4713_i2c_driver); +} + +module_init (si4713_module_init); +module_exit (si4713_module_exit); + +module_param (radio_nr, int,0 ); +MODULE_PARM_DESC (radio_nr, +"Minor number for radio device (-1 ==> auto assign)" ); + +MODULE_LICENSE ("GPL" ); +MODULE_AUTHOR (DRIVER_AUTHOR ); +MODULE_DESCRIPTION (DRIVER_DESC ); +MODULE_VERSION ("0.0.1" );
drivers/media/radio/radio-si4713.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* drivers/media/radio/radio-si4713.h +* +* Property and commands definitions for Si4713 radio transmitter chip. +* +* Copyright (c) 2008 Instituto Nokia de Tecnologia - INdT +* Author: Eduardo Valentin <[email protected]> +* +* This file is licensed under the terms of the GNU General Public License +* version 2. This program is licensed "as is" without any warranty of any +* kind, whether express or implied. +* +*/ + +#ifndef RADIO_SI4713_H +#define RADIO_SI4713_H + +#define SI4713_NAME "radio-si4713" + +/* The SI4713 I2C sensor chip has a fixed slave address of 0xc6. */ +#define SI4713_I2C_ADDR_BUSEN_HIGH 0x63 +#define SI4713_I2C_ADDR_BUSEN_LOW 0x11 + +/* +* Platform dependent definition +*/ +struct si4713_platform_data { +/* Set power state, zero is off, non-zero is on. */ +int (*set_power)(int power); +}; + +#endif /* ifndef RADIO_SI4713_H*/
Signature · 1 line
1.6.2.GIT
PATCH 3/3 FMTx: si4713: Add Kconfig and Makefile entries
--- drivers/media/radio/Kconfig | 12 ++++++++++++ drivers/media/radio/Makefile | 2 ++ 2 files changed, 14 insertions(+), 0 deletions(-)
drivers/media/radio/Kconfig +12 -0
@@ -339,6 +339,18 @@ config RADIO_ZOLTRIX_PORT help Enter the I/O port of your Zoltrix radio card. +config I2C_SI4713 + tristate "Silicon Labs Si4713 FM Radio Transmitter support" + depends on I2C && VIDEO_V4L2 + ---help--- + Say Y here if you want support to Si4713 FM Radio Transmitter. + This device can transmit audio through FM. It can transmit + EDS and EBDS signals as well. This device driver supports only + i2c bus. + + To compile this driver as a module, choose M here: the + module will be called fmtx-si4713. + config USB_DSBR tristate "D-Link/GemTek USB FM radio support" depends on USB && VIDEO_V4L2
drivers/media/radio/Makefile +2 -0
@@ -15,6 +15,8 @@ obj-$(CONFIG_RADIO_ZOLTRIX) += radio-zoltrix.o obj-$(CONFIG_RADIO_GEMTEK) += radio-gemtek.o obj-$(CONFIG_RADIO_GEMTEK_PCI) += radio-gemtek-pci.o obj-$(CONFIG_RADIO_TRUST) += radio-trust.o +obj-$(CONFIG_I2C_SI4713) += fmtx-si4713.o +fmtx-si4713-objs := radio-si4713.o si4713.o obj-$(CONFIG_RADIO_MAESTRO) += radio-maestro.o obj-$(CONFIG_USB_DSBR) += dsbr100.o obj-$(CONFIG_USB_SI470X) += radio-si470x.o
Signature · 1 line
1.6.2.GIT
Quoted 14 lines · On Wednesday 01 April 2009 11:43:28 Eduardo Valentin wrote:
Hello Mauro and v4l guys,
This series contains a v4l2 radio driver which adds support for Silabs si4713 devices. That is a FM transmitter device.
As you should know, v4l2 does not contain representation of FM Transmitters (at least that I know). So this driver was written highly based on FM receivers API, which can cover most of basic functionality. However, as expected, there are some properties which were not covered. For those properties, sysfs nodes were added in order to get user interactions.
Quoted 1 line
Comments are wellcome.
Can you explain in reasonable detail the extra properties needed for a device like this? You will need to document that anyway :-) Rather than implementing a private API it would be much more interesting to turn this into a public V4L2 API that everyone can use.
How does one pass the audio and rds data to the driver? Note that for 2.6.31 we will finalize the V4L2 RDS decoder API (I recently posted an RFC for that, but I haven't had the time to implement the few changes needed). It would be nice if rds modulator support would be modeled after this demodulator API if possible.
Does region information really belong in the driver? Perhaps this should be in a user-space library? (just a suggestion, I'm not sure at this stage).
A general comment: the si4713 driver should be a stand-alone i2c driver. That way it can be reused by other drivers/platforms that use this chip. The v4l2_subdev framework should be used for this.
Always interesting to see new functionality arrive in V4L2 :-)
Regards,
Hans
Quoted 23 lines
Eduardo Valentin (3):
FMTx: si4713: Add files to handle si4713 device
FMTx: si4713: Add files to add radio interface for si4713
FMTx: si4713: AddKconfigandMakefileentriesdrivers/media/radio/Kconfig | 12 + drivers/media/radio/Makefile | 2 + drivers/media/radio/radio-si4713.c | 834 ++++++++++++++ drivers/media/radio/radio-si4713.h | 32 + drivers/media/radio/si4713.c | 2238 ++++++++++++++++++++++++++++++++++++ drivers/media/radio/si4713.h | 294 +++++ 6 files changed, 3412 insertions(+), 0 deletions(-) create mode 100644 drivers/media/radio/radio-si4713.c create mode 100644 drivers/media/radio/radio-si4713.h create mode 100644 drivers/media/radio/si4713.c create mode 100644 drivers/media/radio/si4713.h--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Hans Verkuil - video4linux developer - sponsored by TANDBERG
Hi Hans,
Quoted 15 lines · ext Hans Verkuil
Quoted 14 lines · On Wednesday 01 April 2009 11:43:28 Eduardo Valentin wrote:
Hello Mauro and v4l guys,
This series contains a v4l2 radio driver which adds support for Silabs si4713 devices. That is a FM transmitter device.
As you should know, v4l2 does not contain representation of FM Transmitters (at least that I know). So this driver was written highly based on FM receivers API, which can cover most of basic functionality. However, as expected, there are some properties which were not covered. For those properties, sysfs nodes were added in order to get user interactions.
Quoted 6 lines
Quoted 1 line
Comments are wellcome.
Can you explain in reasonable detail the extra properties needed for a device like this? You will need to document that anyway :-) Rather than implementing a private API it would be much more interesting to turn this into a public V4L2 API that everyone can use.
Yes, here is a little description of them:
Pilot is an audible tone sent by the device.
pilot_frequency - Configures the frequency of the stereo pilot tone. pilot_deviation - Configures pilot tone frequency deviation level. pilot_enabled - Enables or disables the pilot tone feature.
The si4713 device is capable of applying audio compression to the transmitted signal.
acomp_enabled - Enables or disables the audio dynamic range control feature. acomp_gain - Sets the gain for audio dynamic range control. acomp_threshold - Sets the threshold level for audio dynamic range control. acomp_attack_time - Sets the attack time for audio dynamic range control. acomp_release_time - Sets the release time for audio dynamic range control.
Limiter setups audio deviation limiter feature. Once a over deviation occurs, it is possible to adjust the front-end gain of the audio input and always prevent over deviation.
limiter_enabled - Enables or disables the limiter feature. limiter_deviation - Configures audio frequency deviation level. limiter_release_time - Sets the limiter release time.
power_level - Sets the output power level for signal transmission.
RDS related
rds_enabled - Enables or disables the RDS feature. rds_ps_name - Sets the RDS ps name field for transmission. rds_radio_text - Sets the RDS radio text for transmission. rds_pi - Sets the RDS PI field for transmission. rds_pty - Sets the RDS PTY field for transmission.
Region related
Setting region will affect other region properties.
region_bottom_frequencyregion_channel_spacingregion_preemphasisregion_top_frequency
stereo_enabled - Enables or disables stereo mode.
Quoted 6 lines
How does one pass the audio and rds data to the driver? Note that for 2.6.31 we will finalize the V4L2 RDS decoder API (I recently posted an RFC for that, but I haven't had the time to implement the few changes needed). It would be nice if rds modulator support would be modeled after this demodulator API if possible.
I see. This is good. I think the best way is to have a rds modulator interface. This driver have implemented it as sys properties, as described above.
Quoted 3 lines
Does region information really belong in the driver? Perhaps this should be in a user-space library? (just a suggestion, I'm not sure at this stage).
Ok. Yes, this could be better to implement in user land. However, depending on region that would restrict other properties as well. So, letting user space control that, would allow device operate in wrong intervals for frequencies for instance.
Quoted 4 lines
A general comment: the si4713 driver should be a stand-alone i2c driver. That way it can be reused by other
drivers/platformsthat use this chip. Thev4l2_subdevframework should be used for this.
Right. I'll take a look at the v4l2_subdev framework.
Quoted 35 lines
Always interesting to see new functionality arrive in V4L2 :-)
Regards,
Hans
Quoted 23 lines
Eduardo Valentin (3):
FMTx: si4713: Add files to handle si4713 device
FMTx: si4713: Add files to add radio interface for si4713
FMTx: si4713: AddKconfigandMakefileentriesdrivers/media/radio/Kconfig | 12 + drivers/media/radio/Makefile | 2 + drivers/media/radio/radio-si4713.c | 834 ++++++++++++++ drivers/media/radio/radio-si4713.h | 32 + drivers/media/radio/si4713.c | 2238 ++++++++++++++++++++++++++++++++++++ drivers/media/radio/si4713.h | 294 +++++ 6 files changed, 3412 insertions(+), 0 deletions(-) create mode 100644 drivers/media/radio/radio-si4713.c create mode 100644 drivers/media/radio/radio-si4713.h create mode 100644 drivers/media/radio/si4713.c create mode 100644 drivers/media/radio/si4713.h--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlSignature · 1 line
Hans Verkuil - video4linux developer - sponsored by TANDBERG
Signature · 1 line
Eduardo Valentin
Quoted 45 lines · On Thursday 02 April 2009 14:02:11 Eduardo Valentin wrote:
Hi Hans,
Quoted 15 lines · ext Hans Verkuil
Quoted 14 lines · On Wednesday 01 April 2009 11:43:28 Eduardo Valentin wrote:
Hello Mauro and v4l guys,
This series contains a v4l2 radio driver which adds support for Silabs si4713 devices. That is a FM transmitter device.
As you should know, v4l2 does not contain representation of FM Transmitters (at least that I know). So this driver was written highly based on FM receivers API, which can cover most of basic functionality. However, as expected, there are some properties which were not covered. For those properties, sysfs nodes were added in order to get user interactions.
Quoted 6 lines
Quoted 1 line
Comments are wellcome.
Can you explain in reasonable detail the extra properties needed for a device like this? You will need to document that anyway :-) Rather than implementing a private API it would be much more interesting to turn this into a public V4L2 API that everyone can use.
Yes, here is a little description of them:
Pilot is an audible tone sent by the device.
pilot_frequency- Configures the frequency of the stereo pilot tone.pilot_deviation- Configures pilot tone frequency deviation level.pilot_enabled- Enables or disables the pilot tone feature.The si4713 device is capable of applying audio compression to the transmitted signal.
acomp_enabled- Enables or disables the audio dynamic range control feature.acomp_gain- Sets the gain for audio dynamic range control.acomp_threshold- Sets the threshold level for audio dynamic range control.acomp_attack_time- Sets the attack time for audio dynamic range control.acomp_release_time- Sets the release time for audio dynamic range control.Limiter setups audio deviation limiter feature. Once a over deviation occurs, it is possible to adjust the front-end gain of the audio input and always prevent over deviation.
Quoted 5 lines
limiter_enabled- Enables or disables the limiter feature.limiter_deviation- Configures audio frequency deviation level.limiter_release_time- Sets the limiter release time.
power_level- Sets the output power level for signal transmission.
Hmm, there are two ways to implement these: either make a bunch of VIDIOC's for each of these categories, or use extended controls to set all these values. I'm hardly an expert on FM transmitters, but it all seems reasonable to me (i.e., not too specific for this chip).
I am leaning towards extended controls, since that's so easy to extend if needed in the future. And I still intend to add sysfs support to controls in the future. On the other hand, it's a bit harder to use compared to normal VIDIOCs.
Quoted 8 lines
RDS related
rds_enabled- Enables or disables the RDS feature.rds_ps_name- Sets the RDS ps name field for transmission.rds_radio_text- Sets the RDS radio text for transmission.rds_pi- Sets the RDS PI field for transmission.rds_pty- Sets the RDS PTY field for transmission.
So you set the fields and the RDS encoder will just start using them?
This too can be done with controls (needs some work, though, to support string controls).
Quoted 9 lines
Region related
Setting region will affect other region properties.
region_bottom_frequencyregion_channel_spacingregion_preemphasisregion_top_frequency
I do not know enough about FM transmissions to judge this. Are these region properties something that is regulated by some standards commision? Do they also apply when you modulate this over a TV/radio cable system? Do you have some documentation or links that I can look at to learn more about this?
Quoted 9 lines
stereo_enabled- Enables or disables stereo mode.Quoted 6 lines
How does one pass the audio and rds data to the driver? Note that for 2.6.31 we will finalize the V4L2 RDS decoder API (I recently posted an RFC for that, but I haven't had the time to implement the few changes needed). It would be nice if rds modulator support would be modeled after this demodulator API if possible.
Quoted 3 lines
I see. This is good. I think the best way is to have a rds modulator interface. This driver have implemented it as sys properties, as described above.
I don't think there is that much overlap, though. The similarities are probably limited to some flags.
Quoted 9 lines
Quoted 4 lines
Does region information really belong in the driver? Perhaps this should be in a user-space library? (just a suggestion, I'm not sure at this stage).
Ok. Yes, this could be better to implement in user land. However, depending on region that would restrict other properties as well. So, letting user space control that, would allow device operate in wrong intervals for frequencies for instance.
But if you are in region A and you setup the device for region B, then it's wrong as well, right?
I also wonder if there are legal requirements that have to be followed here?
Regards,
Hans
Signature · 1 line
Hans Verkuil - video4linux developer - sponsored by TANDBERG
Quoted 57 lines · ext Hans Verkuil
Quoted 45 lines · On Thursday 02 April 2009 14:02:11 Eduardo Valentin wrote:
Hi Hans,
Quoted 15 lines · ext Hans Verkuil
Quoted 14 lines · On Wednesday 01 April 2009 11:43:28 Eduardo Valentin wrote:
Hello Mauro and v4l guys,
This series contains a v4l2 radio driver which adds support for Silabs si4713 devices. That is a FM transmitter device.
As you should know, v4l2 does not contain representation of FM Transmitters (at least that I know). So this driver was written highly based on FM receivers API, which can cover most of basic functionality. However, as expected, there are some properties which were not covered. For those properties, sysfs nodes were added in order to get user interactions.
Quoted 6 lines
Quoted 1 line
Comments are wellcome.
Can you explain in reasonable detail the extra properties needed for a device like this? You will need to document that anyway :-) Rather than implementing a private API it would be much more interesting to turn this into a public V4L2 API that everyone can use.
Yes, here is a little description of them:
Pilot is an audible tone sent by the device.
pilot_frequency- Configures the frequency of the stereo pilot tone.pilot_deviation- Configures pilot tone frequency deviation level.pilot_enabled- Enables or disables the pilot tone feature.The si4713 device is capable of applying audio compression to the transmitted signal.
acomp_enabled- Enables or disables the audio dynamic range control feature.acomp_gain- Sets the gain for audio dynamic range control.acomp_threshold- Sets the threshold level for audio dynamic range control.acomp_attack_time- Sets the attack time for audio dynamic range control.acomp_release_time- Sets the release time for audio dynamic range control.Limiter setups audio deviation limiter feature. Once a over deviation occurs, it is possible to adjust the front-end gain of the audio input and always prevent over deviation.
Quoted 5 lines
limiter_enabled- Enables or disables the limiter feature.limiter_deviation- Configures audio frequency deviation level.limiter_release_time- Sets the limiter release time.
power_level- Sets the output power level for signal transmission.Hmm, there are two ways to implement these: either make a bunch of VIDIOC's for each of these categories, or use extended controls to set all these values. I'm hardly an expert on FM transmitters, but it all seems reasonable to me (i.e., not too specific for this chip).
Quoted 4 lines
I am leaning towards extended controls, since that's so easy to extend if needed in the future. And I still intend to add sysfs support to controls in the future. On the other hand, it's a bit harder to use compared to normal VIDIOCs.
Could you please explain more about extended controls vs. VIDIOC's? Pointing drivers which uses one of those also would be worth. But yes, looks like moving this properties to some sort of v4l2 control looks better implementation.
Quoted 11 lines
Quoted 9 lines
RDS related
rds_enabled- Enables or disables the RDS feature.rds_ps_name- Sets the RDS ps name field for transmission.rds_radio_text- Sets the RDS radio text for transmission.rds_pi- Sets the RDS PI field for transmission.rds_pty- Sets the RDS PTY field for transmission.So you set the fields and the RDS encoder will just start using them?
Once you have rds_enabled set, yes, it will transmit them.
Quoted 3 lines
This too can be done with controls (needs some work, though, to support string controls).
Yes, true.
Quoted 42 lines
Quoted 10 lines
Region related
Setting region will affect other region properties.
region_bottom_frequencyregion_channel_spacingregion_preemphasisregion_top_frequencyI do not know enough about FM transmissions to judge this. Are these region properties something that is regulated by some standards commision? Do they also apply when you modulate this over a TV/radio cable system? Do you have some documentation or links that I can look at to learn more about this?
Quoted 9 lines
stereo_enabled- Enables or disables stereo mode.Quoted 6 lines
How does one pass the audio and rds data to the driver? Note that for 2.6.31 we will finalize the V4L2 RDS decoder API (I recently posted an RFC for that, but I haven't had the time to implement the few changes needed). It would be nice if rds modulator support would be modeled after this demodulator API if possible.
Quoted 3 lines
I see. This is good. I think the best way is to have a rds modulator interface. This driver have implemented it as sys properties, as described above.
I don't think there is that much overlap, though. The similarities are probably limited to some flags.
Quoted 9 lines
Quoted 4 lines
Does region information really belong in the driver? Perhaps this should be in a user-space library? (just a suggestion, I'm not sure at this stage).
Ok. Yes, this could be better to implement in user land. However, depending on region that would restrict other properties as well. So, letting user space control that, would allow device operate in wrong intervals for frequencies for instance.
Quoted 4 lines
But if you are in region A and you setup the device for region B, then it's wrong as well, right?
I also wonder if there are legal requirements that have to be followed here?
Yes, the region thing is somehow bound to limits of specific area rules / regulation. For instance, Europe frequencies limits are
.bottom_frequency = 8750, .top_frequency = 10800,
BTW, maybe I'm making some confusion, but is there two different APIs for radios? What is the difference in roles of things that goes into drivers/media/radio and drivers/media/common/tuners?
Quoted 7 lines
Regards,
Hans
Signature · 1 line
Hans Verkuil - video4linux developer - sponsored by TANDBERG
Signature · 1 line
Eduardo Valentin
Quoted 66 lines · On Friday 03 April 2009 12:12:30 Eduardo Valentin wrote:
Quoted 60 lines · ext Hans Verkuil
Quoted 48 lines · On Thursday 02 April 2009 14:02:11 Eduardo Valentin wrote:
Hi Hans,
Quoted 15 lines · ext Hans Verkuil
Quoted 14 lines · On Wednesday 01 April 2009 11:43:28 Eduardo Valentin wrote:
Hello Mauro and v4l guys,
This series contains a v4l2 radio driver which adds support for Silabs si4713 devices. That is a FM transmitter device.
As you should know, v4l2 does not contain representation of FM Transmitters (at least that I know). So this driver was written highly based on FM receivers API, which can cover most of basic functionality. However, as expected, there are some properties which were not covered. For those properties, sysfs nodes were added in order to get user interactions.
Quoted 7 lines
Quoted 1 line
Comments are wellcome.
Can you explain in reasonable detail the extra properties needed for a device like this? You will need to document that anyway :-) Rather than implementing a private API it would be much more interesting to turn this into a public V4L2 API that everyone can use.
Yes, here is a little description of them:
Pilot is an audible tone sent by the device.
pilot_frequency- Configures the frequency of the stereo pilot tone.pilot_deviation- Configures pilot tone frequency deviation level.pilot_enabled- Enables or disables the pilot tone feature.The si4713 device is capable of applying audio compression to the transmitted signal.
acomp_enabled- Enables or disables the audio dynamic range control feature.acomp_gain- Sets the gain for audio dynamic range control.acomp_threshold- Sets the threshold level for audio dynamic range control.acomp_attack_time- Sets the attack time for audio dynamic range control.acomp_release_time- Sets the release time for audio dynamic range control.Limiter setups audio deviation limiter feature. Once a over deviation occurs, it is possible to adjust the front-end gain of the audio input and always prevent over deviation.
Quoted 5 lines
limiter_enabled- Enables or disables the limiter feature.limiter_deviation- Configures audio frequency deviation level.limiter_release_time- Sets the limiter release time.
power_level- Sets the output power level for signal transmission.Hmm, there are two ways to implement these: either make a bunch of VIDIOC's for each of these categories, or use extended controls to set all these values. I'm hardly an expert on FM transmitters, but it all seems reasonable to me (i.e., not too specific for this chip).
Quoted 4 lines
I am leaning towards extended controls, since that's so easy to extend if needed in the future. And I still intend to add sysfs support to controls in the future. On the other hand, it's a bit harder to use compared to normal VIDIOCs.
Quoted 4 lines
Could you please explain more about extended controls vs. VIDIOC's? Pointing drivers which uses one of those also would be worth. But yes, looks like moving this properties to some sort of v4l2 control looks better implementation.
The spec explains it pretty well. The most up to date version of the spec is available here: http://www.xs4all.nl/~hverkuil/spec/v4l2.html.
Basically the extended controls API is more flexible than the older VIDIOC_S/G_CTRL ioctls, allowing to set controls atomically (either all are applied or none) and allowing for a wider range of types, although currently that feature isn't used.
It's used by uvcvideo and by MPEG encoders (e.g. cx18, ivtv and others).
Using VIDIOCs is easier, but much harder to make future-proof. One disadvantage of using extended controls is that it is harder to implement in drivers, although I plan on creating a much better solution for that in the coming months. With the new v4l framework it should be possible to move much of the control handling into the framework and so simplifying the drivers.
Quoted 64 lines
Quoted 9 lines
Quoted 7 lines
RDS related
rds_enabled- Enables or disables the RDS feature.rds_ps_name- Sets the RDS ps name field for transmission.rds_radio_text- Sets the RDS radio text for transmission.rds_pi- Sets the RDS PI field for transmission.rds_pty- Sets the RDS PTY field for transmission.So you set the fields and the RDS encoder will just start using them?
Once you have
rds_enabledset, yes, it will transmit them.Quoted 2 lines
This too can be done with controls (needs some work, though, to support string controls).
Yes, true.
Quoted 39 lines
Quoted 8 lines
Region related
Setting region will affect other region properties.
region_bottom_frequencyregion_channel_spacingregion_preemphasisregion_top_frequencyI do not know enough about FM transmissions to judge this. Are these region properties something that is regulated by some standards commision? Do they also apply when you modulate this over a TV/radio cable system? Do you have some documentation or links that I can look at to learn more about this?
Quoted 11 lines
stereo_enabled- Enables or disables stereo mode.Quoted 5 lines
How does one pass the audio and rds data to the driver? Note that for 2.6.31 we will finalize the V4L2 RDS decoder API (I recently posted an RFC for that, but I haven't had the time to implement the few changes needed). It would be nice if rds modulator support would be modeled after this demodulator API if possible.
I see. This is good. I think the best way is to have a rds modulator interface. This driver have implemented it as sys properties, as described above.
I don't think there is that much overlap, though. The similarities are probably limited to some flags.
Quoted 8 lines
Quoted 3 lines
Does region information really belong in the driver? Perhaps this should be in a user-space library? (just a suggestion, I'm not sure at this stage).
Ok. Yes, this could be better to implement in user land. However, depending on region that would restrict other properties as well. So, letting user space control that, would allow device operate in wrong intervals for frequencies for instance.
Quoted 5 lines
But if you are in region A and you setup the device for region B, then it's wrong as well, right?
I also wonder if there are legal requirements that have to be followed here?
Yes, the region thing is somehow bound to limits of specific area rules / regulation. For instance, Europe frequencies limits are
Quoted 7 lines
.bottom_frequency = 8750, .top_frequency = 10800,BTW, maybe I'm making some confusion, but is there two different APIs for radios? What is the difference in roles of things that goes into
drivers/media/radioanddrivers/media/common/tuners?
common/tuners is for the tuner devices (usually i2c). But in media/radio you find the actual v4l2 drivers. However, in a few cases this split wasn't done and there is no separate i2c driver created for the radio device:
instead it is hardcoded into the v4l2 driver. This is bad and should be avoided for new drivers. We didn't always pay enough attention to this in the past.
Regards,
Hans
Signature · 1 line
Hans Verkuil - video4linux developer - sponsored by TANDBERG
Hi,
Quoted 161 lines · ext Hans Verkuil
Quoted 66 lines · On Friday 03 April 2009 12:12:30 Eduardo Valentin wrote:
Quoted 60 lines · ext Hans Verkuil
Quoted 48 lines · On Thursday 02 April 2009 14:02:11 Eduardo Valentin wrote:
Hi Hans,
Quoted 15 lines · ext Hans Verkuil
Quoted 14 lines · On Wednesday 01 April 2009 11:43:28 Eduardo Valentin wrote:
Hello Mauro and v4l guys,
This series contains a v4l2 radio driver which adds support for Silabs si4713 devices. That is a FM transmitter device.
As you should know, v4l2 does not contain representation of FM Transmitters (at least that I know). So this driver was written highly based on FM receivers API, which can cover most of basic functionality. However, as expected, there are some properties which were not covered. For those properties, sysfs nodes were added in order to get user interactions.
Quoted 7 lines
Quoted 1 line
Comments are wellcome.
Can you explain in reasonable detail the extra properties needed for a device like this? You will need to document that anyway :-) Rather than implementing a private API it would be much more interesting to turn this into a public V4L2 API that everyone can use.
Yes, here is a little description of them:
Pilot is an audible tone sent by the device.
pilot_frequency- Configures the frequency of the stereo pilot tone.pilot_deviation- Configures pilot tone frequency deviation level.pilot_enabled- Enables or disables the pilot tone feature.The si4713 device is capable of applying audio compression to the transmitted signal.
acomp_enabled- Enables or disables the audio dynamic range control feature.acomp_gain- Sets the gain for audio dynamic range control.acomp_threshold- Sets the threshold level for audio dynamic range control.acomp_attack_time- Sets the attack time for audio dynamic range control.acomp_release_time- Sets the release time for audio dynamic range control.Limiter setups audio deviation limiter feature. Once a over deviation occurs, it is possible to adjust the front-end gain of the audio input and always prevent over deviation.
Quoted 5 lines
limiter_enabled- Enables or disables the limiter feature.limiter_deviation- Configures audio frequency deviation level.limiter_release_time- Sets the limiter release time.
power_level- Sets the output power level for signal transmission.Hmm, there are two ways to implement these: either make a bunch of VIDIOC's for each of these categories, or use extended controls to set all these values. I'm hardly an expert on FM transmitters, but it all seems reasonable to me (i.e., not too specific for this chip).
Quoted 4 lines
I am leaning towards extended controls, since that's so easy to extend if needed in the future. And I still intend to add sysfs support to controls in the future. On the other hand, it's a bit harder to use compared to normal VIDIOCs.
Quoted 4 lines
Could you please explain more about extended controls vs. VIDIOC's? Pointing drivers which uses one of those also would be worth. But yes, looks like moving this properties to some sort of v4l2 control looks better implementation.
The spec explains it pretty well. The most up to date version of the spec is available here: http://www.xs4all.nl/~hverkuil/spec/v4l2.html.
Basically the extended controls API is more flexible than the older VIDIOC_S/G_CTRL ioctls, allowing to set controls atomically (either all are applied or none) and allowing for a wider range of types, although currently that feature isn't used.
It's used by uvcvideo and by MPEG encoders (e.g. cx18, ivtv and others).
Using VIDIOCs is easier, but much harder to make future-proof. One disadvantage of using extended controls is that it is harder to implement in drivers, although I plan on creating a much better solution for that in the coming months. With the new v4l framework it should be possible to move much of the control handling into the framework and so simplifying the drivers.
Quoted 64 lines
Quoted 9 lines
Quoted 7 lines
RDS related
rds_enabled- Enables or disables the RDS feature.rds_ps_name- Sets the RDS ps name field for transmission.rds_radio_text- Sets the RDS radio text for transmission.rds_pi- Sets the RDS PI field for transmission.rds_pty- Sets the RDS PTY field for transmission.So you set the fields and the RDS encoder will just start using them?
Once you have
rds_enabledset, yes, it will transmit them.Quoted 2 lines
This too can be done with controls (needs some work, though, to support string controls).
Yes, true.
Quoted 39 lines
Quoted 8 lines
Region related
Setting region will affect other region properties.
region_bottom_frequencyregion_channel_spacingregion_preemphasisregion_top_frequencyI do not know enough about FM transmissions to judge this. Are these region properties something that is regulated by some standards commision? Do they also apply when you modulate this over a TV/radio cable system? Do you have some documentation or links that I can look at to learn more about this?
Quoted 11 lines
stereo_enabled- Enables or disables stereo mode.Quoted 5 lines
How does one pass the audio and rds data to the driver? Note that for 2.6.31 we will finalize the V4L2 RDS decoder API (I recently posted an RFC for that, but I haven't had the time to implement the few changes needed). It would be nice if rds modulator support would be modeled after this demodulator API if possible.
I see. This is good. I think the best way is to have a rds modulator interface. This driver have implemented it as sys properties, as described above.
I don't think there is that much overlap, though. The similarities are probably limited to some flags.
Quoted 8 lines
Quoted 3 lines
Does region information really belong in the driver? Perhaps this should be in a user-space library? (just a suggestion, I'm not sure at this stage).
Ok. Yes, this could be better to implement in user land. However, depending on region that would restrict other properties as well. So, letting user space control that, would allow device operate in wrong intervals for frequencies for instance.
Quoted 5 lines
But if you are in region A and you setup the device for region B, then it's wrong as well, right?
I also wonder if there are legal requirements that have to be followed here?
Yes, the region thing is somehow bound to limits of specific area rules / regulation. For instance, Europe frequencies limits are
Quoted 7 lines
.bottom_frequency = 8750, .top_frequency = 10800,BTW, maybe I'm making some confusion, but is there two different APIs for radios? What is the difference in roles of things that goes into
drivers/media/radioanddrivers/media/common/tuners?
Quoted 6 lines
common/tuners is for the tuner devices (usually i2c). But in media/radio you find the actual v4l2 drivers. However, in a few cases this split wasn't done and there is no separate i2c driver created for the radio device:
instead it is hardcoded into the v4l2 driver. This is bad and should be avoided for new drivers. We didn't always pay enough attention to this in the past.
Good stuff. So I see a few things in this code I sent:
1. Move properties to extended controls
2. Split driver into i2c driver (common/tunner?) and media/radio
Possibly the rds modulator thing as well, but I think this will be for future (after the demodulator is done)?
Is that correct or I missed something?
Quoted 4 lines
Regards,
Hans
BTW, thanks for the good reviewing.
Quoted 3 lines
Signature · 2 lines
-- Hans Verkuil - video4linux developer - sponsored by TANDBERG
BR,
Signature · 1 line
Eduardo Valentin
Quoted 177 lines · On Friday 03 April 2009 12:48:19 Eduardo Valentin wrote:
Hi,
Quoted 167 lines · ext Hans Verkuil
Quoted 69 lines · On Friday 03 April 2009 12:12:30 Eduardo Valentin wrote:
Quoted 63 lines · ext Hans Verkuil
Quoted 49 lines · On Thursday 02 April 2009 14:02:11 Eduardo Valentin wrote:
Hi Hans,
Quoted 15 lines · ext Hans Verkuil
Quoted 14 lines · On Wednesday 01 April 2009 11:43:28 Eduardo Valentin wrote:
Hello Mauro and v4l guys,
This series contains a v4l2 radio driver which adds support for Silabs si4713 devices. That is a FM transmitter device.
As you should know, v4l2 does not contain representation of FM Transmitters (at least that I know). So this driver was written highly based on FM receivers API, which can cover most of basic functionality. However, as expected, there are some properties which were not covered. For those properties, sysfs nodes were added in order to get user interactions.
Quoted 7 lines
Quoted 1 line
Comments are wellcome.
Can you explain in reasonable detail the extra properties needed for a device like this? You will need to document that anyway :-) Rather than implementing a private API it would be much more interesting to turn this into a public V4L2 API that everyone can use.
Yes, here is a little description of them:
Pilot is an audible tone sent by the device.
pilot_frequency- Configures the frequency of the stereo pilot tone.pilot_deviation- Configures pilot tone frequency deviation level.pilot_enabled- Enables or disables the pilot tone feature.The si4713 device is capable of applying audio compression to the transmitted signal.
acomp_enabled- Enables or disables the audio dynamic range control feature.acomp_gain- Sets the gain for audio dynamic range control.acomp_threshold- Sets the threshold level for audio dynamic range control.acomp_attack_time- Sets the attack time for audio dynamic range control.acomp_release_time- Sets the release time for audio dynamic range control.Limiter setups audio deviation limiter feature. Once a over deviation occurs, it is possible to adjust the front-end gain of the audio input and always prevent over deviation.
Quoted 6 lines
limiter_enabled- Enables or disables the limiter feature.limiter_deviation- Configures audio frequency deviation level.limiter_release_time- Sets the limiter release time.
power_level- Sets the output power level for signal transmission.Hmm, there are two ways to implement these: either make a bunch of VIDIOC's for each of these categories, or use extended controls to set all these values. I'm hardly an expert on FM transmitters, but it all seems reasonable to me (i.e., not too specific for this chip).
Quoted 4 lines
I am leaning towards extended controls, since that's so easy to extend if needed in the future. And I still intend to add sysfs support to controls in the future. On the other hand, it's a bit harder to use compared to normal VIDIOCs.
Quoted 4 lines
Could you please explain more about extended controls vs. VIDIOC's? Pointing drivers which uses one of those also would be worth. But yes, looks like moving this properties to some sort of v4l2 control looks better implementation.
The spec explains it pretty well. The most up to date version of the spec is available here: http://www.xs4all.nl/~hverkuil/spec/v4l2.html.
Basically the extended controls API is more flexible than the older VIDIOC_S/G_CTRL ioctls, allowing to set controls atomically (either all are applied or none) and allowing for a wider range of types, although currently that feature isn't used.
It's used by uvcvideo and by MPEG encoders (e.g. cx18, ivtv and others).
Using VIDIOCs is easier, but much harder to make future-proof. One disadvantage of using extended controls is that it is harder to implement in drivers, although I plan on creating a much better solution for that in the coming months. With the new v4l framework it should be possible to move much of the control handling into the framework and so simplifying the drivers.
Quoted 66 lines
Quoted 10 lines
Quoted 7 lines
RDS related
rds_enabled- Enables or disables the RDS feature.rds_ps_name- Sets the RDS ps name field for transmission.rds_radio_text- Sets the RDS radio text for transmission.rds_pi- Sets the RDS PI field for transmission.rds_pty- Sets the RDS PTY field for transmission.So you set the fields and the RDS encoder will just start using them?
Once you have
rds_enabledset, yes, it will transmit them.Quoted 2 lines
This too can be done with controls (needs some work, though, to support string controls).
Yes, true.
Quoted 40 lines
Quoted 8 lines
Region related
Setting region will affect other region properties.
region_bottom_frequencyregion_channel_spacingregion_preemphasisregion_top_frequencyI do not know enough about FM transmissions to judge this. Are these region properties something that is regulated by some standards commision? Do they also apply when you modulate this over a TV/radio cable system? Do you have some documentation or links that I can look at to learn more about this?
Quoted 9 lines
stereo_enabled- Enables or disables stereo mode.Quoted 6 lines
How does one pass the audio and rds data to the driver? Note that for 2.6.31 we will finalize the V4L2 RDS decoder API (I recently posted an RFC for that, but I haven't had the time to implement the few changes needed). It would be nice if rds modulator support would be modeled after this demodulator API if possible.
Quoted 3 lines
I see. This is good. I think the best way is to have a rds modulator interface. This driver have implemented it as sys properties, as described above.
I don't think there is that much overlap, though. The similarities are probably limited to some flags.
Quoted 8 lines
Quoted 3 lines
Does region information really belong in the driver? Perhaps this should be in a user-space library? (just a suggestion, I'm not sure at this stage).
Ok. Yes, this could be better to implement in user land. However, depending on region that would restrict other properties as well. So, letting user space control that, would allow device operate in wrong intervals for frequencies for instance.
Quoted 5 lines
But if you are in region A and you setup the device for region B, then it's wrong as well, right?
I also wonder if there are legal requirements that have to be followed here?
Yes, the region thing is somehow bound to limits of specific area rules / regulation. For instance, Europe frequencies limits are
Quoted 7 lines
.bottom_frequency = 8750, .top_frequency = 10800,BTW, maybe I'm making some confusion, but is there two different APIs for radios? What is the difference in roles of things that goes into
drivers/media/radioanddrivers/media/common/tuners?Quoted 6 lines
common/tuners is for the tuner devices (usually i2c). But in media/radio you find the actual v4l2 drivers. However, in a few cases this split wasn't done and there is no separate i2c driver created for the radio device: instead it is hardcoded into the v4l2 driver. This is bad and should be avoided for new drivers. We didn't always pay enough attention to this in the past.
Quoted 2 lines
Good stuff. So I see a few things in this code I sent:
1. Move properties to extended controls
I think this is probably the best approach. You would need to make a new class for such controls (RADIO_MODULATOR or something).
Quoted 1 line
2. Split driver into i2c driver (common/tunner?) and media/radio
Not common/tuner, I think it can just go into media/radio. As long as it is a stand-alone i2c driver that can be reused.
Quoted 2 lines
Possibly the rds modulator thing as well, but I think this will be for future (after the demodulator is done)?
Yes. Finishing the RDS demodulator API according to my RFCv2 of that API is high on my list and I hope to do this by the end of this month. And I will also need to add some support to the extended control API to allow strings to be passed.
Quoted 1 line
Is that correct or I missed something?
Documentation! All these new controls have to be documented in the V4L2 spec. Initially just write it up in a simple text document since there will be no doubt one or two more review cycles, so spending a lot of time on integrating it into the spec when it might change later isn't wise.
Quoted 6 lines
Quoted 4 lines
Regards,
Hans
BTW, thanks for the good reviewing.
You're welcome. Just be prepared that you may have to go through additional
rewrites: this is actually the first modulator driver to be added to v4l-dvb, so we will have to carefully determine what the best API will be for this. Once the API is chosen we can't easily (if at all) change it in the future, so it's good not to rush things at this stage.
I think this is a very interesting time for the v4l subsystem in particular:
for a long time it was limited to consumer TV capture cards which was rather a niche market. It's good to see companies involved in embedded systems to start contributing code, that should move this subsystem to a more professional level.
Regards,
Hans
Signature · 1 line
Hans Verkuil - video4linux developer - sponsored by TANDBERG
Quoted 178 lines · ext Hans Verkuil
Quoted 177 lines · On Friday 03 April 2009 12:48:19 Eduardo Valentin wrote:
Hi,
Quoted 173 lines · ext Hans Verkuil
Quoted 69 lines · On Friday 03 April 2009 12:12:30 Eduardo Valentin wrote:
Quoted 63 lines · ext Hans Verkuil
Quoted 49 lines · On Thursday 02 April 2009 14:02:11 Eduardo Valentin wrote:
Hi Hans,
Quoted 15 lines · ext Hans Verkuil
Quoted 14 lines · On Wednesday 01 April 2009 11:43:28 Eduardo Valentin wrote:
Hello Mauro and v4l guys,
This series contains a v4l2 radio driver which adds support for Silabs si4713 devices. That is a FM transmitter device.
As you should know, v4l2 does not contain representation of FM Transmitters (at least that I know). So this driver was written highly based on FM receivers API, which can cover most of basic functionality. However, as expected, there are some properties which were not covered. For those properties, sysfs nodes were added in order to get user interactions.
Quoted 7 lines
Quoted 1 line
Comments are wellcome.
Can you explain in reasonable detail the extra properties needed for a device like this? You will need to document that anyway :-) Rather than implementing a private API it would be much more interesting to turn this into a public V4L2 API that everyone can use.
Yes, here is a little description of them:
Pilot is an audible tone sent by the device.
pilot_frequency- Configures the frequency of the stereo pilot tone.pilot_deviation- Configures pilot tone frequency deviation level.pilot_enabled- Enables or disables the pilot tone feature.The si4713 device is capable of applying audio compression to the transmitted signal.
acomp_enabled- Enables or disables the audio dynamic range control feature.acomp_gain- Sets the gain for audio dynamic range control.acomp_threshold- Sets the threshold level for audio dynamic range control.acomp_attack_time- Sets the attack time for audio dynamic range control.acomp_release_time- Sets the release time for audio dynamic range control.Limiter setups audio deviation limiter feature. Once a over deviation occurs, it is possible to adjust the front-end gain of the audio input and always prevent over deviation.
Quoted 6 lines
limiter_enabled- Enables or disables the limiter feature.limiter_deviation- Configures audio frequency deviation level.limiter_release_time- Sets the limiter release time.
power_level- Sets the output power level for signal transmission.Hmm, there are two ways to implement these: either make a bunch of VIDIOC's for each of these categories, or use extended controls to set all these values. I'm hardly an expert on FM transmitters, but it all seems reasonable to me (i.e., not too specific for this chip).
Quoted 4 lines
I am leaning towards extended controls, since that's so easy to extend if needed in the future. And I still intend to add sysfs support to controls in the future. On the other hand, it's a bit harder to use compared to normal VIDIOCs.
Quoted 4 lines
Could you please explain more about extended controls vs. VIDIOC's? Pointing drivers which uses one of those also would be worth. But yes, looks like moving this properties to some sort of v4l2 control looks better implementation.
The spec explains it pretty well. The most up to date version of the spec is available here: http://www.xs4all.nl/~hverkuil/spec/v4l2.html.
Basically the extended controls API is more flexible than the older VIDIOC_S/G_CTRL ioctls, allowing to set controls atomically (either all are applied or none) and allowing for a wider range of types, although currently that feature isn't used.
It's used by uvcvideo and by MPEG encoders (e.g. cx18, ivtv and others).
Using VIDIOCs is easier, but much harder to make future-proof. One disadvantage of using extended controls is that it is harder to implement in drivers, although I plan on creating a much better solution for that in the coming months. With the new v4l framework it should be possible to move much of the control handling into the framework and so simplifying the drivers.
Quoted 66 lines
Quoted 10 lines
Quoted 7 lines
RDS related
rds_enabled- Enables or disables the RDS feature.rds_ps_name- Sets the RDS ps name field for transmission.rds_radio_text- Sets the RDS radio text for transmission.rds_pi- Sets the RDS PI field for transmission.rds_pty- Sets the RDS PTY field for transmission.So you set the fields and the RDS encoder will just start using them?
Once you have
rds_enabledset, yes, it will transmit them.Quoted 2 lines
This too can be done with controls (needs some work, though, to support string controls).
Yes, true.
Quoted 40 lines
Quoted 8 lines
Region related
Setting region will affect other region properties.
region_bottom_frequencyregion_channel_spacingregion_preemphasisregion_top_frequencyI do not know enough about FM transmissions to judge this. Are these region properties something that is regulated by some standards commision? Do they also apply when you modulate this over a TV/radio cable system? Do you have some documentation or links that I can look at to learn more about this?
Quoted 9 lines
stereo_enabled- Enables or disables stereo mode.Quoted 6 lines
How does one pass the audio and rds data to the driver? Note that for 2.6.31 we will finalize the V4L2 RDS decoder API (I recently posted an RFC for that, but I haven't had the time to implement the few changes needed). It would be nice if rds modulator support would be modeled after this demodulator API if possible.
Quoted 3 lines
I see. This is good. I think the best way is to have a rds modulator interface. This driver have implemented it as sys properties, as described above.
I don't think there is that much overlap, though. The similarities are probably limited to some flags.
Quoted 8 lines
Quoted 3 lines
Does region information really belong in the driver? Perhaps this should be in a user-space library? (just a suggestion, I'm not sure at this stage).
Ok. Yes, this could be better to implement in user land. However, depending on region that would restrict other properties as well. So, letting user space control that, would allow device operate in wrong intervals for frequencies for instance.
Quoted 5 lines
But if you are in region A and you setup the device for region B, then it's wrong as well, right?
I also wonder if there are legal requirements that have to be followed here?
Yes, the region thing is somehow bound to limits of specific area rules / regulation. For instance, Europe frequencies limits are
Quoted 7 lines
.bottom_frequency = 8750, .top_frequency = 10800,BTW, maybe I'm making some confusion, but is there two different APIs for radios? What is the difference in roles of things that goes into
drivers/media/radioanddrivers/media/common/tuners?common/tuners is for the tuner devices (usually i2c). But in media/radio you find the actual v4l2 drivers. However, in a few cases this split wasn't done and there is no separate i2c driver created for the radio device: instead it is hardcoded into the v4l2 driver. This is bad and should be avoided for new drivers. We didn't always pay enough attention to this in the past.
Quoted 5 lines
Quoted 2 lines
Good stuff. So I see a few things in this code I sent:
1. Move properties to extended controlsI think this is probably the best approach. You would need to make a new class for such controls (
RADIO_MODULATORor something).
Ok. good!
Quoted 5 lines
Quoted 2 lines
2. Split driver into i2c driver (common/tunner?) and media/radio
Not common/tuner, I think it can just go into media/radio. As long as it is a stand-alone i2c driver that can be reused.
Ok. right.
Quoted 8 lines
Quoted 3 lines
Possibly the rds modulator thing as well, but I think this will be for future (after the demodulator is done)?
Yes. Finishing the RDS demodulator API according to my RFCv2 of that API is high on my list and I hope to do this by the end of this month. And I will also need to add some support to the extended control API to allow strings to be passed.
Ok, good then.
Quoted 7 lines
Quoted 2 lines
Is that correct or I missed something?
Documentation! All these new controls have to be documented in the V4L2 spec. Initially just write it up in a simple text document since there will be no doubt one or two more review cycles, so spending a lot of time on integrating it into the spec when it might change later isn't wise.
True. Documentation. I'll check that as well.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Regards,
Hans
Quoted 7 lines
Quoted 1 line
BTW, thanks for the good reviewing.
You're welcome. Just be prepared that you may have to go through additional
rewrites: this is actually the first modulator driver to be added to v4l-dvb, so we will have to carefully determine what the best API will be for this. Once the API is chosen we can't easily (if at all) change it in the future, so it's good not to rush things at this stage.
Yes, no rush, please. The intension of this very first interaction was mainly to raise up discussion about best way to this kind of devices. Also, no worries if it takes several reviews cycles.
More comments, best results we get. :-)
Quoted 13 lines
I think this is a very interesting time for the v4l subsystem in particular:
for a long time it was limited to consumer TV capture cards which was rather a niche market. It's good to see companies involved in embedded systems to start contributing code, that should move this subsystem to a more professional level.Regards,
Hans
Signature · 1 line
Hans Verkuil - video4linux developer - sponsored by TANDBERG
Signature · 1 line
Eduardo Valentin
Hello again,
Quoted 188 lines · Valentin Eduardo (Nokia-D/Helsinki)
Quoted 178 lines · ext Hans Verkuil
Quoted 177 lines · On Friday 03 April 2009 12:48:19 Eduardo Valentin wrote:
Hi,
Quoted 173 lines · ext Hans Verkuil
Quoted 69 lines · On Friday 03 April 2009 12:12:30 Eduardo Valentin wrote:
Quoted 63 lines · ext Hans Verkuil
Quoted 49 lines · On Thursday 02 April 2009 14:02:11 Eduardo Valentin wrote:
Hi Hans,
Quoted 15 lines · ext Hans Verkuil
Quoted 14 lines · On Wednesday 01 April 2009 11:43:28 Eduardo Valentin wrote:
Hello Mauro and v4l guys,
This series contains a v4l2 radio driver which adds support for Silabs si4713 devices. That is a FM transmitter device.
As you should know, v4l2 does not contain representation of FM Transmitters (at least that I know). So this driver was written highly based on FM receivers API, which can cover most of basic functionality. However, as expected, there are some properties which were not covered. For those properties, sysfs nodes were added in order to get user interactions.
Quoted 7 lines
Quoted 1 line
Comments are wellcome.
Can you explain in reasonable detail the extra properties needed for a device like this? You will need to document that anyway :-) Rather than implementing a private API it would be much more interesting to turn this into a public V4L2 API that everyone can use.
Yes, here is a little description of them:
Pilot is an audible tone sent by the device.
pilot_frequency- Configures the frequency of the stereo pilot tone.pilot_deviation- Configures pilot tone frequency deviation level.pilot_enabled- Enables or disables the pilot tone feature.The si4713 device is capable of applying audio compression to the transmitted signal.
acomp_enabled- Enables or disables the audio dynamic range control feature.acomp_gain- Sets the gain for audio dynamic range control.acomp_threshold- Sets the threshold level for audio dynamic range control.acomp_attack_time- Sets the attack time for audio dynamic range control.acomp_release_time- Sets the release time for audio dynamic range control.Limiter setups audio deviation limiter feature. Once a over deviation occurs, it is possible to adjust the front-end gain of the audio input and always prevent over deviation.
Quoted 6 lines
limiter_enabled- Enables or disables the limiter feature.limiter_deviation- Configures audio frequency deviation level.limiter_release_time- Sets the limiter release time.
power_level- Sets the output power level for signal transmission.Hmm, there are two ways to implement these: either make a bunch of VIDIOC's for each of these categories, or use extended controls to set all these values. I'm hardly an expert on FM transmitters, but it all seems reasonable to me (i.e., not too specific for this chip).
Quoted 4 lines
I am leaning towards extended controls, since that's so easy to extend if needed in the future. And I still intend to add sysfs support to controls in the future. On the other hand, it's a bit harder to use compared to normal VIDIOCs.
Quoted 4 lines
Could you please explain more about extended controls vs. VIDIOC's? Pointing drivers which uses one of those also would be worth. But yes, looks like moving this properties to some sort of v4l2 control looks better implementation.
The spec explains it pretty well. The most up to date version of the spec is available here: http://www.xs4all.nl/~hverkuil/spec/v4l2.html.
Basically the extended controls API is more flexible than the older VIDIOC_S/G_CTRL ioctls, allowing to set controls atomically (either all are applied or none) and allowing for a wider range of types, although currently that feature isn't used.
It's used by uvcvideo and by MPEG encoders (e.g. cx18, ivtv and others).
Using VIDIOCs is easier, but much harder to make future-proof. One disadvantage of using extended controls is that it is harder to implement in drivers, although I plan on creating a much better solution for that in the coming months. With the new v4l framework it should be possible to move much of the control handling into the framework and so simplifying the drivers.
Quoted 66 lines
Quoted 10 lines
Quoted 7 lines
RDS related
rds_enabled- Enables or disables the RDS feature.rds_ps_name- Sets the RDS ps name field for transmission.rds_radio_text- Sets the RDS radio text for transmission.rds_pi- Sets the RDS PI field for transmission.rds_pty- Sets the RDS PTY field for transmission.So you set the fields and the RDS encoder will just start using them?
Once you have
rds_enabledset, yes, it will transmit them.Quoted 2 lines
This too can be done with controls (needs some work, though, to support string controls).
Yes, true.
Quoted 40 lines
Quoted 8 lines
Region related
Setting region will affect other region properties.
region_bottom_frequencyregion_channel_spacingregion_preemphasisregion_top_frequencyI do not know enough about FM transmissions to judge this. Are these region properties something that is regulated by some standards commision? Do they also apply when you modulate this over a TV/radio cable system? Do you have some documentation or links that I can look at to learn more about this?
Quoted 9 lines
stereo_enabled- Enables or disables stereo mode.Quoted 6 lines
How does one pass the audio and rds data to the driver? Note that for 2.6.31 we will finalize the V4L2 RDS decoder API (I recently posted an RFC for that, but I haven't had the time to implement the few changes needed). It would be nice if rds modulator support would be modeled after this demodulator API if possible.
Quoted 3 lines
I see. This is good. I think the best way is to have a rds modulator interface. This driver have implemented it as sys properties, as described above.
I don't think there is that much overlap, though. The similarities are probably limited to some flags.
Quoted 8 lines
Quoted 3 lines
Does region information really belong in the driver? Perhaps this should be in a user-space library? (just a suggestion, I'm not sure at this stage).
Ok. Yes, this could be better to implement in user land. However, depending on region that would restrict other properties as well. So, letting user space control that, would allow device operate in wrong intervals for frequencies for instance.
Quoted 5 lines
But if you are in region A and you setup the device for region B, then it's wrong as well, right?
I also wonder if there are legal requirements that have to be followed here?
Yes, the region thing is somehow bound to limits of specific area rules / regulation. For instance, Europe frequencies limits are
Quoted 7 lines
.bottom_frequency = 8750, .top_frequency = 10800,BTW, maybe I'm making some confusion, but is there two different APIs for radios? What is the difference in roles of things that goes into
drivers/media/radioanddrivers/media/common/tuners?common/tuners is for the tuner devices (usually i2c). But in media/radio you find the actual v4l2 drivers. However, in a few cases this split wasn't done and there is no separate i2c driver created for the radio device: instead it is hardcoded into the v4l2 driver. This is bad and should be avoided for new drivers. We didn't always pay enough attention to this in the past.
Quoted 5 lines
Quoted 2 lines
Good stuff. So I see a few things in this code I sent:
1. Move properties to extended controlsI think this is probably the best approach. You would need to make a new class for such controls (
RADIO_MODULATORor something).Ok. good!
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
2. Split driver into i2c driver (common/tunner?) and media/radio
Not common/tuner, I think it can just go into media/radio. As long as it is a stand-alone i2c driver that can be reused.
Ok. right.
One question about this split. AFAIU, the split should go as:
- one i2c driver under media/radio, which handles the i2c device itself and also registers itself as a v4l2_subdev_tuner of v4l2_subdevice api.
- another driver under media/radio, which actually registers the v4l2_device as VFL_TYPE_RADIO and uses the i2c driver through the v4l2_subdev api (v4l2_subdev_call ??). In this case, I see this second driver as platform driver.
Is that correct ?
Any good example of driver which does this?
Quoted 57 lines
Quoted 9 lines
Quoted 4 lines
Possibly the rds modulator thing as well, but I think this will be for future (after the demodulator is done)?
Yes. Finishing the RDS demodulator API according to my RFCv2 of that API is high on my list and I hope to do this by the end of this month. And I will also need to add some support to the extended control API to allow strings to be passed.
Ok, good then.
Quoted 7 lines
Quoted 2 lines
Is that correct or I missed something?
Documentation! All these new controls have to be documented in the V4L2 spec. Initially just write it up in a simple text document since there will be no doubt one or two more review cycles, so spending a lot of time on integrating it into the spec when it might change later isn't wise.
True. Documentation. I'll check that as well.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Regards,
Hans
Quoted 7 lines
Quoted 1 line
BTW, thanks for the good reviewing.
You're welcome. Just be prepared that you may have to go through additional
rewrites: this is actually the first modulator driver to be added to v4l-dvb, so we will have to carefully determine what the best API will be for this. Once the API is chosen we can't easily (if at all) change it in the future, so it's good not to rush things at this stage.Yes, no rush, please. The intension of this very first interaction was mainly to raise up discussion about best way to this kind of devices. Also, no worries if it takes several reviews cycles.
More comments, best results we get. :-)Quoted 13 lines
I think this is a very interesting time for the v4l subsystem in particular:
for a long time it was limited to consumer TV capture cards which was rather a niche market. It's good to see companies involved in embedded systems to start contributing code, that should move this subsystem to a more professional level.Regards,
Hans
Signature · 1 line
Hans Verkuil - video4linux developer - sponsored by TANDBERGSignature · 1 line
Eduardo Valentin
Signature · 1 line
Eduardo Valentin
Hello,
Am Freitag, 3. April 2009 12:12 schrieb Eduardo Valentin:
Quoted 129 lines · ext Hans Verkuil
Quoted 59 lines · On Thursday 02 April 2009 14:02:11 Eduardo Valentin wrote:
Quoted 47 lines
Hi Hans,
Quoted 15 lines · ext Hans Verkuil
Quoted 14 lines · On Wednesday 01 April 2009 11:43:28 Eduardo Valentin wrote:
Hello Mauro and v4l guys,
This series contains a v4l2 radio driver which adds support for Silabs si4713 devices. That is a FM transmitter device.
As you should know, v4l2 does not contain representation of FM Transmitters (at least that I know). So this driver was written highly based on FM receivers API, which can cover most of basic functionality. However, as expected, there are some properties which were not covered. For those properties, sysfs nodes were added in order to get user interactions.
Quoted 6 lines
Quoted 1 line
Comments are wellcome.
Can you explain in reasonable detail the extra properties needed for a device like this? You will need to document that anyway :-) Rather than implementing a private API it would be much more interesting to turn this into a public V4L2 API that everyone can use.
Yes, here is a little description of them:
Pilot is an audible tone sent by the device.
pilot_frequency- Configures the frequency of the stereo pilot tone.pilot_deviation- Configures pilot tone frequency deviation level.pilot_enabled- Enables or disables the pilot tone feature.The si4713 device is capable of applying audio compression to the transmitted signal.
acomp_enabled- Enables or disables the audio dynamic range control feature.acomp_gain- Sets the gain for audio dynamic range control.acomp_threshold- Sets the threshold level for audio dynamic range control.acomp_attack_time- Sets the attack time for audio dynamic range control.acomp_release_time- Sets the release time for audio dynamic range control.Limiter setups audio deviation limiter feature. Once a over deviation occurs, it is possible to adjust the front-end gain of the audio input and always prevent over deviation.
Quoted 5 lines
limiter_enabled- Enables or disables the limiter feature.limiter_deviation- Configures audio frequency deviation level.limiter_release_time- Sets the limiter release time.
power_level- Sets the output power level for signal transmission.Hmm, there are two ways to implement these: either make a bunch of VIDIOC's for each of these categories, or use extended controls to set all these values. I'm hardly an expert on FM transmitters, but it all seems reasonable to me (i.e., not too specific for this chip).
Quoted 4 lines
I am leaning towards extended controls, since that's so easy to extend if needed in the future. And I still intend to add sysfs support to controls in the future. On the other hand, it's a bit harder to use compared to normal VIDIOCs.
Could you please explain more about extended controls vs. VIDIOC's? Pointing drivers which uses one of those also would be worth. But yes, looks like moving this properties to some sort of v4l2 control looks better implementation.
Quoted 9 lines
Quoted 7 lines
RDS related
rds_enabled- Enables or disables the RDS feature.rds_ps_name- Sets the RDS ps name field for transmission.rds_radio_text- Sets the RDS radio text for transmission.rds_pi- Sets the RDS PI field for transmission.rds_pty- Sets the RDS PTY field for transmission.So you set the fields and the RDS encoder will just start using them?
Once you have
rds_enabledset, yes, it will transmit them.Quoted 2 lines
This too can be done with controls (needs some work, though, to support string controls).
Yes, true.
Quoted 42 lines
Quoted 8 lines
Region related
Setting region will affect other region properties.
region_bottom_frequencyregion_channel_spacingregion_preemphasisregion_top_frequencyI do not know enough about FM transmissions to judge this. Are these region properties something that is regulated by some standards commision? Do they also apply when you modulate this over a TV/radio cable system? Do you have some documentation or links that I can look at to learn more about this?
Quoted 11 lines
stereo_enabled- Enables or disables stereo mode.Quoted 5 lines
How does one pass the audio and rds data to the driver? Note that for 2.6.31 we will finalize the V4L2 RDS decoder API (I recently posted an RFC for that, but I haven't had the time to implement the few changes needed). It would be nice if rds modulator support would be modeled after this demodulator API if possible.
I see. This is good. I think the best way is to have a rds modulator interface. This driver have implemented it as sys properties, as described above.
I don't think there is that much overlap, though. The similarities are probably limited to some flags.
Quoted 8 lines
Quoted 3 lines
Does region information really belong in the driver? Perhaps this should be in a user-space library? (just a suggestion, I'm not sure at this stage).
Ok. Yes, this could be better to implement in user land. However, depending on region that would restrict other properties as well. So, letting user space control that, would allow device operate in wrong intervals for frequencies for instance.
But if you are in region A and you setup the device for region B, then it's wrong as well, right?
Quoted 7 lines
Quoted 2 lines
I also wonder if there are legal requirements that have to be followed here?
Yes, the region thing is somehow bound to limits of specific area rules / regulation. For instance, Europe frequencies limits are
.bottom_frequency = 8750, .top_frequency = 10800,
as only an interested reader of this mailinglist maybe i can point you to:
http://linuxwireless.org/en/developers/Regulatory.
It seems to me it is a similar case and can be used for reference.
Quoted 10 lines
BTW, maybe I'm making some confusion, but is there two different APIs for radios? What is the difference in roles of things that goes into
drivers/media/radioanddrivers/media/common/tuners?Quoted 6 lines
Regards,
Hans
--
Hans Verkuil - video4linux developer - sponsored by TANDBERG