FM Transmitter (si4713) and another changes
Subsystems (2)
v2 cover FM Transmitter (si4713) and another changes
Hello all,
It took a few but I'm resending the FM transmitter driver again. Sorry for this delay, but I had another things to give attention.
Anyway, after reading the API and re-writing the code I came up with the following 7 patches. Three of them are in the v4l2 API. The other 4 are for the si4713 device.
It is because of the first 3 patches that I'm sending this as a RFC.
The first and second patches, as suggested before, are creating another v4l2 extended controls class, the V4L2_CTRL_CLASS_FMTX. At this
first interaction, I've put all si4713 device extra properties there. But I think that some of the can be moved to private class (V4L2_CID_PRIVATE_BASE). That's the case of the region related things. Comments are wellcome.
The third patch came *maybe* because I've misunderstood something. But I realized that the v4l2-subdev helper functions for I2C devices assumes that the bridge device will create an I2C adaptor. And in that case, only I2C address and its type are suffient. But in this case, makes no sense to me to create an adaptor for the si4713 platform device driver. This is the case where the device (si4713) is connected to an existing adaptor. That's why I've realized that currently there is no way to pass I2C board info using the current v4l2 I2C helper functions. Other info like irq line and platform data are not passed to subdevices. So, that's why I've created that patch.
The remaining patches are the si4713 device driver itself. As suggested, I've splited the driver into i2c driver and v4l2 radio driver. The first one is exporting it self as a v4l2 subdev as well. Now it is composed by the si4713.c and si4713-subdev.c. But in the future versions I think I'll merge both and remove the si4713.c (by reducing lots of things), because it was mainly designed to be used by the sysfs interface. I've also keeped the sysfs interface (besides the extended control interface). The v4l2 radio driver became a platform driver which is mainly a wrapper to the I2C subdevice. Again here I've found some problem with the device remove. Because, as the I2C helper function assumes the bridge device will create an adaptor, then when the bridge removes the adaptor, its devices will be removed as well. So, when re-inserting the driver, registration will be good. However, if we use an existing adaptor, then we need to remove the i2c client manually. Otherwise it will fail when re-inserting the device.
As I said before, comments are wellcome. I'm mostly to be misunderstanding something from the API.
BR,
Eduardo Valentin (7):
v4l2: video device: Add V4L2_CTRL_CLASS_FMTX controls
v4l2: video device: Add FMTX controls default configurations v4l2_subdev i2c: Add i2c board info to v4l2_i2c_new_subdev
FMTx: si4713: Add files to handle si4713 i2c device
FMTx: si4713: Add files to add radio interface for si4713
FMTx: si4713: Add Kconfig and Makefile entries
FMTx: si4713: Add document file
Documentation/video4linux/si4713.txt | 132 ++ drivers/media/radio/Kconfig | 22 + drivers/media/radio/Makefile | 3 + drivers/media/radio/radio-si4713.c | 345 ++++++ drivers/media/radio/radio-si4713.h | 48 + drivers/media/radio/si4713-subdev.c | 1045 ++++++++++++++++ drivers/media/radio/si4713.c | 2250 ++++++++++++++++++++++++++++++++++ drivers/media/radio/si4713.h | 295 +++++ drivers/media/video/v4l2-common.c | 99 ++- include/linux/videodev2.h | 45 + include/media/v4l2-common.h | 6 + 11 files changed, 4284 insertions(+), 6 deletions(-) create mode 100644 Documentation/video4linux/si4713.txt 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-subdev.c create mode 100644 drivers/media/radio/si4713.c create mode 100644 drivers/media/radio/si4713.h
PATCH v2 1/7 v4l2: video device: Add V4L2_CTRL_CLASS_FMTX controls
This patch adds a new class of extended controls. This class is intended to support Radio Modulators properties such as:
rds, audio limiters, audio compression, pilot tone generation, tuning power levels and region related properties.
--- include/linux/videodev2.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-)
include/linux/videodev2.h +45 -0
@@ -803,6 +803,7 @@ struct v4l2_ext_controls {#define V4L2_CTRL_CLASS_USER 0x00980000/* Old-style 'user' controls */ #define V4L2_CTRL_CLASS_MPEG 0x00990000/* MPEG-compression controls */ #define V4L2_CTRL_CLASS_CAMERA 0x009a0000/* Camera class controls */ +#define V4L2_CTRL_CLASS_FMTX 0x009b0000/* FM Radio Modulator class controls */ #define V4L2_CTRL_ID_MASK (0x0fffffff)#define V4L2_CTRL_ID2CLASS (id) ((id) & 0x0fff0000UL)
@@ -1141,6 +1142,50 @@ enum v4l2_exposure_auto_type {#define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE+16) +/* FM Radio Modulator class control IDs */ +#define V4L2_CID_FMTX_CLASS_BASE (V4L2_CTRL_CLASS_FMTX | 0x900) +#define V4L2_CID_FMTX_CLASS (V4L2_CTRL_CLASS_FMTX | 1) + +#define V4L2_CID_RDS_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 1) +#define V4L2_CID_RDS_PI (V4L2_CID_FMTX_CLASS_BASE + 2) +#define V4L2_CID_RDS_PTY (V4L2_CID_FMTX_CLASS_BASE + 3) +#define V4L2_CID_RDS_PS_NAME (V4L2_CID_FMTX_CLASS_BASE + 4) +#define V4L2_CID_RDS_RADIO_TEXT (V4L2_CID_FMTX_CLASS_BASE + 5) + +#define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 6) +#define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME (V4L2_CID_FMTX_CLASS_BASE + 7) +#define V4L2_CID_AUDIO_LIMITER_DEVIATION (V4L2_CID_FMTX_CLASS_BASE + 8) + +#define V4L2_CID_AUDIO_COMPRESSION_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 9) +#define V4L2_CID_AUDIO_COMPRESSION_GAIN (V4L2_CID_FMTX_CLASS_BASE + 10) +#define V4L2_CID_AUDIO_COMPRESSION_THRESHOLD (V4L2_CID_FMTX_CLASS_BASE + 11) +#define V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME (V4L2_CID_FMTX_CLASS_BASE + 12) +#define V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME (V4L2_CID_FMTX_CLASS_BASE + 13) + +#define V4L2_CID_PILOT_TONE_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 14) +#define V4L2_CID_PILOT_TONE_DEVIATION (V4L2_CID_FMTX_CLASS_BASE + 15) +#define V4L2_CID_PILOT_TONE_FREQUENCY (V4L2_CID_FMTX_CLASS_BASE + 16) + +#define V4L2_CID_REGION (V4L2_CID_FMTX_CLASS_BASE + 17) +enum v4l2_fmtx_region { +V4L2_FMTX_REGION_USA =0 , +V4L2_FMTX_REGION_AUSTRALIA =1 , +V4L2_FMTX_REGION_EUROPE =2 , +V4L2_FMTX_REGION_JAPAN =3 , +V4L2_FMTX_REGION_JAPAN_WIDE_BAND =4 , +}; +#define V4L2_CID_REGION_BOTTOM_FREQUENCY (V4L2_CID_FMTX_CLASS_BASE + 18) +#define V4L2_CID_REGION_TOP_FREQUENCY (V4L2_CID_FMTX_CLASS_BASE + 19) +#define V4L2_CID_REGION_PREEMPHASIS (V4L2_CID_FMTX_CLASS_BASE + 20) +enum v4l2_fmtx_preemphasis { + V4L2_FMTX_PREEMPHASIS_75_uS =0 , + V4L2_FMTX_PREEMPHASIS_50_uS =1 , +V4L2_FMTX_PREEMPHASIS_DISABLED =2 , +}; +#define V4L2_CID_REGION_CHANNEL_SPACING (V4L2_CID_FMTX_CLASS_BASE + 21) +#define V4L2_CID_TUNE_POWER_LEVEL (V4L2_CID_FMTX_CLASS_BASE + 22) +#define V4L2_CID_TUNE_ANTENNA_CAPACITOR (V4L2_CID_FMTX_CLASS_BASE + 23) +/* * T U N I N G */
Signature · 1 line
1.6.2.GIT
PATCH v2 2/7 v4l2: video device: Add FMTX controls default configurations
--- drivers/media/video/v4l2-common.c | 66 +++++++++++++++++++++++++++++++++++++ 1 files changed, 66 insertions(+), 0 deletions(-)
drivers/media/video/v4l2-common.c +66 -0
@@ -340,6 +340,20 @@ const char **v4l2_ctrl_get_menu(u32 id)"Sepia" , NULL }; +static const char *fmtx_region[] = { +"USA region settings" , +"Australia region settings" , +"Europe region settings" , +"Japan region settings" , +"Japan Wide Band region settings" , +NULL , + }; +static const char *fmtx_preemphasis[] = { +"75 useconds" , +"50 useconds" , +"No preemphasis" , +NULL , + };switch (id) {case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ :
@@ -378,6 +392,10 @@ const char **v4l2_ctrl_get_menu(u32 id)return camera_exposure_auto;case V4L2_CID_COLORFX :return colorfx; +case V4L2_CID_REGION : +return fmtx_region; +case V4L2_CID_REGION_PREEMPHASIS : +return fmtx_preemphasis;default :return NULL ; }
@@ -476,6 +494,32 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_ZOOM_CONTINUOUS :return "Zoom, Continuous" ;case V4L2_CID_PRIVACY :return "Privacy" ; +/* FM Radio Modulator control */ +case V4L2_CID_FMTX_CLASS :return "FM Radio Modulator Controls" ; +case V4L2_CID_RDS_ENABLED :return "RDS Feature Enabled" ; +case V4L2_CID_RDS_PI :return "RDS Program ID" ; +case V4L2_CID_RDS_PTY :return "RDS Program Type" ; +case V4L2_CID_RDS_PS_NAME :return "RDS PS Name" ; +case V4L2_CID_RDS_RADIO_TEXT :return "RDS Radio Text" ; +case V4L2_CID_AUDIO_LIMITER_ENABLED :return "Audio Limiter Feature Enabled" ; +case V4L2_CID_AUDIO_LIMITER_RELEASE_TIME :return "Audio Limiter Release Time" ; +case V4L2_CID_AUDIO_LIMITER_DEVIATION :return "Audio Limiter Deviation" ; +case V4L2_CID_AUDIO_COMPRESSION_ENABLED :return "Audio Compression Feature Enabled" ; +case V4L2_CID_AUDIO_COMPRESSION_GAIN :return "Audio Compression Gain" ; +case V4L2_CID_AUDIO_COMPRESSION_THRESHOLD :return "Audio Compression Threshold" ; +case V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME :return "Audio Compression Attack Time" ; +case V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME :return "Audio Compression Release Time" ; +case V4L2_CID_PILOT_TONE_ENABLED :return "Pilot Tone Feature Enabled" ; +case V4L2_CID_PILOT_TONE_DEVIATION :return "Pilot Tone Deviation" ; +case V4L2_CID_PILOT_TONE_FREQUENCY :return "Pilot Tone Frequency" ; +case V4L2_CID_REGION :return "Region Settings" ; +case V4L2_CID_REGION_BOTTOM_FREQUENCY :return "Region Bottom Frequency" ; +case V4L2_CID_REGION_TOP_FREQUENCY :return "Region Top Frequency" ; +case V4L2_CID_REGION_PREEMPHASIS :return "Region Preemphasis" ; +case V4L2_CID_REGION_CHANNEL_SPACING :return "Region Channel Spacing" ; +case V4L2_CID_TUNE_POWER_LEVEL :return "Tune Power Level" ; +case V4L2_CID_TUNE_ANTENNA_CAPACITOR :return "Tune Antenna Capacitor" ; +default :return NULL ; }
@@ -508,6 +552,10 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 stecase V4L2_CID_EXPOSURE_AUTO_PRIORITY :case V4L2_CID_FOCUS_AUTO :case V4L2_CID_PRIVACY : +case V4L2_CID_RDS_ENABLED : +case V4L2_CID_AUDIO_LIMITER_ENABLED : +case V4L2_CID_AUDIO_COMPRESSION_ENABLED : +case V4L2_CID_PILOT_TONE_ENABLED : qctrl->type =V4L2_CTRL_TYPE_BOOLEAN ; min =0 ; max = step =1 ;
@@ -536,12 +584,15 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 stecase V4L2_CID_MPEG_STREAM_VBI_FMT :case V4L2_CID_EXPOSURE_AUTO :case V4L2_CID_COLORFX : +case V4L2_CID_REGION : +case V4L2_CID_REGION_PREEMPHASIS : qctrl->type =V4L2_CTRL_TYPE_MENU ; step =1 ;break ;case V4L2_CID_USER_CLASS :case V4L2_CID_CAMERA_CLASS :case V4L2_CID_MPEG_CLASS : +case V4L2_CID_FMTX_CLASS : qctrl->type =V4L2_CTRL_TYPE_CTRL_CLASS ; qctrl->flags |=V4L2_CTRL_FLAG_READ_ONLY ; min = max = step = def =0 ;
@@ -570,8 +621,23 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 stecase V4L2_CID_BLUE_BALANCE :case V4L2_CID_GAMMA :case V4L2_CID_SHARPNESS : +case V4L2_CID_AUDIO_LIMITER_RELEASE_TIME : +case V4L2_CID_AUDIO_LIMITER_DEVIATION : +case V4L2_CID_AUDIO_COMPRESSION_GAIN : +case V4L2_CID_AUDIO_COMPRESSION_THRESHOLD : +case V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME : +case V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME : +case V4L2_CID_PILOT_TONE_DEVIATION : +case V4L2_CID_PILOT_TONE_FREQUENCY : +case V4L2_CID_TUNE_POWER_LEVEL : +case V4L2_CID_TUNE_ANTENNA_CAPACITOR : qctrl->flags |=V4L2_CTRL_FLAG_SLIDER ;break ; +case V4L2_CID_REGION_BOTTOM_FREQUENCY : +case V4L2_CID_REGION_TOP_FREQUENCY : +case V4L2_CID_REGION_CHANNEL_SPACING : + qctrl->flags |=V4L2_CTRL_FLAG_READ_ONLY ; +break ;case V4L2_CID_PAN_RELATIVE :case V4L2_CID_TILT_RELATIVE :case V4L2_CID_FOCUS_RELATIVE :
Signature · 1 line
1.6.2.GIT
PATCH v2 3/7 v4l2_subdev i2c: Add i2c board info to v4l2_i2c_new_subdev
Device drivers of v4l2_subdev devices may want to have i2c board info data. This patch adds an helper function to allow bridge drivers to pass board specific data to v4l2_subdev drivers.
--- drivers/media/video/v4l2-common.c | 33 +++++++++++++++++++++++++++------ include/media/v4l2-common.h | 6 ++++++ 2 files changed, 33 insertions(+), 6 deletions(-)
drivers/media/video/v4l2-common.c +27 -6
@@ -827,9 +827,9 @@ EXPORT_SYMBOL_GPL(v4l2_i2c_subdev_init);/* Load an i2c sub-device. */ -struct v4l2_subdev *v4l2_i2c_new_subdev (struct v4l2_device *v4l2_dev, -struct i2c_adapter *adapter, -const char *module_name,const char *client_type,u8 addr) +static struct v4l2_subdev *__v4l2_i2c_new_subdev (struct v4l2_device *v4l2_dev, +struct i2c_adapter *adapter,const char *module_name, +const char *client_type,u8 addr,struct i2c_board_info *i) {struct v4l2_subdev *sd =NULL ;struct i2c_client *client;
@@ -842,9 +842,13 @@ struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,/* Setup the i2c board info with the device type and the device address. */ -memset (&info,0 ,sizeof (info)); -strlcpy (info.type, client_type,sizeof (info.type)); - info.addr = addr; +if (!i) { +memset (&info,0 ,sizeof (info)); +strlcpy (info.type, client_type,sizeof (info.type)); + info.addr = addr; + }else { +memcpy (&info, i,sizeof (info)); + }/* Create the i2c client */ client =i2c_new_device (adapter, &info);
@@ -874,8 +878,25 @@ error:i2c_unregister_device (client);return sd; } + +struct v4l2_subdev *v4l2_i2c_new_subdev (struct v4l2_device *v4l2_dev, +struct i2c_adapter *adapter, +const char *module_name,const char *client_type,u8 addr) +{ +return __v4l2_i2c_new_subdev (v4l2_dev, adapter, module_name, + client_type, addr,NULL ); +}EXPORT_SYMBOL_GPL (v4l2_i2c_new_subdev); +struct v4l2_subdev *v4l2_i2c_new_subdev_board_info (struct v4l2_device *v4l2_dev, +struct i2c_adapter *adapter,const char *module_name, +struct i2c_board_info *i) +{ +return __v4l2_i2c_new_subdev (v4l2_dev, adapter, module_name, +NULL ,0 , i); +} +EXPORT_SYMBOL_GPL (v4l2_i2c_new_subdev_board_info); +/* Probe and load an i2c sub-device. */ struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct v4l2_device *v4l2_dev, struct i2c_adapter *adapter,
include/media/v4l2-common.h +6 -0
@@ -130,6 +130,7 @@ int v4l2_chip_match_host(const struct v4l2_dbg_match *match);struct i2c_driver ;struct i2c_adapter ;struct i2c_client ; +struct i2c_board_info ;struct i2c_device_id ;struct v4l2_device ;struct v4l2_subdev ;
@@ -142,6 +143,11 @@ struct v4l2_subdev_ops;struct v4l2_subdev *v4l2_i2c_new_subdev (struct v4l2_device *v4l2_dev,struct i2c_adapter *adapter,const char *module_name,const char *client_type,u8 addr); +/* Same as v4l2_i2c_new_subdev, but with oportunity to pass i2c_board_info +to client device */ +struct v4l2_subdev *v4l2_i2c_new_subdev_board_info (struct v4l2_device *v4l2_dev, +struct i2c_adapter *adapter,const char *module_name, +struct i2c_board_info *i);/* Probe and load an i2c module and return an initialized v4l2_subdev struct. Only call request_module if module_name != NULL. The client_type argument is the name of the chip that's on the adapter. */
Signature · 1 line
1.6.2.GIT
PATCH v2 6/7 FMTx: si4713: Add Kconfig and Makefile entries
In reply to Eduardo Valentin--- drivers/media/radio/Kconfig | 22 ++++++++++++++++++++++ drivers/media/radio/Makefile | 3 +++ 2 files changed, 25 insertions(+), 0 deletions(-)
drivers/media/radio/Kconfig +22 -0
@@ -339,6 +339,28 @@ config RADIO_ZOLTRIX_PORT help Enter the I/O port of your Zoltrix radio card. +config I2C_SI4713 + tristate "I2C driver for Silicon Labs Si4713 device" + depends on I2C && VIDEO_V4L2 + ---help--- + Say Y here if you want support to Si4713 I2C device. + This device driver supports only i2c bus. + + To compile this driver as a module, choose M here: the + module will be called si4713. + +config RADIO_SI4713 + tristate "Silicon Labs Si4713 FM Radio Transmitter support" + depends on I2C && VIDEO_V4L2 + ---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 module is the v4l2 radio + interface for the i2c driver of this device. + + To compile this driver as a module, choose M here: the + module will be called radio-si4713. + config USB_DSBR tristate "D-Link/GemTek USB FM radio support" depends on USB && VIDEO_V4L2
drivers/media/radio/Makefile +3 -0
@@ -15,6 +15,9 @@ 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) += si4713-i2c.o +si4713-i2c-objs := si4713.o si4713-subdev.o +obj-$(CONFIG_RADIO_SI4713) += radio-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
PATCH v2 7/7 FMTx: si4713: Add document file
--- Documentation/video4linux/si4713.txt | 132 ++++++++++++++++++++++++++++++++++ 1 files changed, 132 insertions(+), 0 deletions(-) create mode 100644 Documentation/video4linux/si4713.txt
Documentation/video4linux/si4713.txt new file +132 -0
@@ -0,0 +1,132 @@ +Driver for I2C radios for the Silicon Labs Si4713 FM Radio Transmitters + +Copyright (c) 2009 Nokia Corporation +Contact: Eduardo Valentin <[email protected]> + + +Information about the Device +============================ +This chip is a Silicon Labs product. It is a I2C device, currently on 0×63 address. +Basically, it has transmission and signal noise level measurement features. + +The Si4713 integrates transmit functions for FM broadcast stereo transmission. +The chip also allows integrated receive power scanning to identify low signal +power FM channels. + +The chip is programmed using commands and responses. There are also several +properties which can change the behavior of this chip. + +Users must comply with local regulations on radio frequency (RF) transmission. + +Device driver description +========================= +There are two modules to handle this device. One is a I2C device driver +and the other is a platform driver. + +The I2C device driver exports a v4l2-subdev interface to the kernel. Also +it exports several device properties through sysfs interface to the user land. +All properties can also be accessed by v4l2 extended controls interface, by +using the v4l2-subdev calls (g_ext_ctrls, s_ext_ctrls). + +The platform device driver exports a v4l2 radio device interface to user land. +So, it uses the I2C device driver as a sub device in order to send the user +commands to the actual device. Basically it is a wrapper to the I2C device driver. + +So, in summary, the device driver has two interfaces to the user space. + +Applications can use v4l2 radio API to specify frequency of operation, mute state, +etc. But mostly of its properties will be present in the extended controls. +However, the device properties can also be accessed through its sysfs directory. + +When the v4l2 mute property is set to 1 (true), the driver will turn the chip off. + +Properties description +====================== + +The properties can be accessed in sysfs device directory. Using v4l2 extended +controls as well. + +# ls +acomp_attack_time modalias rds_radio_text +acomp_enabled name region +acomp_gain pilot_deviation region_bottom_frequency +acomp_release_time pilot_enabled region_channel_spacing +acomp_threshold pilot_frequency region_preemphasis +antenna_capacitor power region_top_frequency +bus power_level stereo_enabled +driver rds_enabled subsystem +limiter_deviation rds_pi tune_measure +limiter_enabled rds_ps_name uevent +limiter_release_time rds_pty + +Here is a summary 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. + +* Tuning power + +power_level - Sets the output power level for signal transmission. +antenna_capacitor - This selects the value of antenna tuning capacitor manually +or automatically if set to zero. +tune_measure - With this you can get the value of signal length of a specific frequency. + +* 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_frequency +region_channel_spacing +region_preemphasis +region_top_frequency +region - Selects which country specific setting should be assumed. + +* stereo_enabled - Enables or disables stereo mode. + +Testing +======= +Testing is usually done with fmtools utility for managing FM tuner cards. +The tool can be found under Debian/Testing packages. + +The basic command list is: + +$ fm on # Sets mute = false +$ fm off # Sets mute = true +$ fm <freq> # Tunes to the frequency <freq> + +Of course, you should have the audio working and play something through alsa +API to get something different of mute transmitted. + +To play with the above described properties, you can just use “echo” and +“cat” commands. For example, changing the rds_ps_name property, you just do: + +echo "Dummy FM Station" > /sys/bus/i2c/devices/X-0063/rds_ps_name + +where "X" is the i2c bus id which the device is connected.
Signature · 1 line
1.6.2.GIT
PATCH v2 4/7 FMTx: si4713: Add files to handle si4713 i2c device
In reply to Eduardo ValentinThis patch adds files to control si4713 devices. Internal functions to control device properties and initialization procedures are into these files. Also, a v4l2 subdev interface is also exported. This way other drivers can use this as v4l2 i2c subdevice.
--- drivers/media/radio/si4713-subdev.c | 1045 ++++++++++++++++ drivers/media/radio/si4713.c | 2250 +++++++++++++++++++++++++++++++++++ drivers/media/radio/si4713.h | 295 +++++ 3 files changed, 3590 insertions(+), 0 deletions(-) create mode 100644 drivers/media/radio/si4713-subdev.c create mode 100644 drivers/media/radio/si4713.c create mode 100644 drivers/media/radio/si4713.h
drivers/media/radio/si4713-subdev.c new file +1045 -0
@@ -0,0 +1,1045 @@ +/* +* drivers/media/radio/si4713.c +* +* Silicon Labs Si4713 FM Radio Transmitter I2C commands. +* +* Copyright (c) 2009 Nokia Corporation +* Contact: 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/interrupt.h> +#include <linux/i2c.h> +#include <media/v4l2-device.h> +#include <media/v4l2-ioctl.h> +#include <media/v4l2-i2c-drv.h> + +#include "si4713.h" + +#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 to_si4713_device (sd) container_of(sd, struct si4713_device, sd) + +/* 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) + +/* +* 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; +struct i2c_client *client =v4l2_get_subdevdata (&sdev->sd); + +dev_dbg (&client->dev,"IRQ called, signaling completion work\n" ); +complete (&sdev->work); + +return IRQ_HANDLED ; +} + +static int si4713_write_econtrol (struct si4713_device *sdev, +struct v4l2_ext_control *control) +{ + +s32 rval =0 ; + +switch (control->id) { +/* User class controls */ +case V4L2_CID_AUDIO_MUTE : + rval =si4713_set_mute (sdev, control->value); +break ; +/* FMTX class controls */ +case V4L2_CID_RDS_ENABLED : + rval =si4713_set_rds_enabled (sdev, control->value); +break ; +case V4L2_CID_RDS_PI : + rval =si4713_set_rds_pi (sdev, control->value); +break ; +case V4L2_CID_RDS_PTY : + rval =si4713_set_rds_pty (sdev, control->value); +break ; +/* TODO: String controls not implemented yet */ +case V4L2_CID_RDS_PS_NAME : +case V4L2_CID_RDS_RADIO_TEXT : +break ; + +case V4L2_CID_AUDIO_LIMITER_ENABLED : + rval =si4713_set_limiter_enabled (sdev, control->value); +break ; +case V4L2_CID_AUDIO_LIMITER_RELEASE_TIME : + rval =si4713_set_limiter_release_time (sdev, control->value); +break ; +case V4L2_CID_AUDIO_LIMITER_DEVIATION : + rval =si4713_set_limiter_deviation (sdev, control->value); +break ; + +case V4L2_CID_AUDIO_COMPRESSION_ENABLED : + rval =si4713_set_acomp_enabled (sdev, control->value); +break ; +case V4L2_CID_AUDIO_COMPRESSION_GAIN : + rval =si4713_set_acomp_gain (sdev, control->value); +break ; +case V4L2_CID_AUDIO_COMPRESSION_THRESHOLD : + rval =si4713_set_acomp_threshold (sdev, control->value); +break ; +case V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME : + rval =si4713_set_acomp_attack_time (sdev, control->value); +break ; +case V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME : + rval =si4713_set_acomp_release_time (sdev, control->value); +break ; + +case V4L2_CID_PILOT_TONE_ENABLED : + rval =si4713_set_pilot_enabled (sdev, control->value); +break ; +case V4L2_CID_PILOT_TONE_DEVIATION : + rval =si4713_set_pilot_deviation (sdev, control->value); +break ; +case V4L2_CID_PILOT_TONE_FREQUENCY : + rval =si4713_set_pilot_frequency (sdev, control->value); +break ; + +case V4L2_CID_REGION : + rval =si4713_set_region (sdev, control->value); +break ; +case V4L2_CID_REGION_PREEMPHASIS : + rval =si4713_set_region_preemphasis (sdev, control->value); +break ; +case V4L2_CID_TUNE_POWER_LEVEL : + rval =si4713_set_power_level (sdev, control->value); +break ; +case V4L2_CID_TUNE_ANTENNA_CAPACITOR : + rval =si4713_set_antenna_capacitor (sdev, control->value); +break ; +default : + rval = -EINVAL ; +break ; + }; + +/* FIXME: There are properties with negative values */ +if (rval >=0 ) { + control->value = rval; + rval =0 ; + } + +return rval; +} +static int si4713_read_econtrol (struct si4713_device *sdev, +struct v4l2_ext_control *control) +{ + +s32 rval =0 ; +s8 val; + +switch (control->id) { +/* User class controls */ +case V4L2_CID_AUDIO_MUTE : + rval =si4713_get_mute (sdev); +break ; +/* FMTX class controls */ +case V4L2_CID_RDS_ENABLED : + rval =si4713_get_rds_enabled (sdev); +break ; +case V4L2_CID_RDS_PI : + rval =si4713_get_rds_pi (sdev); +break ; +case V4L2_CID_RDS_PTY : + rval =si4713_get_rds_pty (sdev); +break ; +/* TODO: String controls not implemented yet */ +case V4L2_CID_RDS_PS_NAME : +case V4L2_CID_RDS_RADIO_TEXT : +break ; + +case V4L2_CID_AUDIO_LIMITER_ENABLED : + rval =si4713_get_limiter_enabled (sdev); +break ; +case V4L2_CID_AUDIO_LIMITER_RELEASE_TIME : + rval =si4713_get_limiter_release_time (sdev); +break ; +case V4L2_CID_AUDIO_LIMITER_DEVIATION : + rval =si4713_get_limiter_deviation (sdev); +break ; + +case V4L2_CID_AUDIO_COMPRESSION_ENABLED : + rval =si4713_get_acomp_enabled (sdev); +break ; +case V4L2_CID_AUDIO_COMPRESSION_GAIN : + rval =si4713_get_acomp_gain (sdev); +break ; +case V4L2_CID_AUDIO_COMPRESSION_THRESHOLD : + rval =si4713_get_acomp_threshold (sdev, &val); +if (rval ==0 ) + rval = val; +break ; +case V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME : + rval =si4713_get_acomp_attack_time (sdev); +break ; +case V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME : + rval =si4713_get_acomp_release_time (sdev); +break ; + +case V4L2_CID_PILOT_TONE_ENABLED : + rval =si4713_get_pilot_enabled (sdev); +break ; +case V4L2_CID_PILOT_TONE_DEVIATION : + rval =si4713_get_pilot_deviation (sdev); +break ; +case V4L2_CID_PILOT_TONE_FREQUENCY : + rval =si4713_get_pilot_frequency (sdev); +break ; + +case V4L2_CID_REGION : + rval =si4713_get_region (sdev); +break ; +case V4L2_CID_REGION_BOTTOM_FREQUENCY : + rval =si4713_get_region_bottom_frequency (sdev); +break ; +case V4L2_CID_REGION_TOP_FREQUENCY : + rval =si4713_get_region_top_frequency (sdev); +break ; +case V4L2_CID_REGION_PREEMPHASIS : + rval =si4713_get_region_preemphasis (sdev); +break ; +case V4L2_CID_REGION_CHANNEL_SPACING : + rval =si4713_get_region_channel_spacing (sdev); +break ; +case V4L2_CID_TUNE_POWER_LEVEL : + rval =si4713_get_power_level (sdev); +break ; +case V4L2_CID_TUNE_ANTENNA_CAPACITOR : + rval =si4713_get_antenna_capacitor (sdev); +break ; +default : + rval = -EINVAL ; +break ; + }; + +/* FIXME: There are properties with negative values */ +if (rval >=0 ) { + control->value = rval; + rval =0 ; + } + +return rval; +} + +/* +* Video4Linux Subdev Interface +*/ + +/* +* si4713_s_ext_ctrls - set extended controls value +*/ +static int si4713_s_ext_ctrls (struct v4l2_subdev *sd, +struct v4l2_ext_controls *ctrls) +{ +struct si4713_device *sdev =to_si4713_device (sd); +int i; + +if (ctrls->ctrl_class !=V4L2_CTRL_CLASS_FMTX ) +return -EINVAL ; + +for (i =0 ; i < ctrls->count; i++) { +int err =si4713_write_econtrol (sdev, ctrls->controls + i); + +if (err <0 ) { + ctrls->error_idx = i; +return err; + } + } + +return 0 ; +} + +/* +* si4713_g_ext_ctrls - get extended controls value +*/ +static int si4713_g_ext_ctrls (struct v4l2_subdev *sd, +struct v4l2_ext_controls *ctrls) +{ +struct si4713_device *sdev =to_si4713_device (sd); +int i; + +if (ctrls->ctrl_class !=V4L2_CTRL_CLASS_FMTX ) +return -EINVAL ; + +for (i =0 ; i < ctrls->count; i++) { +int err =si4713_read_econtrol (sdev, ctrls->controls + i); + +if (err <0 ) { + ctrls->error_idx = i; +return err; + } + } + +return 0 ; +} +/* +* si4713_queryctrl - enumerate control items +*/ +static int si4713_queryctrl (struct v4l2_subdev *sd,struct v4l2_queryctrl *qc) +{ +int rval =0 ; + +switch (qc->id) { +/* User class controls */ +/* These are only for kradio and such apps */ +case V4L2_CID_AUDIO_VOLUME : +case V4L2_CID_AUDIO_BALANCE : +case V4L2_CID_AUDIO_BASS : +case V4L2_CID_AUDIO_TREBLE : +case V4L2_CID_AUDIO_LOUDNESS : + rval =v4l2_ctrl_query_fill (qc,0 ,0 ,0 ,0 ); + qc->flags |=V4L2_CTRL_FLAG_DISABLED ; +break ; +case V4L2_CID_AUDIO_MUTE : + rval =v4l2_ctrl_query_fill (qc,0 ,1 ,1 ,DEFAULT_MUTE ); +break ; +/* FMTX class controls */ +case V4L2_CID_RDS_ENABLED : + rval =v4l2_ctrl_query_fill (qc,0 ,1 ,1 ,1 ); +break ; +case V4L2_CID_RDS_PI : + rval =v4l2_ctrl_query_fill (qc,0 ,0xFFFF ,1 ,DEFAULT_RDS_PI ); +break ; +case V4L2_CID_RDS_PTY : + rval =v4l2_ctrl_query_fill (qc,0 ,31 ,1 ,DEFAULT_RDS_PTY ); +break ; +/* TODO: String controls not implemented yet */ +case V4L2_CID_RDS_PS_NAME : + rval =v4l2_ctrl_query_fill (qc,0 ,0 ,0 ,0 ); +break ; +case V4L2_CID_RDS_RADIO_TEXT : + rval =v4l2_ctrl_query_fill (qc,0 ,0 ,0 ,0 ); +break ; + +case V4L2_CID_AUDIO_LIMITER_ENABLED : + rval =v4l2_ctrl_query_fill (qc,0 ,1 ,1 ,1 ); +break ; +case V4L2_CID_AUDIO_LIMITER_RELEASE_TIME : + rval =v4l2_ctrl_query_fill (qc,250 ,MAX_LIMITER_RELEASE_TIME , +50 ,DEFAULT_LIMITER_RTIME ); +break ; +case V4L2_CID_AUDIO_LIMITER_DEVIATION : + rval =v4l2_ctrl_query_fill (qc,0 ,MAX_LIMITER_DEVIATION , +10 ,DEFAULT_LIMITER_DEV ); +break ; + +case V4L2_CID_AUDIO_COMPRESSION_ENABLED : + rval =v4l2_ctrl_query_fill (qc,0 ,1 ,1 ,1 ); +break ; +case V4L2_CID_AUDIO_COMPRESSION_GAIN : + rval =v4l2_ctrl_query_fill (qc,0 ,MAX_ACOMP_GAIN ,1 , +DEFAULT_ACOMP_GAIN ); +break ; +case V4L2_CID_AUDIO_COMPRESSION_THRESHOLD : + rval =v4l2_ctrl_query_fill (qc,MIN_ACOMP_THRESHOLD , +MAX_ACOMP_THRESHOLD ,1 , +DEFAULT_ACOMP_THRESHOLD ); +break ; +case V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME : + rval =v4l2_ctrl_query_fill (qc,0 ,MAX_ACOMP_ATTACK_TIME , +500 ,DEFAULT_ACOMP_ATIME ); +break ; +case V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME : + rval =v4l2_ctrl_query_fill (qc,100000 ,MAX_ACOMP_RELEASE_TIME , +100000 ,DEFAULT_ACOMP_RTIME ); +break ; + +case V4L2_CID_PILOT_TONE_ENABLED : + rval =v4l2_ctrl_query_fill (qc,0 ,1 ,1 ,1 ); +break ; +case V4L2_CID_PILOT_TONE_DEVIATION : + rval =v4l2_ctrl_query_fill (qc,0 ,MAX_PILOT_DEVIATION , +10 ,DEFAULT_PILOT_DEVIATION ); +break ; +case V4L2_CID_PILOT_TONE_FREQUENCY : + rval =v4l2_ctrl_query_fill (qc,0 ,MAX_PILOT_FREQUENCY , +1 ,DEFAULT_PILOT_FREQUENCY ); +break ; + +case V4L2_CID_REGION : + rval =v4l2_ctrl_query_fill (qc,V4L2_FMTX_REGION_USA , +V4L2_FMTX_REGION_JAPAN_WIDE_BAND , +1 ,DEFAULT_REGION_SETTINGS ); +break ; +case V4L2_CID_REGION_BOTTOM_FREQUENCY : + rval =v4l2_ctrl_query_fill (qc,76000 ,108000 ,50 ,108000 ); +break ; +case V4L2_CID_REGION_TOP_FREQUENCY : + rval =v4l2_ctrl_query_fill (qc,76000 ,108000 ,50 ,108000 ); +break ; +case V4L2_CID_REGION_PREEMPHASIS : + rval =v4l2_ctrl_query_fill (qc, V4L2_FMTX_PREEMPHASIS_75_uS, + V4L2_FMTX_PREEMPHASIS_50_uS, +1 , V4L2_FMTX_PREEMPHASIS_50_uS); +break ; +case V4L2_CID_REGION_CHANNEL_SPACING : + rval =v4l2_ctrl_query_fill (qc,50 ,1000 ,100 ,50 ); +break ; +case V4L2_CID_TUNE_POWER_LEVEL : + rval =v4l2_ctrl_query_fill (qc,0 ,120 ,1 ,88 ); +break ; +case V4L2_CID_TUNE_ANTENNA_CAPACITOR : + rval =v4l2_ctrl_query_fill (qc,0 ,191 ,1 ,0 ); +break ; +default : + rval = -EINVAL ; +break ; + }; + +return rval; +} + +/* +* si4713_g_ctrl - get the value of a control +*/ +static int si4713_g_ctrl (struct v4l2_subdev *sd,struct v4l2_control *ctrl) +{ +struct si4713_device *sdev =to_si4713_device (sd); +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_s_ctrl - set the value of a control +*/ +static int si4713_s_ctrl (struct v4l2_subdev *sd,struct v4l2_control *ctrl) +{ +struct si4713_device *sdev =to_si4713_device (sd); +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; +} + +static const struct v4l2_subdev_core_ops si4713_subdev_core_ops = { + .try_ext_ctrls =NULL , + .g_chip_ident =NULL , + .log_status =NULL , +#ifdef CONFIG_VIDEO_ADV_DEBUG + .g_register =NULL , + .s_register =NULL , +#endif + .queryctrl = si4713_queryctrl, + .g_ext_ctrls = si4713_g_ext_ctrls, + .s_ext_ctrls = si4713_s_ext_ctrls, + .g_ctrl = si4713_g_ctrl, + .s_ctrl = si4713_s_ctrl, + .ioctl =NULL , + .querymenu =NULL , + .init =NULL , + .load_fw =NULL , + .reset =NULL , + .s_gpio =NULL , + .s_std =NULL , +}; + +/* +* si4713_g_tuner - get tuner attributes +*/ +static int si4713_g_tuner (struct v4l2_subdev *sd,struct v4l2_tuner *tuner) +{ +struct si4713_device *sdev =to_si4713_device (sd); +int rval; + +if (!sdev) { + rval = -ENODEV ; + goto exit; + } + +if (tuner->index >0 ) { + rval = -EINVAL ; + goto exit; + } + +strncpy (tuner->name,"FM Transmitter" ,32 ); + tuner->type =V4L2_TUNER_RADIO ; + tuner->rxsubchans =V4L2_TUNER_SUB_STEREO |V4L2_TUNER_SUB_MONO ; + tuner->capability =V4L2_TUNER_CAP_STEREO |V4L2_TUNER_CAP_LOW ; + +/* Report current frequency range limits */ + rval =si4713_get_region_bottom_frequency (sdev); +if (rval <0 ) + goto exit; + tuner->rangelow =dev_to_v4l2 (rval /10 ); + rval =si4713_get_region_top_frequency (sdev); +if (rval <0 ) + goto exit; + tuner->rangehigh =dev_to_v4l2 (rval /10 ); + +/* Report current audio mode: mono or stereo */ + tuner->audmode =V4L2_TUNER_MODE_MONO ; + rval =si4713_get_stereo_enabled (sdev); +if (rval <0 ) + goto exit; +if (rval) + tuner->audmode |=V4L2_TUNER_MODE_STEREO ; + +/* Report current signal length */ + rval =si4713_get_tune_measure (sdev); +if (rval <0 ) + goto exit; + tuner->signal = rval; + +/* automatic frequency control: -1: freq to low, 1 freq to high */ + tuner->afc =0 ; + +exit: +return rval; +} + +/* +* si4713_s_tuner - set tuner attributes +*/ +static int si4713_s_tuner (struct v4l2_subdev *sd,struct v4l2_tuner *tuner) +{ +struct si4713_device *sdev =to_si4713_device (sd); +int rval; + +if (!sdev) { + rval = -ENODEV ; + goto exit; + } + +if (tuner->index >0 ) { + rval = -EINVAL ; + goto exit; + } + +/* Set audio mode: mono or stereo */ + rval =si4713_set_stereo_enabled (sdev, + !!(tuner->audmode &V4L2_TUNER_MODE_STEREO )); +if (rval <0 ) + goto exit; + +/* TODO: How to set frequency to measure current signal length */ + +exit: +return rval; +} + +/* +* si4713_g_frequency - get tuner or modulator radio frequency +*/ +static int si4713_g_frequency (struct v4l2_subdev *sd,struct v4l2_frequency *f) +{ +struct si4713_device *sdev =to_si4713_device (sd); +int rval =0 ; +int freq; + + f->type =V4L2_TUNER_RADIO ; + freq =si4713_get_frequency (sdev); + +if (freq <0 ) + rval = freq; +else + f->frequency =dev_to_v4l2 (freq); + +return rval; +} + +/* +* si4713_s_frequency - set tuner or modulator radio frequency +*/ +static int si4713_s_frequency (struct v4l2_subdev *sd,struct v4l2_frequency *f) +{ +struct si4713_device *sdev =to_si4713_device (sd); +int rval =0 ; + +if (f->type !=V4L2_TUNER_RADIO ) { + rval = -EINVAL ; + goto exit; + } + + rval =si4713_set_frequency (sdev,v4l2_to_dev (f->frequency)); + +exit: +return rval; +} + +static const struct v4l2_subdev_tuner_ops si4713_subdev_tuner_ops = { + .g_frequency = si4713_g_frequency, + .s_frequency = si4713_s_frequency, + .g_tuner = si4713_g_tuner, + .s_tuner = si4713_s_tuner, + .s_type_addr =NULL , + .s_config =NULL , + .s_standby =NULL , + .s_mode =NULL , + .s_radio =NULL , +}; + +static const struct v4l2_subdev_ops si4713_subdev_ops = { + .core = &si4713_subdev_core_ops, + .tuner = &si4713_subdev_tuner_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; + + sdev =kzalloc (sizeof *sdev,GFP_KERNEL ); +if (!sdev) { +dev_dbg (&client->dev,"Failed to alloc video device.\n" ); + rval = -ENOMEM ; + goto exit; + } + + sdev->platform_data = client->dev.platform_data; +if (!sdev->platform_data) { +dev_err (&client->dev,"No platform data registered.\n" ); + rval = -ENODEV ; + goto free_sdev; + } + +v4l2_i2c_subdev_init (&sdev->sd, client, &si4713_subdev_ops); + +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_sdev; + } +dev_dbg (&client->dev,"IRQ requested.\n" ); + }else { +dev_info (&client->dev,"IRQ not configure. Using timeouts.\n" ); + } + + rval =sysfs_create_group (&client->dev.kobj, &attr_group); +if (rval <0 ) { +dev_err (&client->dev,"Could not register sysfs interface.\n" ); + goto free_irq; + } + + rval =si4713_probe (sdev); +if (rval <0 ) { +dev_err (&client->dev,"Failed to probe device information.\n" ); + goto free_sysfs; + } + +return 0 ; + +free_sysfs: +sysfs_remove_group (&client->dev.kobj, &attr_group); +free_irq: +if (client->irq) +free_irq (client->irq, sdev); +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 v4l2_subdev *sd =i2c_get_clientdata (client); +struct si4713_device *sdev =to_si4713_device (sd); + +/* our client isn't attached */ +if (!client->adapter) +return -ENODEV ; + +if (sdev) { +sysfs_remove_group (&client->dev.kobj, &attr_group); + +if (sdev->power_state) +si4713_set_power_state (sdev,POWER_DOWN ); + +if (client->irq >0 ) +free_irq (client->irq, sdev); + +v4l2_device_unregister_subdev (sd); + +kfree (sdev); + } + +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 v4l2_i2c_driver_data v4l2_i2c_data = { + .name ="si4713" , + .probe = si4713_i2c_driver_probe, + .remove =__exit_p (si4713_i2c_driver_remove), + .id_table = si4713_id, +}; + +MODULE_LICENSE ("GPL" ); +MODULE_AUTHOR ("Eduardo Valentin <[email protected]>" ); +MODULE_DESCRIPTION ("I2C driver for Si4713 FM Radio Transmitter" ); +MODULE_VERSION ("0.0.1" );
drivers/media/radio/si4713.c new file +2250 -0
1,955 lines not on this page · raw message
drivers/media/radio/si4713.h new file +295 -0
295 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.6.2.GIT
Part of the diff is not shown here. View the raw message.
PATCH v2 5/7 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 | 345 ++++++++++++++++++++++++++++++++++++ drivers/media/radio/radio-si4713.h | 48 +++++ 2 files changed, 393 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 +345 -0
@@ -0,0 +1,345 @@ +/* +* drivers/media/radio/radio-si4713.c +* +* Platform Driver for Silicon Labs Si4713 FM Radio Transmitter: +* +* Copyright (c) 2008 Instituto Nokia de Tecnologia - INdT +* Contact: 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/kernel.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/version.h> +#include <linux/platform_device.h> +#include <linux/i2c.h> +#include <linux/videodev2.h> +#include <media/v4l2-device.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) */ + +/* radio_si4713_fops - file operations interface */ +static const struct v4l2_file_operations radio_si4713_fops = { + .owner =THIS_MODULE , + .ioctl = video_ioctl2, +}; + +/* Video4Linux Interface */ +static int radio_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 ; +} + +static int radio_si4713_vidioc_s_audio (struct file *file,void *priv, +struct v4l2_audio *audio) +{ +if (audio->index !=0 ) +return -EINVAL ; + +return 0 ; +} + +static int radio_si4713_vidioc_g_input (struct file *file,void *priv, +unsigned int *i) +{ + *i =0 ; + +return 0 ; +} + +static int radio_si4713_vidioc_s_input (struct file *file,void *priv, +unsigned int i) +{ +if (i !=0 ) +return -EINVAL ; + +return 0 ; +} + +/* radio_si4713_vidioc_querycap - query device capabilities */ +static int radio_si4713_vidioc_querycap (struct file *file,void *priv, +struct v4l2_capability *capability) +{ +struct radio_si4713_device *rsdev; + + rsdev =video_get_drvdata (video_devdata (file)); + +strlcpy (capability->driver,"radio-si4713" ,sizeof (capability->driver)); +strlcpy (capability->card,"Silicon Labs Si4713 FM Radio Transmitter" , +sizeof (capability->card)); + capability->capabilities =V4L2_CAP_TUNER ; + +return 0 ; +} + +/* radio_si4713_vidioc_queryctrl - enumerate control items */ +static int radio_si4713_vidioc_queryctrl (struct file *file,void *priv, +struct v4l2_queryctrl *qc) +{ + +/* Must be sorted from low to high control ID! */ +static const u32 user_ctrls[] = { +V4L2_CID_USER_CLASS , +V4L2_CID_AUDIO_VOLUME , +V4L2_CID_AUDIO_BALANCE , +V4L2_CID_AUDIO_BASS , +V4L2_CID_AUDIO_TREBLE , +V4L2_CID_AUDIO_LOUDNESS , +V4L2_CID_AUDIO_MUTE , +0 + }; + +/* Must be sorted from low to high control ID! */ +static const u32 fmtx_ctrls[] = { +V4L2_CID_FMTX_CLASS , +V4L2_CID_RDS_ENABLED , +V4L2_CID_RDS_PI , +V4L2_CID_RDS_PTY , +V4L2_CID_RDS_PS_NAME , +V4L2_CID_RDS_RADIO_TEXT , +V4L2_CID_AUDIO_LIMITER_ENABLED , +V4L2_CID_AUDIO_LIMITER_RELEASE_TIME , +V4L2_CID_AUDIO_LIMITER_DEVIATION , +V4L2_CID_AUDIO_COMPRESSION_ENABLED , +V4L2_CID_AUDIO_COMPRESSION_GAIN , +V4L2_CID_AUDIO_COMPRESSION_THRESHOLD , +V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME , +V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME , +V4L2_CID_PILOT_TONE_ENABLED , +V4L2_CID_PILOT_TONE_DEVIATION , +V4L2_CID_PILOT_TONE_FREQUENCY , +V4L2_CID_REGION , +V4L2_CID_REGION_BOTTOM_FREQUENCY , +V4L2_CID_REGION_TOP_FREQUENCY , +V4L2_CID_REGION_PREEMPHASIS , +V4L2_CID_REGION_CHANNEL_SPACING , +V4L2_CID_TUNE_POWER_LEVEL , +V4L2_CID_TUNE_ANTENNA_CAPACITOR , +0 + }; +static const u32 *ctrl_classes[] = { + user_ctrls, + fmtx_ctrls, +NULL + }; +struct radio_si4713_device *rsdev; + + rsdev =video_get_drvdata (video_devdata (file)); + + qc->id =v4l2_ctrl_next (ctrl_classes, qc->id); +if (qc->id ==0 ) +return -EINVAL ; + +if (qc->id ==V4L2_CID_USER_CLASS || qc->id ==V4L2_CID_FMTX_CLASS ) +return v4l2_ctrl_query_fill (qc,0 ,0 ,0 ,0 ); + +return v4l2_device_call_until_err (&rsdev->v4l2_dev,0 , core, + queryctrl, qc); +} + + +/* +* radio_si4713_vidioc_template - Produce a v4l2 vidioc call back. +* Can be used because we are just a wrapper for v4l2_sub_devs. +*/ +#define radio_si4713_vidioc_template (type, callback, arg_type) \ +static int radio_si4713_vidioc_##callback(struct file *file, void *p, \ + arg_type a) \ +{ \ + struct radio_si4713_device *rsdev; \ + \ + rsdev = video_get_drvdata(video_devdata(file)); \ + \ + return v4l2_device_call_until_err(&rsdev->v4l2_dev, 0, type, \ + callback, a); \ +} + +radio_si4713_vidioc_template(core, g_ext_ctrls, struct v4l2_ext_controls *) +radio_si4713_vidioc_template(core, s_ext_ctrls, struct v4l2_ext_controls *) +radio_si4713_vidioc_template(core, g_ctrl, struct v4l2_control *) +radio_si4713_vidioc_template(core, s_ctrl, struct v4l2_control *) +radio_si4713_vidioc_template(tuner, g_tuner, struct v4l2_tuner *) +radio_si4713_vidioc_template(tuner, s_tuner, struct v4l2_tuner *) +radio_si4713_vidioc_template(tuner, g_frequency, struct v4l2_frequency *) +radio_si4713_vidioc_template(tuner, s_frequency, struct v4l2_frequency *) + +static struct v4l2_ioctl_ops radio_si4713_ioctl_ops = { + .vidioc_g_input = radio_si4713_vidioc_g_input, + .vidioc_s_input = radio_si4713_vidioc_s_input, + .vidioc_g_audio = radio_si4713_vidioc_g_audio, + .vidioc_s_audio = radio_si4713_vidioc_s_audio, + .vidioc_querycap = radio_si4713_vidioc_querycap, + .vidioc_queryctrl = radio_si4713_vidioc_queryctrl, + .vidioc_g_ext_ctrls = radio_si4713_vidioc_g_ext_ctrls, + .vidioc_s_ext_ctrls = radio_si4713_vidioc_s_ext_ctrls, + .vidioc_g_ctrl = radio_si4713_vidioc_g_ctrl, + .vidioc_s_ctrl = radio_si4713_vidioc_s_ctrl, + .vidioc_g_tuner = radio_si4713_vidioc_g_tuner, + .vidioc_s_tuner = radio_si4713_vidioc_s_tuner, + .vidioc_g_frequency = radio_si4713_vidioc_g_frequency, + .vidioc_s_frequency = radio_si4713_vidioc_s_frequency, +}; + +/* radio_si4713_vdev_template - video device interface */ +static struct video_device radio_si4713_vdev_template = { + .fops = &radio_si4713_fops, + .name = "radio-si4713", + .release = video_device_release, + .ioctl_ops = &radio_si4713_ioctl_ops, +}; + +/* Platform driver interface */ +/* radio_si4713_pdriver_probe - probe for the device */ +static int radio_si4713_pdriver_probe(struct platform_device *pdev) +{ +struct radio_si4713_platform_data *pdata = pdev->platform_data; +struct radio_si4713_device *rsdev; +struct i2c_adapter *adapter; +struct v4l2_subdev *sd; +int rval =0 ; + +if (!pdata) { +dev_err (&pdev->dev,"Can not proceed without platform data.\n" ); + rval = -EINVAL ; + goto exit; + } + + rsdev =kzalloc (sizeof *rsdev,GFP_KERNEL ); +if (!rsdev) { +dev_err (&pdev->dev,"Failed to alloc video device.\n" ); + rval = -ENOMEM ; + goto exit; + } + + rval =v4l2_device_register (&pdev->dev, &rsdev->v4l2_dev); +if (rval) { +dev_err (&pdev->dev,"Failed to register v4l2 device.\n" ); + goto free_rsdev; + } + + adapter =i2c_get_adapter (pdata->i2c_bus); +if (!adapter) { +dev_err (&pdev->dev,"Can not get i2c adapter %d\n" , + pdata->i2c_bus); + rval = -ENODEV ; + goto unregister_v4l2_dev; + } + + sd =v4l2_i2c_new_subdev_board_info (&rsdev->v4l2_dev, adapter, +"si4713_i2c" , &pdata->child_board_info); +if (!sd) { +dev_err (&pdev->dev,"Can not get v4l2 subdevice\n" ); + rval = -ENODEV ; + goto unregister_v4l2_dev; + } + + rsdev->radio_dev =video_device_alloc (); +if (!rsdev->radio_dev) { +dev_err (&pdev->dev,"Failed to alloc video device.\n" ); + rval = -ENOMEM ; + goto unregister_v4l2_dev; + } + +memcpy (rsdev->radio_dev, &radio_si4713_vdev_template, +sizeof (radio_si4713_vdev_template)); +video_set_drvdata (rsdev->radio_dev, rsdev); +if (video_register_device (rsdev->radio_dev,VFL_TYPE_RADIO , radio_nr)) { +dev_err (&pdev->dev,"Could not register video device.\n" ); + rval = -EIO ; + goto free_vdev; + } +dev_info (&pdev->dev,"New device successfully probed\n" ); + + goto exit; + +free_vdev: +video_device_release (rsdev->radio_dev); +unregister_v4l2_dev: +v4l2_device_unregister (&rsdev->v4l2_dev); +free_rsdev: +kfree (rsdev); +exit: +return rval; +} + +/* radio_si4713_pdriver_remove - remove the device */ +static int __exit radio_si4713_pdriver_remove(struct platform_device *pdev) +{ + struct v4l2_device *v4l2_dev = platform_get_drvdata(pdev); + struct v4l2_subdev *sd, *tmp; + struct radio_si4713_device *rsdev = container_of(v4l2_dev, + struct radio_si4713_device, + v4l2_dev); + + /* + * We want this because we create client based on existing + * adapter. So we may not want to wait existing adapter to be + * unloaded in order to release data created by us. + */ + list_for_each_entry_safe(sd, tmp, &(v4l2_dev)->subdevs, list) + i2c_unregister_device(v4l2_get_subdevdata(sd)); + + video_unregister_device(rsdev->radio_dev); + v4l2_device_unregister(&rsdev->v4l2_dev); + kfree(rsdev); + + return 0; +} + +static struct platform_driver radio_si4713_pdriver = { + .driver = { + .name ="radio-si4713" , + }, + .probe = radio_si4713_pdriver_probe, + .remove = __exit_p(radio_si4713_pdriver_remove), +}; + +/* Module Interface */ +static int __init radio_si4713_module_init(void) +{ +return platform_driver_register (&radio_si4713_pdriver); +} + +static void __exit radio_si4713_module_exit(void) +{ + platform_driver_unregister(&radio_si4713_pdriver); +} + +module_init(radio_si4713_module_init); +module_exit(radio_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 ("Eduardo Valentin <[email protected]>" ); +MODULE_DESCRIPTION ("Platform driver for Si4713 FM Radio Transmitter" ); +MODULE_VERSION ("0.0.1" );
drivers/media/radio/radio-si4713.h new file +48 -0
48 lines not on this page · raw message
Signature · 1 line
1.6.2.GIT
Re: [PATCH v2 1/7] v4l2: video device: Add V4L2_CTRL_CLASS_FMTX controls
In reply to Eduardo ValentinEm Mon, 11 May 2009 12:31:43 +0300
Eduardo Valentin <[email protected]> escreveu:
Quoted 6 lines
This patch adds a new class of extended controls. This class is intended to support Radio Modulators properties such as:
rds, audio limiters, audio compression, pilot tone generation, tuning power levels and region related properties.Signed-off-by Eduardo Valentin <[email protected]>
Eduardo,
Please provide us a patch also for V4L2 API for the new API controls you're adding. I'll hold the analysis of the patch series until you provide us the docs. So, there's no need to resubmit the entire patch series.
The V4L2 API is maintained together with the mercurial development tree, at:
http://linuxtv.org/hg/v4l-dvb/
under v4l2-spec/ directory.
Cheers,
Mauro.
Quoted 57 lines
--- include/linux/videodev2.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-)include/linux/videodev2.h +38
-0@@ -803,6 +803,7 @@ struct v4l2_ext_controls {#define V4L2_CTRL_CLASS_USER 0x00980000/* Old-style 'user' controls */ #define V4L2_CTRL_CLASS_MPEG 0x00990000/* MPEG-compression controls */ #define V4L2_CTRL_CLASS_CAMERA 0x009a0000/* Camera class controls */ +#define V4L2_CTRL_CLASS_FMTX 0x009b0000/* FM Radio Modulator class controls */ #define V4L2_CTRL_ID_MASK (0x0fffffff)#define V4L2_CTRL_ID2CLASS (id) ((id) & 0x0fff0000UL)@@ -1141,6 +1142,50 @@ enum v4l2_exposure_auto_type {#define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE+16) +/* FM Radio Modulator class control IDs */ +#define V4L2_CID_FMTX_CLASS_BASE (V4L2_CTRL_CLASS_FMTX | 0x900) +#define V4L2_CID_FMTX_CLASS (V4L2_CTRL_CLASS_FMTX | 1) + +#define V4L2_CID_RDS_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 1) +#define V4L2_CID_RDS_PI (V4L2_CID_FMTX_CLASS_BASE + 2) +#define V4L2_CID_RDS_PTY (V4L2_CID_FMTX_CLASS_BASE + 3) +#define V4L2_CID_RDS_PS_NAME (V4L2_CID_FMTX_CLASS_BASE + 4) +#define V4L2_CID_RDS_RADIO_TEXT (V4L2_CID_FMTX_CLASS_BASE + 5) + +#define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 6) +#define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME (V4L2_CID_FMTX_CLASS_BASE + 7) +#define V4L2_CID_AUDIO_LIMITER_DEVIATION (V4L2_CID_FMTX_CLASS_BASE + 8) + +#define V4L2_CID_AUDIO_COMPRESSION_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 9) +#define V4L2_CID_AUDIO_COMPRESSION_GAIN (V4L2_CID_FMTX_CLASS_BASE + 10) +#define V4L2_CID_AUDIO_COMPRESSION_THRESHOLD (V4L2_CID_FMTX_CLASS_BASE + 11) +#define V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME (V4L2_CID_FMTX_CLASS_BASE + 12) +#define V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME (V4L2_CID_FMTX_CLASS_BASE + 13) + +#define V4L2_CID_PILOT_TONE_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 14) +#define V4L2_CID_PILOT_TONE_DEVIATION (V4L2_CID_FMTX_CLASS_BASE + 15) +#define V4L2_CID_PILOT_TONE_FREQUENCY (V4L2_CID_FMTX_CLASS_BASE + 16) + +#define V4L2_CID_REGION (V4L2_CID_FMTX_CLASS_BASE + 17) +enum v4l2_fmtx_region { +V4L2_FMTX_REGION_USA =0 , +V4L2_FMTX_REGION_AUSTRALIA =1 , +V4L2_FMTX_REGION_EUROPE =2 , +V4L2_FMTX_REGION_JAPAN =3 , +V4L2_FMTX_REGION_JAPAN_WIDE_BAND =4 , +}; +#define V4L2_CID_REGION_BOTTOM_FREQUENCY (V4L2_CID_FMTX_CLASS_BASE + 18) +#define V4L2_CID_REGION_TOP_FREQUENCY (V4L2_CID_FMTX_CLASS_BASE + 19) +#define V4L2_CID_REGION_PREEMPHASIS (V4L2_CID_FMTX_CLASS_BASE + 20) +enum v4l2_fmtx_preemphasis { + V4L2_FMTX_PREEMPHASIS_75_uS =0 ,
include/linux/videodev2.h enum v4l2_exposure_auto_type { · line 1191
Quoted 10 lines
include/linux/videodev2.h +7
-0+ V4L2_FMTX_PREEMPHASIS_50_uS =1 , + V4L2_FMTX_PREEMPHASIS_DISABLED = 2, +}; +#define V4L2_CID_REGION_CHANNEL_SPACING (V4L2_CID_FMTX_CLASS_BASE + 21) +#define V4L2_CID_TUNE_POWER_LEVEL (V4L2_CID_FMTX_CLASS_BASE + 22) +#define V4L2_CID_TUNE_ANTENNA_CAPACITOR (V4L2_CID_FMTX_CLASS_BASE + 23) +/* * T U N I N G */
Cheers,
Mauro
Re: [PATCH v2 1/7] v4l2: video device: Add V4L2_CTRL_CLASS_FMTX controls
In reply to Eduardo ValentinEm Mon, 11 May 2009 12:31:43 +0300
Eduardo Valentin <[email protected]> escreveu:
Quoted 48 lines
This patch adds a new class of extended controls. This class is intended to support Radio Modulators properties such as:
rds, audio limiters, audio compression, pilot tone generation, tuning power levels and region related properties.Signed-off-by Eduardo Valentin <[email protected]>--- include/linux/videodev2.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-)include/linux/videodev2.h +23
-0@@ -803,6 +803,7 @@ struct v4l2_ext_controls {#define V4L2_CTRL_CLASS_USER 0x00980000/* Old-style 'user' controls */ #define V4L2_CTRL_CLASS_MPEG 0x00990000/* MPEG-compression controls */ #define V4L2_CTRL_CLASS_CAMERA 0x009a0000/* Camera class controls */ +#define V4L2_CTRL_CLASS_FMTX 0x009b0000/* FM Radio Modulator class controls */ #define V4L2_CTRL_ID_MASK (0x0fffffff)#define V4L2_CTRL_ID2CLASS (id) ((id) & 0x0fff0000UL)@@ -1141,6 +1142,50 @@ enum v4l2_exposure_auto_type {#define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE+16) +/* FM Radio Modulator class control IDs */ +#define V4L2_CID_FMTX_CLASS_BASE (V4L2_CTRL_CLASS_FMTX | 0x900) +#define V4L2_CID_FMTX_CLASS (V4L2_CTRL_CLASS_FMTX | 1) + +#define V4L2_CID_RDS_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 1) +#define V4L2_CID_RDS_PI (V4L2_CID_FMTX_CLASS_BASE + 2) +#define V4L2_CID_RDS_PTY (V4L2_CID_FMTX_CLASS_BASE + 3) +#define V4L2_CID_RDS_PS_NAME (V4L2_CID_FMTX_CLASS_BASE + 4) +#define V4L2_CID_RDS_RADIO_TEXT (V4L2_CID_FMTX_CLASS_BASE + 5) + +#define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 6) +#define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME (V4L2_CID_FMTX_CLASS_BASE + 7) +#define V4L2_CID_AUDIO_LIMITER_DEVIATION (V4L2_CID_FMTX_CLASS_BASE + 8) + +#define V4L2_CID_AUDIO_COMPRESSION_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 9) +#define V4L2_CID_AUDIO_COMPRESSION_GAIN (V4L2_CID_FMTX_CLASS_BASE + 10) +#define V4L2_CID_AUDIO_COMPRESSION_THRESHOLD (V4L2_CID_FMTX_CLASS_BASE + 11) +#define V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME (V4L2_CID_FMTX_CLASS_BASE + 12) +#define V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME (V4L2_CID_FMTX_CLASS_BASE + 13) + +#define V4L2_CID_PILOT_TONE_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 14) +#define V4L2_CID_PILOT_TONE_DEVIATION (V4L2_CID_FMTX_CLASS_BASE + 15)
include/linux/videodev2.h enum v4l2_exposure_auto_type { · line 1176
Quoted 10 lines
include/linux/videodev2.h +10
-0+#define V4L2_CID_PILOT_TONE_FREQUENCY (V4L2_CID_FMTX_CLASS_BASE + 16) + +#define V4L2_CID_REGION (V4L2_CID_FMTX_CLASS_BASE + 17) +enum v4l2_fmtx_region { +V4L2_FMTX_REGION_USA =0 , +V4L2_FMTX_REGION_AUSTRALIA =1 , +V4L2_FMTX_REGION_EUROPE =2 , +V4L2_FMTX_REGION_JAPAN =3 , +V4L2_FMTX_REGION_JAPAN_WIDE_BAND =4 , +};
Hmm... the region is not just a derived parameter, based on preemphasis/frequencies, and channel stepping? What this parameter controls?
Quoted 5 lines
include/linux/videodev2.h +5
-0+#define V4L2_CID_REGION_BOTTOM_FREQUENCY (V4L2_CID_FMTX_CLASS_BASE + 18) +#define V4L2_CID_REGION_TOP_FREQUENCY (V4L2_CID_FMTX_CLASS_BASE + 19) +#define V4L2_CID_REGION_PREEMPHASIS (V4L2_CID_FMTX_CLASS_BASE + 20) +enum v4l2_fmtx_preemphasis { + V4L2_FMTX_PREEMPHASIS_75_uS =0 ,
include/linux/videodev2.h enum v4l2_exposure_auto_type { · line 1191
Quoted 10 lines
include/linux/videodev2.h +7
-0+ V4L2_FMTX_PREEMPHASIS_50_uS =1 , + V4L2_FMTX_PREEMPHASIS_DISABLED = 2, +}; +#define V4L2_CID_REGION_CHANNEL_SPACING (V4L2_CID_FMTX_CLASS_BASE + 21) +#define V4L2_CID_TUNE_POWER_LEVEL (V4L2_CID_FMTX_CLASS_BASE + 22) +#define V4L2_CID_TUNE_ANTENNA_CAPACITOR (V4L2_CID_FMTX_CLASS_BASE + 23) +/* * T U N I N G */
Cheers,
Mauro
Re: [PATCH v2 1/7] v4l2: video device: Add V4L2_CTRL_CLASS_FMTX controls
In reply to Eduardo Valentininclude/linux/videodev2.h enum v4l2_exposure_auto_type { · line 1184
Quoted 5 lines · Valentin Eduardo (Nokia-D/Helsinki)
include/linux/videodev2.h +5
-0+enum v4l2_fmtx_preemphasis { + V4L2_FMTX_PREEMPHASIS_75_uS =0 , + V4L2_FMTX_PREEMPHASIS_50_uS =1 , +V4L2_FMTX_PREEMPHASIS_DISABLED =2 , +};
Hello there,
Would it make more sense to make:
"V4L2_FMTX_PREEMPHASIS_DISABLED" as "zero" (false). In my opinion, that would be more clear.
- Eero
Re: [PATCH v2 4/7] FMTx: si4713: Add files to handle si4713 i2c device
In reply to Eduardo ValentinQuoted 37 lines · Valentin Eduardo (Nokia-D/Helsinki)
drivers/media/radio/si4713.c new file +37
-0+/* +* 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 , + },
drivers/media/radio/si4713.c line 197
Quoted 10 lines
drivers/media/radio/si4713.c new file +10
-0+/* Japan wide band */ + { + .channel_spacing = 10, + .bottom_frequency = 7600, + .top_frequency = 10800, + .preemphasis = 1, + .region = 4, + }, +}; +
Hi,
I took a quick peek;
For USA, the correct range appears as:
USA: 87.9 - 107.9
Some more to add:
China: 92 - 108 Mhz
Korea: 88 - 108 Mhz
(Europe?Middle east? Israel: 87.5 - 108)
But please do double check these before changing ;)
- Eero
Re: [PATCH v2 4/7] FMTx: si4713: Add files to handle si4713 i2c device
Quoted 59 lines · Eero Nurkkala
Quoted 37 lines · Valentin Eduardo (Nokia-D/Helsinki)
drivers/media/radio/si4713.c new file +37
-0+/* +* 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 , + },drivers/media/radio/si4713.c line 197
Quoted 10 lines
drivers/media/radio/si4713.c new file +10
-0+/* Japan wide band */ + { + .channel_spacing = 10, + .bottom_frequency = 7600, + .top_frequency = 10800, + .preemphasis = 1, + .region = 4, + }, +}; +Hi,
I took a quick peek;
For USA, the correct range appears as:
USA: 87.9 - 107.9Some more to add:
Quoted 7 lines
China: 92 - 108 Mhz
Korea: 88 - 108 Mhz
(Europe?Middle east? Israel: 87.5 - 108)But please do double check these before changing ;)
- Eero
..And South America goes as USA (should we denote is as North America instead?).
See, North America also has, in addition to USA,:
Canada, Bahamas, Barbaros, Saint Kitts and Nevis, Trinidad and Tobago, Antigua and Barbuda, Costa Rica, Mexico, Grenada, Belize, Panama, Dominical Republic, Saint Vincent and the Grenadines, Dominica, Saint Lucia, El Salvador, Jamaica, Guatemala, Cuba, Hondura, Nicaragua and Haiti)
- Eero
Re: [PATCH v2 4/7] FMTx: si4713: Add files to handle si4713 i2c device
Quoted 8 lines · Eero Nurkkala
Quoted 8 lines
drivers/media/radio/si4713.c line 171
Quoted 8 lines
drivers/media/radio/si4713.c new file +8
-0+/* Australia */ + { + .channel_spacing = 20, + .bottom_frequency = 8750, + .top_frequency = 10800, + .preemphasis = 1, + .region = 1, + },
Hi,
Australia must be 88.1 - 107.9 with 10 channel spacing.
- Eero
Re: [PATCH v2 1/7] v4l2: video device: Add V4L2_CTRL_CLASS_FMTX controls
In reply to Eero NurkkalaHi Eero,
Quoted 9 lines · Nurkkala Eero.An (EXT-Offcode/Oulu)
include/linux/videodev2.h enum v4l2_exposure_auto_type { · line 1184
Quoted 5 lines · Valentin Eduardo (Nokia-D/Helsinki)
include/linux/videodev2.h +5
-0+enum v4l2_fmtx_preemphasis { + V4L2_FMTX_PREEMPHASIS_75_uS =0 , + V4L2_FMTX_PREEMPHASIS_50_uS =1 , +V4L2_FMTX_PREEMPHASIS_DISABLED =2 , +};Hello there,
Quoted 3 lines
Would it make more sense to make:
"V4L2_FMTX_PREEMPHASIS_DISABLED" as "zero" (false). In my opinion, that would be more clear.
Indeed,
Something like:
enum v4l2_fmtx_preemphasis {
V4L2_FMTX_PREEMPHASIS_DISABLED = 0,
V4L2_FMTX_PREEMPHASIS_50_uS = 1,
V4L2_FMTX_PREEMPHASIS_75_uS = 2,
};looks better?
Quoted 2 lines
- Eero
Signature · 1 line
Eduardo Valentin
Re: [PATCH v2 1/7] v4l2: video device: Add V4L2_CTRL_CLASS_FMTX controls
In reply to Mauro Carvalho ChehabQuoted 56 lines · ext Mauro Carvalho Chehab
Em Mon, 11 May 2009 12:31:43 +0300
Eduardo Valentin <[email protected]> escreveu:Quoted 53 lines
This patch adds a new class of extended controls. This class is intended to support Radio Modulators properties such as:
rds, audio limiters, audio compression, pilot tone generation, tuning power levels and region related properties.Signed-off-by Eduardo Valentin <[email protected]>--- include/linux/videodev2.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-)include/linux/videodev2.h +28
-0@@ -803,6 +803,7 @@ struct v4l2_ext_controls {#define V4L2_CTRL_CLASS_USER 0x00980000/* Old-style 'user' controls */ #define V4L2_CTRL_CLASS_MPEG 0x00990000/* MPEG-compression controls */ #define V4L2_CTRL_CLASS_CAMERA 0x009a0000/* Camera class controls */ +#define V4L2_CTRL_CLASS_FMTX 0x009b0000/* FM Radio Modulator class controls */ #define V4L2_CTRL_ID_MASK (0x0fffffff)#define V4L2_CTRL_ID2CLASS (id) ((id) & 0x0fff0000UL)@@ -1141,6 +1142,50 @@ enum v4l2_exposure_auto_type {#define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE+16) +/* FM Radio Modulator class control IDs */ +#define V4L2_CID_FMTX_CLASS_BASE (V4L2_CTRL_CLASS_FMTX | 0x900) +#define V4L2_CID_FMTX_CLASS (V4L2_CTRL_CLASS_FMTX | 1) + +#define V4L2_CID_RDS_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 1) +#define V4L2_CID_RDS_PI (V4L2_CID_FMTX_CLASS_BASE + 2) +#define V4L2_CID_RDS_PTY (V4L2_CID_FMTX_CLASS_BASE + 3) +#define V4L2_CID_RDS_PS_NAME (V4L2_CID_FMTX_CLASS_BASE + 4) +#define V4L2_CID_RDS_RADIO_TEXT (V4L2_CID_FMTX_CLASS_BASE + 5) + +#define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 6) +#define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME (V4L2_CID_FMTX_CLASS_BASE + 7) +#define V4L2_CID_AUDIO_LIMITER_DEVIATION (V4L2_CID_FMTX_CLASS_BASE + 8) + +#define V4L2_CID_AUDIO_COMPRESSION_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 9) +#define V4L2_CID_AUDIO_COMPRESSION_GAIN (V4L2_CID_FMTX_CLASS_BASE + 10) +#define V4L2_CID_AUDIO_COMPRESSION_THRESHOLD (V4L2_CID_FMTX_CLASS_BASE + 11) +#define V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME (V4L2_CID_FMTX_CLASS_BASE + 12) +#define V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME (V4L2_CID_FMTX_CLASS_BASE + 13) + +#define V4L2_CID_PILOT_TONE_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 14) +#define V4L2_CID_PILOT_TONE_DEVIATION (V4L2_CID_FMTX_CLASS_BASE + 15) +#define V4L2_CID_PILOT_TONE_FREQUENCY (V4L2_CID_FMTX_CLASS_BASE + 16) + +#define V4L2_CID_REGION (V4L2_CID_FMTX_CLASS_BASE + 17) +enum v4l2_fmtx_region { +V4L2_FMTX_REGION_USA =0 ,
Quoted 8 lines
include/linux/videodev2.h enum v4l2_exposure_auto_type { · line 1176
Quoted 5 lines
include/linux/videodev2.h +5
-0+V4L2_FMTX_REGION_AUSTRALIA =1 , +V4L2_FMTX_REGION_EUROPE =2 , +V4L2_FMTX_REGION_JAPAN =3 , + V4L2_FMTX_REGION_JAPAN_WIDE_BAND = 4, +};Hmm... the region is not just a derived parameter, based on preemphasis/frequencies, and channel stepping? What this parameter controls?
Hi Mauro, I thought in the opposite way. The other parameters are derived from the region parameter. So, you just set the region, then it will affect the frequency range, channel stepping and preemphasis.
However, there was some resistance to have this inside kernel
(in previous discussion). One suggested to use database in user land (or similar thing). In that case, driver(s) would
report its constraints based on device values, not in region settings. But, this patch set is proposing to have it inside the kernel as you can see.
I'd like to hear more opinions though.
Quoted 22 lines
Quoted 6 lines
include/linux/videodev2.h +5
-0+#define V4L2_CID_REGION_BOTTOM_FREQUENCY (V4L2_CID_FMTX_CLASS_BASE + 18) +#define V4L2_CID_REGION_TOP_FREQUENCY (V4L2_CID_FMTX_CLASS_BASE + 19) +#define V4L2_CID_REGION_PREEMPHASIS (V4L2_CID_FMTX_CLASS_BASE + 20) +enum v4l2_fmtx_preemphasis { + V4L2_FMTX_PREEMPHASIS_75_uS =0 ,include/linux/videodev2.h enum v4l2_exposure_auto_type { · line 1191
Quoted 10 lines
include/linux/videodev2.h +7
-0+ V4L2_FMTX_PREEMPHASIS_50_uS =1 , + V4L2_FMTX_PREEMPHASIS_DISABLED = 2, +}; +#define V4L2_CID_REGION_CHANNEL_SPACING (V4L2_CID_FMTX_CLASS_BASE + 21) +#define V4L2_CID_TUNE_POWER_LEVEL (V4L2_CID_FMTX_CLASS_BASE + 22) +#define V4L2_CID_TUNE_ANTENNA_CAPACITOR (V4L2_CID_FMTX_CLASS_BASE + 23) +/* * T U N I N G */ Cheers,
Mauro
Signature · 1 line
Eduardo Valentin
Re: [PATCH v2 1/7] v4l2: video device: Add V4L2_CTRL_CLASS_FMTX controls
In reply to Mauro Carvalho ChehabHi Mauro,
Quoted 10 lines · ext Mauro Carvalho Chehab
Em Mon, 11 May 2009 12:31:43 +0300
Eduardo Valentin <[email protected]> escreveu:Quoted 6 lines
This patch adds a new class of extended controls. This class is intended to support Radio Modulators properties such as:
rds, audio limiters, audio compression, pilot tone generation, tuning power levels and region related properties.Signed-off-by Eduardo Valentin <[email protected]>
Quoted 8 lines
Eduardo,
Please provide us a patch also for V4L2 API for the new API controls you're adding. I'll hold the analysis of the patch series until you provide us the docs. So, there's no need to resubmit the entire patch series.
The V4L2 API is maintained together with the mercurial development tree, at:
http://linuxtv.org/hg/v4l-dvb/
Right. That's something I was looking for. Thanks for the directions. I'll submit the docs then.
Quoted 79 lines
under v4l2-spec/ directory.
Cheers,
Mauro.Quoted 57 lines
--- include/linux/videodev2.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-)include/linux/videodev2.h +38
-0@@ -803,6 +803,7 @@ struct v4l2_ext_controls {#define V4L2_CTRL_CLASS_USER 0x00980000/* Old-style 'user' controls */ #define V4L2_CTRL_CLASS_MPEG 0x00990000/* MPEG-compression controls */ #define V4L2_CTRL_CLASS_CAMERA 0x009a0000/* Camera class controls */ +#define V4L2_CTRL_CLASS_FMTX 0x009b0000/* FM Radio Modulator class controls */ #define V4L2_CTRL_ID_MASK (0x0fffffff)#define V4L2_CTRL_ID2CLASS (id) ((id) & 0x0fff0000UL)@@ -1141,6 +1142,50 @@ enum v4l2_exposure_auto_type {#define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE+16) +/* FM Radio Modulator class control IDs */ +#define V4L2_CID_FMTX_CLASS_BASE (V4L2_CTRL_CLASS_FMTX | 0x900) +#define V4L2_CID_FMTX_CLASS (V4L2_CTRL_CLASS_FMTX | 1) + +#define V4L2_CID_RDS_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 1) +#define V4L2_CID_RDS_PI (V4L2_CID_FMTX_CLASS_BASE + 2) +#define V4L2_CID_RDS_PTY (V4L2_CID_FMTX_CLASS_BASE + 3) +#define V4L2_CID_RDS_PS_NAME (V4L2_CID_FMTX_CLASS_BASE + 4) +#define V4L2_CID_RDS_RADIO_TEXT (V4L2_CID_FMTX_CLASS_BASE + 5) + +#define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 6) +#define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME (V4L2_CID_FMTX_CLASS_BASE + 7) +#define V4L2_CID_AUDIO_LIMITER_DEVIATION (V4L2_CID_FMTX_CLASS_BASE + 8) + +#define V4L2_CID_AUDIO_COMPRESSION_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 9) +#define V4L2_CID_AUDIO_COMPRESSION_GAIN (V4L2_CID_FMTX_CLASS_BASE + 10) +#define V4L2_CID_AUDIO_COMPRESSION_THRESHOLD (V4L2_CID_FMTX_CLASS_BASE + 11) +#define V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME (V4L2_CID_FMTX_CLASS_BASE + 12) +#define V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME (V4L2_CID_FMTX_CLASS_BASE + 13) + +#define V4L2_CID_PILOT_TONE_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 14) +#define V4L2_CID_PILOT_TONE_DEVIATION (V4L2_CID_FMTX_CLASS_BASE + 15) +#define V4L2_CID_PILOT_TONE_FREQUENCY (V4L2_CID_FMTX_CLASS_BASE + 16) + +#define V4L2_CID_REGION (V4L2_CID_FMTX_CLASS_BASE + 17) +enum v4l2_fmtx_region { +V4L2_FMTX_REGION_USA =0 , +V4L2_FMTX_REGION_AUSTRALIA =1 , +V4L2_FMTX_REGION_EUROPE =2 , +V4L2_FMTX_REGION_JAPAN =3 , +V4L2_FMTX_REGION_JAPAN_WIDE_BAND =4 , +}; +#define V4L2_CID_REGION_BOTTOM_FREQUENCY (V4L2_CID_FMTX_CLASS_BASE + 18) +#define V4L2_CID_REGION_TOP_FREQUENCY (V4L2_CID_FMTX_CLASS_BASE + 19) +#define V4L2_CID_REGION_PREEMPHASIS (V4L2_CID_FMTX_CLASS_BASE + 20) +enum v4l2_fmtx_preemphasis { + V4L2_FMTX_PREEMPHASIS_75_uS =0 ,include/linux/videodev2.h enum v4l2_exposure_auto_type { · line 1191
Quoted 10 lines
include/linux/videodev2.h +7
-0+ V4L2_FMTX_PREEMPHASIS_50_uS =1 , + V4L2_FMTX_PREEMPHASIS_DISABLED = 2, +}; +#define V4L2_CID_REGION_CHANNEL_SPACING (V4L2_CID_FMTX_CLASS_BASE + 21) +#define V4L2_CID_TUNE_POWER_LEVEL (V4L2_CID_FMTX_CLASS_BASE + 22) +#define V4L2_CID_TUNE_ANTENNA_CAPACITOR (V4L2_CID_FMTX_CLASS_BASE + 23) +/* * T U N I N G */ Cheers,
Mauro
Signature · 1 line
Eduardo Valentin
Re: [PATCH v2 1/7] v4l2: video device: Add V4L2_CTRL_CLASS_FMTX controls
In reply to Eduardo ValentinQuoted 78 lines · On Tuesday 12 May 2009 08:10:43 Eduardo Valentin wrote:
Quoted 64 lines · ext Mauro Carvalho Chehab
Em Mon, 11 May 2009 12:31:43 +0300
Eduardo Valentin <[email protected]> escreveu:
Quoted 61 lines
This patch adds a new class of extended controls. This class is intended to support Radio Modulators properties such as:
rds, audio limiters, audio compression, pilot tone generation, tuning power levels and region related properties.Signed-off-by Eduardo Valentin <[email protected]>--- include/linux/videodev2.h | 45+++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-)
include/linux/videodev2.h +0
-0@@ -803,6 +803,7 @@ struct v4l2_ext_controls {#define V4L2_CTRL_CLASS_USER 0x00980000/* Old-style 'user' controls */ #define V4L2_CTRL_CLASS_MPEG 0x00990000/* MPEG-compression controls */ #define
V4L2_CTRL_CLASS_CAMERA0x009a0000/* Camera class
controls */ +#defineV4L2_CTRL_CLASS_FMTX0x009b0000/* FM Radio
Modulator class controls */#define
V4L2_CTRL_ID_MASK(0x0fffffff)
#defineV4L2_CTRL_ID2CLASS(id)((id) &0x0fff0000UL)include/linux/videodev2.h +11
-0@@ -1141,6 +1142,50 @@ enum v4l2_exposure_auto_type {#define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE+16) +/* FM Radio Modulator class control IDs */ +#define V4L2_CID_FMTX_CLASS_BASE (V4L2_CTRL_CLASS_FMTX | 0x900) +#define V4L2_CID_FMTX_CLASS (V4L2_CTRL_CLASS_FMTX | 1) + +#define V4L2_CID_RDS_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 1) +#define V4L2_CID_RDS_PI (V4L2_CID_FMTX_CLASS_BASE + 2) +#define V4L2_CID_RDS_PTY (V4L2_CID_FMTX_CLASS_BASE + 3) +#define V4L2_CID_RDS_PS_NAME (V4L2_CID_FMTX_CLASS_BASE + 4) +#define V4L2_CID_RDS_RADIO_TEXT (V4L2_CID_FMTX_CLASS_BASE + 5) + +#define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FMTX_CLASS_BASE +6) +#define
V4L2_CID_AUDIO_LIMITER_RELEASE_TIME(V4L2_CID_FMTX_CLASS_BASE+ 7)
+#defineV4L2_CID_AUDIO_LIMITER_DEVIATION(V4L2_CID_FMTX_CLASS_BASE+
8) +
+#defineV4L2_CID_AUDIO_COMPRESSION_ENABLED(V4L2_CID_FMTX_CLASS_BASE
+ 9) +#defineV4L2_CID_AUDIO_COMPRESSION_GAIN(V4L2_CID_FMTX_CLASS_BASE+ 10)
+#defineV4L2_CID_AUDIO_COMPRESSION_THRESHOLD(V4L2_CID_FMTX_CLASS_BASE+ 11)
+#defineV4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME(V4L2_CID_FMTX_CLASS_BASE+
12) +#defineV4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME(V4L2_CID_FMTX_CLASS_BASE+
13) +include/linux/videodev2.h +2
-0+#define V4L2_CID_PILOT_TONE_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 14) +#define V4L2_CID_PILOT_TONE_DEVIATION (V4L2_CID_FMTX_CLASS_BASE +15) +#define
V4L2_CID_PILOT_TONE_FREQUENCY(V4L2_CID_FMTX_CLASS_BASE
+ 16) +include/linux/videodev2.h +4
-0+#define V4L2_CID_REGION (V4L2_CID_FMTX_CLASS_BASE + 17) +enum v4l2_fmtx_region { +V4L2_FMTX_REGION_USA =0 , +V4L2_FMTX_REGION_AUSTRALIA =1 ,Quoted 8 lines
include/linux/videodev2.h enum v4l2_exposure_auto_type { · line 1176
Quoted 4 lines
include/linux/videodev2.h +4
-0+V4L2_FMTX_REGION_EUROPE =2 , +V4L2_FMTX_REGION_JAPAN =3 , + V4L2_FMTX_REGION_JAPAN_WIDE_BAND = 4, +};Hmm... the region is not just a derived parameter, based on preemphasis/frequencies, and channel stepping? What this parameter controls?
Hi Mauro, I thought in the opposite way. The other parameters are derived from the region parameter. So, you just set the region, then it will affect the frequency range, channel stepping and preemphasis.
Quoted 8 lines
However, there was some resistance to have this inside kernel (in previous discussion). One suggested to use database in user land (or similar thing). In that case, driver(s) would
report its constraints based on device values, not in region settings. But, this patch set is proposing to have it inside the kernel as you can see.I'd like to hear more opinions though.
I'm opposed to having this in the kernel. This is something that can go into e.g. libv4l2util (in the v4l2-apps directory). If only because this is very much application dependent. Your code assumes a few regions, but I think it is much more common that applications will allow customers to select a country, so that means you need a mapping from country to region. And some countries may use a different range than you think (I doubt you know the frequency ranges for all the countries in the world!) and having a table for all countries in the kernel is simply not the right approach.
Also, such a table definitely does not belong with any particular driver, but should be common code.
The only reason why such a table might end up in the kernel is if there are legal requirements forcing strict control on what is allowed for an FM transmitter in each country, and in that case a similar mechanism as is used for wifi should be used. I know we discussed this earlier, but I've forgotten the exact name of that API.
Regards,
Hans
Quoted 19 lines
Quoted 19 lines
Quoted 10 lines
+#define
V4L2_CID_REGION_BOTTOM_FREQUENCY(V4L2_CID_FMTX_CLASS_BASE+
18) +#defineV4L2_CID_REGION_TOP_FREQUENCY(V4L2_CID_FMTX_CLASS_BASE
+ 19) +#defineV4L2_CID_REGION_PREEMPHASIS(V4L2_CID_FMTX_CLASS_BASE
+ 20) +enumv4l2_fmtx_preemphasis{include/linux/videodev2.h +5
-0+ V4L2_FMTX_PREEMPHASIS_75_uS =0 , + V4L2_FMTX_PREEMPHASIS_50_uS =1 , + V4L2_FMTX_PREEMPHASIS_DISABLED = 2, +}; +#define V4L2_CID_REGION_CHANNEL_SPACING (V4L2_CID_FMTX_CLASS_BASE +Quoted 6 lines
21) +#define
V4L2_CID_TUNE_POWER_LEVEL(V4L2_CID_FMTX_CLASS_BASE+
22) +#defineV4L2_CID_TUNE_ANTENNA_CAPACITOR(V4L2_CID_FMTX_CLASS_BASE+ 23) +
/*
* T U N I N G
*/Cheers,
Mauro
Signature · 1 line
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom
Quoted 18 lines · On Monday 11 May 2009 11:31:42 Eduardo Valentin wrote:
Hello all,
It took a few but I'm resending the FM transmitter driver again. Sorry for this delay, but I had another things to give attention.
Anyway, after reading the API and re-writing the code I came up with the following 7 patches. Three of them are in the v4l2 API. The other 4 are for the si4713 device.
It is because of the first 3 patches that I'm sending this as a RFC.
The first and second patches, as suggested before, are creating another v4l2 extended controls class, the
V4L2_CTRL_CLASS_FMTX. At this first interaction, I've put all si4713 device extra properties there. But I think that some of the can be moved to private class (V4L2_CID_PRIVATE_BASE). That's the case of the region related things. Comments are wellcome.
Quoted 10 lines
The third patch came *maybe* because I've misunderstood something. But I realized that the v4l2-subdev helper functions for I2C devices assumes that the bridge device will create an I2C adaptor. And in that case, only I2C address and its type are suffient. But in this case, makes no sense to me to create an adaptor for the si4713 platform device driver. This is the case where the device (si4713) is connected to an existing adaptor. That's why I've realized that currently there is no way to pass I2C board info using the current v4l2 I2C helper functions. Other info like irq line and platform data are not passed to subdevices. So, that's why I've created that patch.
I've made several changes to the v4l2-subdev helpers: you now pass the i2c adapter directly. I've also fixed the unregister code to properly unregister any i2c client so you can safely rmmod and modprobe the i2c module.
What sort of platform data do you need to pass to the i2c driver? I have yet to see a valid use case for this that can't be handled in a different way. Remember that devices like this are not limited to fixed platforms, but can also be used in USB or PCI devices.
Regards,
Hans
Quoted 54 lines
The remaining patches are the si4713 device driver itself. As suggested, I've splited the driver into i2c driver and v4l2 radio driver. The first one is exporting it self as a v4l2 subdev as well. Now it is composed by the
si4713.candsi4713-subdev.c. But in the future versions I think I'll merge both and remove thesi4713.c(by reducing lots of things), because it was mainly designed to be used by the sysfs interface. I've also keeped the sysfs interface (besides the extended control interface). The v4l2 radio driver became a platform driver which is mainly a wrapper to the I2C subdevice. Again here I've found some problem with the device remove. Because, as the I2C helper function assumes the bridge device will create an adaptor, then when the bridge removes the adaptor, its devices will be removed as well. So, when re-inserting the driver, registration will be good. However, if we use an existing adaptor, then we need to remove the i2c client manually. Otherwise it will fail when re-inserting the device.As I said before, comments are wellcome. I'm mostly to be misunderstanding something from the API.
BR,
Eduardo Valentin (7):
v4l2: video device: AddV4L2_CTRL_CLASS_FMTXcontrols
v4l2: video device: Add FMTX controls default configurationsv4l2_subdevi2c: Add i2c board info tov4l2_i2c_new_subdev
FMTx: si4713: Add files to handle si4713 i2c device
FMTx: si4713: Add files to add radio interface for si4713
FMTx: si4713: AddKconfigandMakefileentries
FMTx: si4713: Add document fileDocumentation/video4linux/si4713.txt | 132 ++ drivers/media/radio/Kconfig | 22 + drivers/media/radio/Makefile | 3 + drivers/media/radio/radio-si4713.c | 345 ++++++ drivers/media/radio/radio-si4713.h | 48 + drivers/media/radio/si4713-subdev.c | 1045 ++++++++++++++++ drivers/media/radio/si4713.c | 2250 ++++++++++++++++++++++++++++++++++ drivers/media/radio/si4713.h | 295 +++++ drivers/media/video/v4l2-common.c | 99 ++- include/linux/videodev2.h | 45 + include/media/v4l2-common.h | 6 + 11 files changed, 4284 insertions(+), 6 deletions(-) create mode 100644 Documentation/video4linux/si4713.txt 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-subdev.c 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 Telecom
Quoted 30 lines · ext Hans Verkuil
Quoted 18 lines · On Monday 11 May 2009 11:31:42 Eduardo Valentin wrote:
Hello all,
It took a few but I'm resending the FM transmitter driver again. Sorry for this delay, but I had another things to give attention.
Anyway, after reading the API and re-writing the code I came up with the following 7 patches. Three of them are in the v4l2 API. The other 4 are for the si4713 device.
It is because of the first 3 patches that I'm sending this as a RFC.
The first and second patches, as suggested before, are creating another v4l2 extended controls class, the
V4L2_CTRL_CLASS_FMTX. At this first interaction, I've put all si4713 device extra properties there. But I think that some of the can be moved to private class (V4L2_CID_PRIVATE_BASE). That's the case of the region related things. Comments are wellcome.Quoted 10 lines
The third patch came *maybe* because I've misunderstood something. But I realized that the v4l2-subdev helper functions for I2C devices assumes that the bridge device will create an I2C adaptor. And in that case, only I2C address and its type are suffient. But in this case, makes no sense to me to create an adaptor for the si4713 platform device driver. This is the case where the device (si4713) is connected to an existing adaptor. That's why I've realized that currently there is no way to pass I2C board info using the current v4l2 I2C helper functions. Other info like irq line and platform data are not passed to subdevices. So, that's why I've created that patch.
Quoted 4 lines
I've made several changes to the v4l2-subdev helpers: you now pass the i2c adapter directly. I've also fixed the unregister code to properly unregister any i2c client so you can safely rmmod and modprobe the i2c module.
Right. I will check those.
Quoted 5 lines
What sort of platform data do you need to pass to the i2c driver? I have yet to see a valid use case for this that can't be handled in a different way. Remember that devices like this are not limited to fixed platforms, but can also be used in USB or PCI devices.
Yes, sure. Well, a simple "set_power" procedure is an example of things that I see as platform specific. Which may be passed by platform data structures. In some platform a set power / reset line may be done by a simple gpio. but in others it may be a different procedure.
Quoted 64 lines
Regards,
Hans
Quoted 54 lines
The remaining patches are the si4713 device driver itself. As suggested, I've splited the driver into i2c driver and v4l2 radio driver. The first one is exporting it self as a v4l2 subdev as well. Now it is composed by the
si4713.candsi4713-subdev.c. But in the future versions I think I'll merge both and remove thesi4713.c(by reducing lots of things), because it was mainly designed to be used by the sysfs interface. I've also keeped the sysfs interface (besides the extended control interface). The v4l2 radio driver became a platform driver which is mainly a wrapper to the I2C subdevice. Again here I've found some problem with the device remove. Because, as the I2C helper function assumes the bridge device will create an adaptor, then when the bridge removes the adaptor, its devices will be removed as well. So, when re-inserting the driver, registration will be good. However, if we use an existing adaptor, then we need to remove the i2c client manually. Otherwise it will fail when re-inserting the device.As I said before, comments are wellcome. I'm mostly to be misunderstanding something from the API.
BR,
Eduardo Valentin (7):
v4l2: video device: AddV4L2_CTRL_CLASS_FMTXcontrols
v4l2: video device: Add FMTX controls default configurationsv4l2_subdevi2c: Add i2c board info tov4l2_i2c_new_subdev
FMTx: si4713: Add files to handle si4713 i2c device
FMTx: si4713: Add files to add radio interface for si4713
FMTx: si4713: AddKconfigandMakefileentries
FMTx: si4713: Add document fileDocumentation/video4linux/si4713.txt | 132 ++ drivers/media/radio/Kconfig | 22 + drivers/media/radio/Makefile | 3 + drivers/media/radio/radio-si4713.c | 345 ++++++ drivers/media/radio/radio-si4713.h | 48 + drivers/media/radio/si4713-subdev.c | 1045 ++++++++++++++++ drivers/media/radio/si4713.c | 2250 ++++++++++++++++++++++++++++++++++ drivers/media/radio/si4713.h | 295 +++++ drivers/media/video/v4l2-common.c | 99 ++- include/linux/videodev2.h | 45 + include/media/v4l2-common.h | 6 + 11 files changed, 4284 insertions(+), 6 deletions(-) create mode 100644 Documentation/video4linux/si4713.txt 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-subdev.c 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 Telecom
Signature · 1 line
Eduardo Valentin
Quoted 44 lines · Valentin Eduardo (Nokia-D/Helsinki)
Quoted 30 lines · ext Hans Verkuil
Quoted 18 lines · On Monday 11 May 2009 11:31:42 Eduardo Valentin wrote:
Hello all,
It took a few but I'm resending the FM transmitter driver again. Sorry for this delay, but I had another things to give attention.
Anyway, after reading the API and re-writing the code I came up with the following 7 patches. Three of them are in the v4l2 API. The other 4 are for the si4713 device.
It is because of the first 3 patches that I'm sending this as a RFC.
The first and second patches, as suggested before, are creating another v4l2 extended controls class, the
V4L2_CTRL_CLASS_FMTX. At this first interaction, I've put all si4713 device extra properties there. But I think that some of the can be moved to private class (V4L2_CID_PRIVATE_BASE). That's the case of the region related things. Comments are wellcome.Quoted 10 lines
The third patch came *maybe* because I've misunderstood something. But I realized that the v4l2-subdev helper functions for I2C devices assumes that the bridge device will create an I2C adaptor. And in that case, only I2C address and its type are suffient. But in this case, makes no sense to me to create an adaptor for the si4713 platform device driver. This is the case where the device (si4713) is connected to an existing adaptor. That's why I've realized that currently there is no way to pass I2C board info using the current v4l2 I2C helper functions. Other info like irq line and platform data are not passed to subdevices. So, that's why I've created that patch.
Quoted 4 lines
I've made several changes to the v4l2-subdev helpers: you now pass the i2c adapter directly. I've also fixed the unregister code to properly unregister any i2c client so you can safely rmmod and modprobe the i2c module.
Right. I will check those.
Quoted 5 lines
What sort of platform data do you need to pass to the i2c driver? I have yet to see a valid use case for this that can't be handled in a different way. Remember that devices like this are not limited to fixed platforms, but can also be used in USB or PCI devices.
Quoted 4 lines
Yes, sure. Well, a simple "
set_power" procedure is an example of things that I see as platform specific. Which may be passed by platform data structures. In some platform a set power / reset line may be done by a simple gpio. but in others it may be a different procedure.
Also, the IRQ line value can also be passed to device driver using the i2c board info. That's another way of use of this i2c board info.
Quoted 68 lines
Quoted 65 lines
Regards,
Hans
Quoted 54 lines
The remaining patches are the si4713 device driver itself. As suggested, I've splited the driver into i2c driver and v4l2 radio driver. The first one is exporting it self as a v4l2 subdev as well. Now it is composed by the
si4713.candsi4713-subdev.c. But in the future versions I think I'll merge both and remove thesi4713.c(by reducing lots of things), because it was mainly designed to be used by the sysfs interface. I've also keeped the sysfs interface (besides the extended control interface). The v4l2 radio driver became a platform driver which is mainly a wrapper to the I2C subdevice. Again here I've found some problem with the device remove. Because, as the I2C helper function assumes the bridge device will create an adaptor, then when the bridge removes the adaptor, its devices will be removed as well. So, when re-inserting the driver, registration will be good. However, if we use an existing adaptor, then we need to remove the i2c client manually. Otherwise it will fail when re-inserting the device.As I said before, comments are wellcome. I'm mostly to be misunderstanding something from the API.
BR,
Eduardo Valentin (7):
v4l2: video device: AddV4L2_CTRL_CLASS_FMTXcontrols
v4l2: video device: Add FMTX controls default configurationsv4l2_subdevi2c: Add i2c board info tov4l2_i2c_new_subdev
FMTx: si4713: Add files to handle si4713 i2c device
FMTx: si4713: Add files to add radio interface for si4713
FMTx: si4713: AddKconfigandMakefileentries
FMTx: si4713: Add document fileDocumentation/video4linux/si4713.txt | 132 ++ drivers/media/radio/Kconfig | 22 + drivers/media/radio/Makefile | 3 + drivers/media/radio/radio-si4713.c | 345 ++++++ drivers/media/radio/radio-si4713.h | 48 + drivers/media/radio/si4713-subdev.c | 1045 ++++++++++++++++ drivers/media/radio/si4713.c | 2250 ++++++++++++++++++++++++++++++++++ drivers/media/radio/si4713.h | 295 +++++ drivers/media/video/v4l2-common.c | 99 ++- include/linux/videodev2.h | 45 + include/media/v4l2-common.h | 6 + 11 files changed, 4284 insertions(+), 6 deletions(-) create mode 100644 Documentation/video4linux/si4713.txt 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-subdev.c 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 TelecomSignature · 1 line
Eduardo Valentin
Signature · 1 line
Eduardo Valentin
Re: [PATCH v2 1/7] v4l2: video device: Add V4L2_CTRL_CLASS_FMTX controls
In reply to Eduardo ValentinEm Tue, 12 May 2009 09:10:43 +0300
Eduardo Valentin <[email protected]> escreveu:
Quoted 70 lines · ext Mauro Carvalho Chehab
Quoted 56 lines
Em Mon, 11 May 2009 12:31:43 +0300
Eduardo Valentin <[email protected]> escreveu:Quoted 53 lines
This patch adds a new class of extended controls. This class is intended to support Radio Modulators properties such as:
rds, audio limiters, audio compression, pilot tone generation, tuning power levels and region related properties.Signed-off-by Eduardo Valentin <[email protected]>--- include/linux/videodev2.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-)include/linux/videodev2.h +28
-0@@ -803,6 +803,7 @@ struct v4l2_ext_controls {#define V4L2_CTRL_CLASS_USER 0x00980000/* Old-style 'user' controls */ #define V4L2_CTRL_CLASS_MPEG 0x00990000/* MPEG-compression controls */ #define V4L2_CTRL_CLASS_CAMERA 0x009a0000/* Camera class controls */ +#define V4L2_CTRL_CLASS_FMTX 0x009b0000/* FM Radio Modulator class controls */ #define V4L2_CTRL_ID_MASK (0x0fffffff)#define V4L2_CTRL_ID2CLASS (id) ((id) & 0x0fff0000UL)@@ -1141,6 +1142,50 @@ enum v4l2_exposure_auto_type {#define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE+16) +/* FM Radio Modulator class control IDs */ +#define V4L2_CID_FMTX_CLASS_BASE (V4L2_CTRL_CLASS_FMTX | 0x900) +#define V4L2_CID_FMTX_CLASS (V4L2_CTRL_CLASS_FMTX | 1) + +#define V4L2_CID_RDS_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 1) +#define V4L2_CID_RDS_PI (V4L2_CID_FMTX_CLASS_BASE + 2) +#define V4L2_CID_RDS_PTY (V4L2_CID_FMTX_CLASS_BASE + 3) +#define V4L2_CID_RDS_PS_NAME (V4L2_CID_FMTX_CLASS_BASE + 4) +#define V4L2_CID_RDS_RADIO_TEXT (V4L2_CID_FMTX_CLASS_BASE + 5) + +#define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 6) +#define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME (V4L2_CID_FMTX_CLASS_BASE + 7) +#define V4L2_CID_AUDIO_LIMITER_DEVIATION (V4L2_CID_FMTX_CLASS_BASE + 8) + +#define V4L2_CID_AUDIO_COMPRESSION_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 9) +#define V4L2_CID_AUDIO_COMPRESSION_GAIN (V4L2_CID_FMTX_CLASS_BASE + 10) +#define V4L2_CID_AUDIO_COMPRESSION_THRESHOLD (V4L2_CID_FMTX_CLASS_BASE + 11) +#define V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME (V4L2_CID_FMTX_CLASS_BASE + 12) +#define V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME (V4L2_CID_FMTX_CLASS_BASE + 13) + +#define V4L2_CID_PILOT_TONE_ENABLED (V4L2_CID_FMTX_CLASS_BASE + 14) +#define V4L2_CID_PILOT_TONE_DEVIATION (V4L2_CID_FMTX_CLASS_BASE + 15) +#define V4L2_CID_PILOT_TONE_FREQUENCY (V4L2_CID_FMTX_CLASS_BASE + 16) + +#define V4L2_CID_REGION (V4L2_CID_FMTX_CLASS_BASE + 17) +enum v4l2_fmtx_region { +V4L2_FMTX_REGION_USA =0 ,Quoted 8 lines
include/linux/videodev2.h enum v4l2_exposure_auto_type { · line 1176
Quoted 5 lines
include/linux/videodev2.h +5
-0+V4L2_FMTX_REGION_AUSTRALIA =1 , +V4L2_FMTX_REGION_EUROPE =2 , +V4L2_FMTX_REGION_JAPAN =3 , + V4L2_FMTX_REGION_JAPAN_WIDE_BAND = 4, +};Hmm... the region is not just a derived parameter, based on preemphasis/frequencies, and channel stepping? What this parameter controls?
Hi Mauro, I thought in the opposite way. The other parameters are derived from the region parameter. So, you just set the region, then it will affect the frequency range, channel stepping and preemphasis.
Quoted 5 lines
However, there was some resistance to have this inside kernel
(in previous discussion). One suggested to use database in user land (or similar thing). In that case, driver(s) would
report its constraints based on device values, not in region settings. But, this patch set is proposing to have it inside the kernel as you can see.
The point is that the region and the other parameters are interrelated. So, you're specifying the same thing twice. In order to follow the V4L2 spirit, where video standards aren't determined by a Country based table, but, instead, by their technical differences, IMO, we should remove this. Also, I don't doubt that some countries would come with new settings as they deploy some digital radio broadcast standard.
Quoted 1 line
I'd like to hear more opinions though.
Yes, it would be nice to have more opinions about the API changes.
Cheers,
Mauro
Cheers,
Mauro
Re: [PATCH v2 1/7] v4l2: video device: Add V4L2_CTRL_CLASS_FMTX controls
In reply to Hans VerkuilEm Tue, 12 May 2009 08:26:40 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 5 lines
The only reason why such a table might end up in the kernel is if there are legal requirements forcing strict control on what is allowed for an FM transmitter in each country, and in that case a similar mechanism as is used for wifi should be used. I know we discussed this earlier, but I've forgotten the exact name of that API.
If the usage of FM transmission is for very short range transmissions (for example, to listen to a phone call inside your car stereo, or to listen to your baby's room noises or to see him while you're in the kitchen), I doubt that there are any legal requirements. Such usage is called by the regulatory agencies as "secondary usage"[1]. The secondary usage for FM and for their adjacent frequencies (the TV range) should allow such domestic usage [2]. In general, the restriction for secondary usage is just the power level, to avoid interferences with the primary usage. In general, the secondary usage for TV and FM ranges are the same (and both ranges are adjacent).
On the other hand, for FM primary usage, e. g. a FM broadcaster, the restriction is that you should transmit _ONLY_ at the authorized frequency, at the specified maximum power (that may have a different max power during the day or during the night), using strict shapes for frequency shift, and for modulation levels. It also restricts the location of the FM station, and the characteristics of the antenna beams. Such constraints require application, infrastructure and hardware control that couldn't be done at kernel level.
So, I don't see how legal issues might affect this driver.
[1] Maybe the specific term may change from country to country, but the idea remains the same, since this concept exists on ITU-R regulations.
[2] I'm not aware of any country that forbids the usage of FM/TV ranges for domestic usage. Yet, if such country does exist, then the usage of this module should be forbidden at such country, no matter what frequency you're generating. So, again, it seems pointless to add such restriction in kernel.
Cheers,
Mauro
Re: [PATCH v2 1/7] v4l2: video device: Add V4L2_CTRL_CLASS_FMTX controls
Quoted 29 lines · ext Mauro Carvalho Chehab
Em Tue, 12 May 2009 08:26:40 +0200
Hans Verkuil <[email protected]> escreveu:Quoted 5 lines
The only reason why such a table might end up in the kernel is if there are legal requirements forcing strict control on what is allowed for an FM transmitter in each country, and in that case a similar mechanism as is used for wifi should be used. I know we discussed this earlier, but I've forgotten the exact name of that API.
If the usage of FM transmission is for very short range transmissions (for example, to listen to a phone call inside your car stereo, or to listen to your baby's room noises or to see him while you're in the kitchen), I doubt that there are any legal requirements. Such usage is called by the regulatory agencies as "secondary usage"[1]. The secondary usage for FM and for their adjacent frequencies (the TV range) should allow such domestic usage [2]. In general, the restriction for secondary usage is just the power level, to avoid interferences with the primary usage. In general, the secondary usage for TV and FM ranges are the same (and both ranges are adjacent).
On the other hand, for FM primary usage, e. g. a FM broadcaster, the restriction is that you should transmit _ONLY_ at the authorized frequency, at the specified maximum power (that may have a different max power during the day or during the night), using strict shapes for frequency shift, and for modulation levels. It also restricts the location of the FM station, and the characteristics of the antenna beams. Such constraints require application, infrastructure and hardware control that couldn't be done at kernel level.
So, I don't see how legal issues might affect this driver.
Quoted 7 lines
[1] Maybe the specific term may change from country to country, but the idea remains the same, since this concept exists on ITU-R regulations.
[2] I'm not aware of any country that forbids the usage of FM/TV ranges for domestic usage. Yet, if such country does exist, then the usage of this module should be forbidden at such country, no matter what frequency you're generating. So, again, it seems pointless to add such restriction in kernel.
Right. I've to agree that there is no need to have those in kernel. Better to leave this role to user land, if some legal requirement is needed then. I'll resend the patches without the region settings. It will export only the device limits. I believe that user land can, on top of that, handle the channel spacing and frequency limits. Of course, leaving a way to set/get the preemphasis will be kept. But not bound to a region setting anymore.
Quoted 3 lines
Cheers,
Mauro
Cheers,
Signature · 1 line
Eduardo Valentin