All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv7 0/9] FM Transmitter (si4713) and another changes
@ 2009-06-12 17:30 Eduardo Valentin
  2009-06-12 17:30 ` [PATCHv7 1/9] v4l2-subdev.h: Add g_modulator callbacks to subdev api Eduardo Valentin
  2009-06-14 11:37 ` [PATCHv7 0/9] FM Transmitter (si4713) and another changes Hans Verkuil
  0 siblings, 2 replies; 33+ messages in thread
From: Eduardo Valentin @ 2009-06-12 17:30 UTC (permalink / raw)
  To: ext Hans Verkuil, ext Mauro Carvalho Chehab
  Cc: Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media, Eduardo Valentin

Hello all,

  I'm resending the FM transmitter driver and the proposed changes in
v4l2 api files in order to cover the fmtx extended controls class.

  Difference from version #6 is that now I've added added lots of comments
made by Hans. Here is a list of changes:
- Reduce card type string
- Remove unused ext controls
- Remove s/g_audio and add s/g_audout and enumaudout
- remove g/s_input
- remove s/g_tuner and add s/g_modulator on subdev and platform driver
- reduce function names
- Update documentation
- remove a few unused and empty lines
- remove sysfs interface
- rename dev_to_v4l2 to si4713_to_v4l2 (and vice-versa) macros
- Remove disabled controls
- Add string support
- remove v4l2_i2c_driver_data
- Join si4713.c with si4713-subdev.c
- move platform data to include/media
- update documentation

And now this series is based on two of Hans' trees:
http://www.linuxtv.org/hg/~hverkuil/v4l-dvb-subdev2.
http://www.linuxtv.org/hg/~hverkuil/v4l-dvb-str.

The first tree has refactoring of v4l2 i2c helper functions. The second
one has string support for extended controls, which is used in this driver.

  So, now the series includes changes to add the new v4l2
FMTX extended controls (and its documetation) and si4713 i2c and platform
drivers (and its documentation as well). Besides that, there is also
a patch to add g_modulator to v4l2-subdev and a patch to add support
for fm tx class in v4l2-ctl util.

  In the TODO list there are two things:
i. the signal level measurement property is missing.
ii. Re-factor the driver so all that get/set internal functions are removed.

  I believe those TODO's can be done later on, if there is still time to get
this driver merged into this window. But of course, this is my opinion,
I will understand also if you ask to do them before merge it.

  With these series, the driver is now functional through the v4l2 extended
controls changes. Here is an output of v4l2-ctl:
 # v4l2-ctl -d /dev/radio0 -l --all
Driver Info:
        Driver name   : radio-si4713
        Card type     : Silicon Labs Si4713 Modulator
        Bus info      : 
        Driver version: 0
        Capabilities  : 0x00080000
                Modulator
Audio output: 0 (FM Modulator Audio Out)
Frequency: 1552000 (97000.000000 MHz)
Video Standard = 0x00000000
Modulator:
        Name                 : FM Modulator
        Capabilities         : 62.5 Hz stereo 
        Frequency range      : 76.0 MHz - 108.0 MHz
        Available subchannels: mono stereo 

User Controls

                           mute (bool) : default=1 value=0

FM Radio Modulator Controls

            rds_feature_enabled (bool) : default=1 value=1
                 rds_program_id (int)  : min=0 max=65535 step=1 default=0 value=0
               rds_program_type (int)  : min=0 max=31 step=1 default=0 value=0
                    rds_ps_name (str)  : value='Si4713  ' len=8
' len=9          rds_radio_text (str)  : value='Si4713  
  audio_limiter_feature_enabled (bool) : default=1 value=1
     audio_limiter_release_time (int)  : min=250 max=102390 step=50 default=5010 value=5010 flags=slider
        audio_limiter_deviation (int)  : min=0 max=90000 step=10 default=66250 value=66250 flags=slider
audio_compression_feature_enabl (bool) : default=1 value=1
         audio_compression_gain (int)  : min=0 max=20 step=1 default=15 value=15 flags=slider
    audio_compression_threshold (int)  : min=-40 max=0 step=1 default=-40 value=-40 flags=slider
  audio_compression_attack_time (int)  : min=0 max=5000 step=500 default=0 value=2000 flags=slider
 audio_compression_release_time (int)  : min=100000 max=1000000 step=100000 default=1000000 value=1000000 flags=slider
     pilot_tone_feature_enabled (bool) : default=1 value=1
           pilot_tone_deviation (int)  : min=0 max=90000 step=10 default=6750 value=6750 flags=slider
           pilot_tone_frequency (int)  : min=0 max=19000 step=1 default=19000 value=19000 flags=slider
          pre_emphasis_settings (menu) : min=0 max=2 default=1 value=1
               tune_power_level (int)  : min=0 max=120 step=1 default=88 value=120 flags=slider
         tune_antenna_capacitor (int)  : min=0 max=191 step=1 default=0 value=68 flags=slider


  Again, comments are welcome.

BR,

Eduardo Valentin (9):
  v4l2-subdev.h: Add g_modulator callbacks to subdev api
  v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX controls
  v4l2: video device: Add FM_TX controls default configurations
  v4l2-ctl: Add support for FM TX controls
  v4l2-spec: Add documentation description for FM TX extended control
    class
  FMTx: si4713: Add files to add radio interface for si4713
  FMTx: si4713: Add files to handle si4713 i2c device
  FMTx: si4713: Add Kconfig and Makefile entries
  FMTx: si4713: Add document file

 linux/Documentation/video4linux/si4713.txt |  137 ++
 linux/drivers/media/radio/Kconfig          |   22 +
 linux/drivers/media/radio/Makefile         |    2 +
 linux/drivers/media/radio/radio-si4713.c   |  325 ++++
 linux/drivers/media/radio/si4713-i2c.c     | 2813 ++++++++++++++++++++++++++++
 linux/drivers/media/radio/si4713-i2c.h     |  226 +++
 linux/drivers/media/video/v4l2-common.c    |   50 +
 linux/include/linux/videodev2.h            |   34 +
 linux/include/media/si4713.h               |   40 +
 linux/include/media/v4l2-subdev.h          |    2 +
 v4l2-apps/util/v4l2-ctl.cpp                |   36 +
 v4l2-spec/Makefile                         |    1 +
 v4l2-spec/biblio.sgml                      |   10 +
 v4l2-spec/controls.sgml                    |  205 ++
 14 files changed, 3903 insertions(+), 0 deletions(-)
 create mode 100644 linux/Documentation/video4linux/si4713.txt
 create mode 100644 linux/drivers/media/radio/radio-si4713.c
 create mode 100644 linux/drivers/media/radio/si4713-i2c.c
 create mode 100644 linux/drivers/media/radio/si4713-i2c.h
 create mode 100644 linux/include/media/si4713.h


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCHv7 1/9] v4l2-subdev.h: Add g_modulator callbacks to subdev api
  2009-06-12 17:30 [PATCHv7 0/9] FM Transmitter (si4713) and another changes Eduardo Valentin
@ 2009-06-12 17:30 ` Eduardo Valentin
  2009-06-12 17:30   ` [PATCHv7 2/9] v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX controls Eduardo Valentin
  2009-06-14 11:37 ` [PATCHv7 0/9] FM Transmitter (si4713) and another changes Hans Verkuil
  1 sibling, 1 reply; 33+ messages in thread
From: Eduardo Valentin @ 2009-06-12 17:30 UTC (permalink / raw)
  To: ext Hans Verkuil, ext Mauro Carvalho Chehab
  Cc: Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media, Eduardo Valentin

Signed-off-by: Eduardo Valentin <eduardo.valentin@nokia.com>
---
 linux/include/media/v4l2-subdev.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/linux/include/media/v4l2-subdev.h b/linux/include/media/v4l2-subdev.h
index 5dcb367..4dc3788 100644
--- a/linux/include/media/v4l2-subdev.h
+++ b/linux/include/media/v4l2-subdev.h
@@ -137,6 +137,8 @@ struct v4l2_subdev_tuner_ops {
 	int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
 	int (*g_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt);
 	int (*s_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt);
+	int (*g_modulator)(struct v4l2_subdev *sd, struct v4l2_modulator *vm);
+	int (*s_modulator)(struct v4l2_subdev *sd, struct v4l2_modulator *vm);
 	int (*s_type_addr)(struct v4l2_subdev *sd, struct tuner_setup *type);
 	int (*s_config)(struct v4l2_subdev *sd, const struct v4l2_priv_tun_config *config);
 	int (*s_standby)(struct v4l2_subdev *sd);
-- 
1.6.2.GIT


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCHv7 2/9] v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX controls
  2009-06-12 17:30 ` [PATCHv7 1/9] v4l2-subdev.h: Add g_modulator callbacks to subdev api Eduardo Valentin
@ 2009-06-12 17:30   ` Eduardo Valentin
  2009-06-12 17:30     ` [PATCHv7 3/9] v4l2: video device: Add FM_TX controls default configurations Eduardo Valentin
  2009-06-14 10:46     ` [PATCHv7 2/9] v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX controls Hans Verkuil
  0 siblings, 2 replies; 33+ messages in thread
From: Eduardo Valentin @ 2009-06-12 17:30 UTC (permalink / raw)
  To: ext Hans Verkuil, ext Mauro Carvalho Chehab
  Cc: Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media, Eduardo Valentin

This patch adds a new class of extended controls. This class
is intended to support FM Radio Modulators properties such as:
rds, audio limiters, audio compression, pilot tone generation,
tuning power levels and preemphasis properties.

Signed-off-by: Eduardo Valentin <eduardo.valentin@nokia.com>
---
 linux/include/linux/videodev2.h |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/linux/include/linux/videodev2.h b/linux/include/linux/videodev2.h
index b8cffc9..9733435 100644
--- a/linux/include/linux/videodev2.h
+++ b/linux/include/linux/videodev2.h
@@ -806,6 +806,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_FM_TX 0x009b0000	/* FM Modulator control class */
 
 #define V4L2_CTRL_ID_MASK      	  (0x0fffffff)
 #define V4L2_CTRL_ID2CLASS(id)    ((id) & 0x0fff0000UL)
@@ -1144,6 +1145,39 @@ enum  v4l2_exposure_auto_type {
 
 #define V4L2_CID_PRIVACY			(V4L2_CID_CAMERA_CLASS_BASE+16)
 
+/* FM Modulator class control IDs */
+#define V4L2_CID_FM_TX_CLASS_BASE		(V4L2_CTRL_CLASS_FM_TX | 0x900)
+#define V4L2_CID_FM_TX_CLASS			(V4L2_CTRL_CLASS_FM_TX | 1)
+
+#define V4L2_CID_RDS_ENABLED			(V4L2_CID_FM_TX_CLASS_BASE + 1)
+#define V4L2_CID_RDS_PI				(V4L2_CID_FM_TX_CLASS_BASE + 2)
+#define V4L2_CID_RDS_PTY			(V4L2_CID_FM_TX_CLASS_BASE + 3)
+#define V4L2_CID_RDS_PS_NAME			(V4L2_CID_FM_TX_CLASS_BASE + 4)
+#define V4L2_CID_RDS_RADIO_TEXT			(V4L2_CID_FM_TX_CLASS_BASE + 5)
+
+#define V4L2_CID_AUDIO_LIMITER_ENABLED		(V4L2_CID_FM_TX_CLASS_BASE + 6)
+#define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME	(V4L2_CID_FM_TX_CLASS_BASE + 7)
+#define V4L2_CID_AUDIO_LIMITER_DEVIATION	(V4L2_CID_FM_TX_CLASS_BASE + 8)
+
+#define V4L2_CID_AUDIO_COMPRESSION_ENABLED	(V4L2_CID_FM_TX_CLASS_BASE + 9)
+#define V4L2_CID_AUDIO_COMPRESSION_GAIN		(V4L2_CID_FM_TX_CLASS_BASE + 10)
+#define V4L2_CID_AUDIO_COMPRESSION_THRESHOLD	(V4L2_CID_FM_TX_CLASS_BASE + 11)
+#define V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME	(V4L2_CID_FM_TX_CLASS_BASE + 12)
+#define V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME	(V4L2_CID_FM_TX_CLASS_BASE + 13)
+
+#define V4L2_CID_PILOT_TONE_ENABLED		(V4L2_CID_FM_TX_CLASS_BASE + 14)
+#define V4L2_CID_PILOT_TONE_DEVIATION		(V4L2_CID_FM_TX_CLASS_BASE + 15)
+#define V4L2_CID_PILOT_TONE_FREQUENCY		(V4L2_CID_FM_TX_CLASS_BASE + 16)
+
+#define V4L2_CID_PREEMPHASIS			(V4L2_CID_FM_TX_CLASS_BASE + 17)
+enum v4l2_fm_tx_preemphasis {
+	V4L2_FM_TX_PREEMPHASIS_DISABLED		= 0,
+	V4L2_FM_TX_PREEMPHASIS_50_uS		= 1,
+	V4L2_FM_TX_PREEMPHASIS_75_uS		= 2,
+};
+#define V4L2_CID_TUNE_POWER_LEVEL		(V4L2_CID_FM_TX_CLASS_BASE + 18)
+#define V4L2_CID_TUNE_ANTENNA_CAPACITOR		(V4L2_CID_FM_TX_CLASS_BASE + 19)
+
 /*
  *	T U N I N G
  */
-- 
1.6.2.GIT


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCHv7 3/9] v4l2: video device: Add FM_TX controls default configurations
  2009-06-12 17:30   ` [PATCHv7 2/9] v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX controls Eduardo Valentin
@ 2009-06-12 17:30     ` Eduardo Valentin
  2009-06-12 17:30       ` [PATCHv7 4/9] v4l2-ctl: Add support for FM TX controls Eduardo Valentin
  2009-06-14 10:46     ` [PATCHv7 2/9] v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX controls Hans Verkuil
  1 sibling, 1 reply; 33+ messages in thread
From: Eduardo Valentin @ 2009-06-12 17:30 UTC (permalink / raw)
  To: ext Hans Verkuil, ext Mauro Carvalho Chehab
  Cc: Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media, Eduardo Valentin

Signed-off-by: Eduardo Valentin <eduardo.valentin@nokia.com>
---
 linux/drivers/media/video/v4l2-common.c |   50 +++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/linux/drivers/media/video/v4l2-common.c b/linux/drivers/media/video/v4l2-common.c
index 5cfd727..9b6cf9f 100644
--- a/linux/drivers/media/video/v4l2-common.c
+++ b/linux/drivers/media/video/v4l2-common.c
@@ -345,6 +345,12 @@ const char **v4l2_ctrl_get_menu(u32 id)
 		"Sepia",
 		NULL
 	};
+	static const char *fm_tx_preemphasis[] = {
+		"No preemphasis",
+		"50 useconds",
+		"75 useconds",
+		NULL,
+	};
 
 	switch (id) {
 		case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ:
@@ -383,6 +389,8 @@ const char **v4l2_ctrl_get_menu(u32 id)
 			return camera_exposure_auto;
 		case V4L2_CID_COLORFX:
 			return colorfx;
+		case V4L2_CID_PREEMPHASIS:
+			return fm_tx_preemphasis;
 		default:
 			return NULL;
 	}
@@ -481,6 +489,28 @@ 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_FM_TX_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_PREEMPHASIS:		return "Pre-emphasis settings";
+	case V4L2_CID_TUNE_POWER_LEVEL:		return "Tune Power Level";
+	case V4L2_CID_TUNE_ANTENNA_CAPACITOR:	return "Tune Antenna Capacitor";
+
 	default:
 		return NULL;
 	}
@@ -513,6 +543,10 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 ste
 	case 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;
@@ -541,12 +575,18 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 ste
 	case V4L2_CID_MPEG_STREAM_VBI_FMT:
 	case V4L2_CID_EXPOSURE_AUTO:
 	case V4L2_CID_COLORFX:
+	case V4L2_CID_PREEMPHASIS:
 		qctrl->type = V4L2_CTRL_TYPE_MENU;
 		step = 1;
 		break;
+	case V4L2_CID_RDS_PS_NAME:
+	case V4L2_CID_RDS_RADIO_TEXT:
+		qctrl->type = V4L2_CTRL_TYPE_STRING;
+		break;
 	case V4L2_CID_USER_CLASS:
 	case V4L2_CID_CAMERA_CLASS:
 	case V4L2_CID_MPEG_CLASS:
+	case V4L2_CID_FM_TX_CLASS:
 		qctrl->type = V4L2_CTRL_TYPE_CTRL_CLASS;
 		qctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY;
 		min = max = step = def = 0;
@@ -575,6 +615,16 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 ste
 	case 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_PAN_RELATIVE:
-- 
1.6.2.GIT


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCHv7 4/9] v4l2-ctl: Add support for FM TX controls
  2009-06-12 17:30     ` [PATCHv7 3/9] v4l2: video device: Add FM_TX controls default configurations Eduardo Valentin
@ 2009-06-12 17:30       ` Eduardo Valentin
  2009-06-12 17:30         ` [PATCHv7 5/9] v4l2-spec: Add documentation description for FM TX extended control class Eduardo Valentin
  0 siblings, 1 reply; 33+ messages in thread
From: Eduardo Valentin @ 2009-06-12 17:30 UTC (permalink / raw)
  To: ext Hans Verkuil, ext Mauro Carvalho Chehab
  Cc: Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media, Eduardo Valentin

This patch adds simple support for FM TX extended controls
on v4l2-ctl utility.

Signed-off-by: Eduardo Valentin <eduardo.valentin@nokia.com>
---
 v4l2-apps/util/v4l2-ctl.cpp |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/v4l2-apps/util/v4l2-ctl.cpp b/v4l2-apps/util/v4l2-ctl.cpp
index 2c7290f..45a2310 100644
--- a/v4l2-apps/util/v4l2-ctl.cpp
+++ b/v4l2-apps/util/v4l2-ctl.cpp
@@ -148,6 +148,7 @@ typedef std::vector<struct v4l2_ext_control> ctrl_list;
 static ctrl_list user_ctrls;
 static ctrl_list mpeg_ctrls;
 static ctrl_list camera_ctrls;
+static ctrl_list fm_tx_ctrls;
 
 typedef std::map<std::string, unsigned> ctrl_strmap;
 static ctrl_strmap ctrl_str2id;
@@ -2166,6 +2167,8 @@ set_vid_fmt_error:
 				mpeg_ctrls.push_back(ctrl);
 			else if (V4L2_CTRL_ID2CLASS(ctrl.id) == V4L2_CTRL_CLASS_CAMERA)
 				camera_ctrls.push_back(ctrl);
+			else if (V4L2_CTRL_ID2CLASS(ctrl.id) == V4L2_CTRL_CLASS_FM_TX)
+				fm_tx_ctrls.push_back(ctrl);
 			else
 				user_ctrls.push_back(ctrl);
 		}
@@ -2212,6 +2215,22 @@ set_vid_fmt_error:
 				}
 			}
 		}
+		if (fm_tx_ctrls.size()) {
+			ctrls.ctrl_class = V4L2_CTRL_CLASS_FM_TX;
+			ctrls.count = fm_tx_ctrls.size();
+			ctrls.controls = &fm_tx_ctrls[0];
+			if (doioctl(fd, VIDIOC_S_EXT_CTRLS, &ctrls, "VIDIOC_S_EXT_CTRLS")) {
+				if (ctrls.error_idx >= ctrls.count) {
+					fprintf(stderr, "Error setting FM Modulator controls: %s\n",
+						strerror(errno));
+				}
+				else {
+					fprintf(stderr, "%s: %s\n",
+						ctrl_id2str[fm_tx_ctrls[ctrls.error_idx].id].c_str(),
+						strerror(errno));
+				}
+			}
+		}
 	}
 
 	/* Get options */
@@ -2429,6 +2448,7 @@ set_vid_fmt_error:
 		mpeg_ctrls.clear();
 		camera_ctrls.clear();
 		user_ctrls.clear();
+		fm_tx_ctrls.clear();
 		for (ctrl_get_list::iterator iter = get_ctrls.begin();
 				iter != get_ctrls.end(); ++iter) {
 			struct v4l2_ext_control ctrl = { 0 };
@@ -2443,6 +2463,8 @@ set_vid_fmt_error:
 				mpeg_ctrls.push_back(ctrl);
 			else if (V4L2_CTRL_ID2CLASS(ctrl.id) == V4L2_CTRL_CLASS_CAMERA)
 				camera_ctrls.push_back(ctrl);
+			else if (V4L2_CTRL_ID2CLASS(ctrl.id) == V4L2_CTRL_CLASS_FM_TX)
+				fm_tx_ctrls.push_back(ctrl);
 			else
 				user_ctrls.push_back(ctrl);
 		}
@@ -2481,6 +2503,20 @@ set_vid_fmt_error:
 					printf("%s: %d\n", ctrl_id2str[ctrl.id].c_str(), ctrl.value);
 			}
 		}
+		if (fm_tx_ctrls.size()) {
+			ctrls.ctrl_class = V4L2_CTRL_CLASS_FM_TX;
+			ctrls.count = fm_tx_ctrls.size();
+			ctrls.controls = &fm_tx_ctrls[0];
+			doioctl(fd, VIDIOC_G_EXT_CTRLS, &ctrls, "VIDIOC_G_EXT_CTRLS");
+			for (unsigned i = 0; i < fm_tx_ctrls.size(); i++) {
+				struct v4l2_ext_control ctrl = fm_tx_ctrls[i];
+
+				if (ctrl_id2type[ctrl.id] == V4L2_CTRL_TYPE_STRING)
+					printf("%s: '%s'\n", ctrl_id2str[ctrl.id].c_str(), ctrl.string);
+				else
+					printf("%s: %d\n", ctrl_id2str[ctrl.id].c_str(), ctrl.value);
+			}
+		}
 	}
 
 	if (options[OptGetTuner]) {
-- 
1.6.2.GIT


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCHv7 5/9] v4l2-spec: Add documentation description for FM TX extended control class
  2009-06-12 17:30       ` [PATCHv7 4/9] v4l2-ctl: Add support for FM TX controls Eduardo Valentin
@ 2009-06-12 17:30         ` Eduardo Valentin
  2009-06-12 17:30           ` [PATCHv7 6/9] FMTx: si4713: Add files to add radio interface for si4713 Eduardo Valentin
  2009-06-14 10:41           ` [PATCHv7 5/9] v4l2-spec: Add documentation description for FM TX extended control class Hans Verkuil
  0 siblings, 2 replies; 33+ messages in thread
From: Eduardo Valentin @ 2009-06-12 17:30 UTC (permalink / raw)
  To: ext Hans Verkuil, ext Mauro Carvalho Chehab
  Cc: Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media, Eduardo Valentin

This single patch adds documentation description for FM Modulator (FM_TX)
Extended Control Class and its Control IDs. The text was added under
"Extended Controls" section.

Signed-off-by: Eduardo Valentin <eduardo.valentin@nokia.com>
---
 v4l2-spec/Makefile      |    1 +
 v4l2-spec/biblio.sgml   |   10 +++
 v4l2-spec/controls.sgml |  205 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 216 insertions(+), 0 deletions(-)

diff --git a/v4l2-spec/Makefile b/v4l2-spec/Makefile
index 7a19924..bfe2965 100644
--- a/v4l2-spec/Makefile
+++ b/v4l2-spec/Makefile
@@ -242,6 +242,7 @@ ENUMS = \
 	v4l2_power_line_frequency \
 	v4l2_priority \
 	v4l2_tuner_type \
+	v4l2_fm_tx_preemphasis \
 
 STRUCTS = \
 	v4l2_audio \
diff --git a/v4l2-spec/biblio.sgml b/v4l2-spec/biblio.sgml
index b013ece..0921849 100644
--- a/v4l2-spec/biblio.sgml
+++ b/v4l2-spec/biblio.sgml
@@ -11,6 +11,16 @@ url="http://www.eia.org">http://www.eia.org</ulink>)</corpauthor>
 Service"</title>
     </biblioentry>
 
+    <biblioentry id="en50067">
+      <abbrev>EN&nbsp;50067</abbrev>
+      <authorgroup>
+	<corpauthor>CENELEC European Committee for Electrotechnical Standardization
+(<ulink url="http://www.cenelec.eu">http://www.cenelec.eu</ulink>)</corpauthor>
+      </authorgroup>
+      <title>EN 50067 "Specification of the radio data system (RDS) for
+VHF/FM sound broadcasting in the frequency range from 87,5 to 108,0 MHz"</title>
+    </biblioentry>
+
     <biblioentry id="en300294">
       <abbrev>EN&nbsp;300&nbsp;294</abbrev>
       <authorgroup>
diff --git a/v4l2-spec/controls.sgml b/v4l2-spec/controls.sgml
index 477a970..0bb6f00 100644
--- a/v4l2-spec/controls.sgml
+++ b/v4l2-spec/controls.sgml
@@ -458,6 +458,12 @@ video is actually encoded into that format.</para>
       <para>Unfortunately, the original control API lacked some
 features needed for these new uses and so it was extended into the
 (not terribly originally named) extended control API.</para>
+
+      <para>Even though the MPEG encoding API was the first effort
+to use the Extended Control API, nowadays there are also other classes
+of Extended Controls, such as Camera Controls and FM Transmitter Controls.
+The Extended Controls API as well as all Extended Controls classes are
+described in the following text.</para>
     </section>
 
     <section>
@@ -1816,6 +1822,205 @@ control must support read access and may support write access.</entry>
       </tgroup>
     </table>
   </section>
+
+    <section id="fm-tx-controls">
+      <title>FM Transmitter Control Reference</title>
+
+      <para>The FM Transmitter (FM_TX) class includes controls for common features of
+FM transmissions capable devices. Currently this class include parameters for audio
+compression, pilot tone generation, audio deviation limiter, RDS transmission and
+tuning power features.</para>
+
+      <table pgwide="1" frame="none" id="fm-tx-control-id">
+      <title>FM_TX Control IDs</title>
+
+      <tgroup cols="4">
+	<colspec colname="c1" colwidth="1*">
+	<colspec colname="c2" colwidth="6*">
+	<colspec colname="c3" colwidth="2*">
+	<colspec colname="c4" colwidth="6*">
+	<spanspec namest="c1" nameend="c2" spanname="id">
+	<spanspec namest="c2" nameend="c4" spanname="descr">
+	<thead>
+	  <row>
+	    <entry spanname="id" align="left">ID</entry>
+	    <entry align="left">Type</entry>
+	  </row><row rowsep="1"><entry spanname="descr" align="left">Description</entry>
+	  </row>
+	</thead>
+	<tbody valign="top">
+	  <row><entry></entry></row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_FM_TX_CLASS</constant>&nbsp;</entry>
+	    <entry>class</entry>
+	  </row><row><entry spanname="descr">The FM_TX class
+descriptor. Calling &VIDIOC-QUERYCTRL; for this control will return a
+description of this control class.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_RDS_ENABLED</constant>&nbsp;</entry>
+	    <entry>boolean</entry>
+	  </row>
+	  <row><entry spanname="descr">Enables or disables the RDS transmission feature.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_RDS_PI</constant>&nbsp;</entry>
+	    <entry>integer</entry>
+	  </row>
+	  <row><entry spanname="descr">Sets the RDS Programme Identification field
+for transmission.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_RDS_PTY</constant>&nbsp;</entry>
+	    <entry>integer</entry>
+	  </row>
+	  <row><entry spanname="descr">Sets the RDS Programme Type field for transmission.
+This coding of up to 31 pre-defined programme types.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_RDS_PS_NAME</constant>&nbsp;</entry>
+	    <entry>string</entry>
+	  </row>
+	  <row><entry spanname="descr">Sets the Programme Service name (PS_NAME) for transmission.
+It is intended for static display on a receiver. It is the primary aid to listeners in programme service
+identification and selection. The use of PS to transmit text other than a single eight character name is not permitted.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_RDS_RADIO_TEXT</constant>&nbsp;</entry>
+	    <entry>string</entry>
+	  </row>
+	  <row><entry spanname="descr">Sets the Radio Text info for transmission. It is a textual description of
+what is being broadcasted. If broadcaster wishes to transmit longer PS names, programme-related information or any other
+text, then RadioText should be used.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_AUDIO_LIMITER_ENABLED</constant>&nbsp;</entry>
+	    <entry>boolean</entry>
+	  </row>
+	  <row><entry spanname="descr">Enables or disables the audio deviation limiter feature.
+The limiter is useful when trying to maximize the audio volume, minimize receiver-generated
+distortion and prevent overmodulation.
+</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_AUDIO_LIMITER_RELEASE_TIME</constant>&nbsp;</entry>
+	    <entry>integer</entry>
+	  </row>
+	  <row><entry spanname="descr">Sets the audio deviation limiter feature release time.
+The unit, step and range are driver-specific.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_AUDIO_LIMITER_DEVIATION</constant>&nbsp;</entry>
+	    <entry>integer</entry>
+	  </row>
+	  <row><entry spanname="descr">Configures audio frequency deviation level in Hz.
+The range and step are driver-specific.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_AUDIO_COMPRESSION_ENABLED</constant>&nbsp;</entry>
+	    <entry>boolean</entry>
+	  </row>
+	  <row><entry spanname="descr">Enables or disables the audio compression feature.
+This feature amplifies signals below the threshold by a fixed gain and compresses audio
+signals above the threshold by the ratio of Threshold/(Gain + Threshold).</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_AUDIO_COMPRESSION_GAIN</constant>&nbsp;</entry>
+	    <entry>integer</entry>
+	  </row>
+	  <row><entry spanname="descr">Sets the gain for audio compression feature. It is
+a dB value. The range and step are driver-specific.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_AUDIO_COMPRESSION_THRESHOLD</constant>&nbsp;</entry>
+	    <entry>integer</entry>
+	  </row>
+	  <row><entry spanname="descr">Sets the threshold level for audio compression freature.
+It is a dB value. The range and step are driver-specific.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME</constant>&nbsp;</entry>
+	    <entry>integer</entry>
+	  </row>
+	  <row><entry spanname="descr">Sets the attack time for audio compression feature.
+It is a useconds value. The range and step are driver-specific.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME</constant>&nbsp;</entry>
+	    <entry>integer</entry>
+	  </row>
+	  <row><entry spanname="descr">Sets the release time for audio compression feature.
+It is a useconds value. The range and step are driver-specific.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_PILOT_TONE_ENABLED</constant>&nbsp;</entry>
+	    <entry>boolean</entry>
+	  </row>
+	  <row><entry spanname="descr">Enables or disables the pilot tone generation feature.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_PILOT_TONE_DEVIATION</constant>&nbsp;</entry>
+	    <entry>integer</entry>
+	  </row>
+	  <row><entry spanname="descr">Configures pilot tone frequency deviation level. Unit is
+in Hz. The range and step are driver-specific.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_PILOT_TONE_FREQUENCY</constant>&nbsp;</entry>
+	    <entry>integer</entry>
+	  </row>
+	  <row><entry spanname="descr">Configures pilot tone frequency value. Unit is
+in Hz. The range and step are driver-specific.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_PREEMPHASIS</constant>&nbsp;</entry>
+	    <entry>integer</entry>
+	  </row>
+	  <row id="v4l2-fm-tx-preemphasis"><entry spanname="descr">Configures the pre-emphasis value for broadcasting.
+A pre-emphasis filter is applied to the broadcast to accentuate the high audio frequencies.
+Depending on the region, a time constant of either 50 or 75 useconds is used. The enum&nbsp;v4l2_fm_tx_preemphasis
+defines possible values for pre-emphasis. Here they are:</entry>
+	</row><row>
+	<entrytbl spanname="descr" cols="2">
+		  <tbody valign="top">
+		    <row>
+		      <entry><constant>V4L2_FM_TX_PREEMPHASIS_DISABLED</constant>&nbsp;</entry>
+		      <entry>No pre-emphasis is applied.</entry>
+		    </row>
+		    <row>
+		      <entry><constant>V4L2_FM_TX_PREEMPHASIS_50_uS</constant>&nbsp;</entry>
+		      <entry>A pre-emphasis of 50 uS is used.</entry>
+		    </row>
+		    <row>
+		      <entry><constant>V4L2_FM_TX_PREEMPHASIS_75_uS</constant>&nbsp;</entry>
+		      <entry>A pre-emphasis of 75 uS is used.</entry>
+		    </row>
+		  </tbody>
+		</entrytbl>
+
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_TUNE_POWER_LEVEL</constant>&nbsp;</entry>
+	    <entry>integer</entry>
+	  </row>
+	  <row><entry spanname="descr">Sets the output power level for signal transmission.
+Unit is in dBuV. Range and step are driver-specific.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_TUNE_ANTENNA_CAPACITOR</constant>&nbsp;</entry>
+	    <entry>integer</entry>
+	  </row>
+	  <row><entry spanname="descr">This selects the value of antenna tuning capacitor
+manually or automatically if set to zero. Unit, range and step are driver-specific.</entry>
+	  </row>
+	  <row><entry></entry></row>
+	</tbody>
+      </tgroup>
+      </table>
+
+<para>For more details about RDS specification, refer to
+<xref linkend="en50067"> document, from CENELEC.</para>
+    </section>
 </section>
 
   <!--
-- 
1.6.2.GIT


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCHv7 6/9] FMTx: si4713: Add files to add radio interface for si4713
  2009-06-12 17:30         ` [PATCHv7 5/9] v4l2-spec: Add documentation description for FM TX extended control class Eduardo Valentin
@ 2009-06-12 17:30           ` Eduardo Valentin
  2009-06-12 17:30             ` [PATCHv7 7/9] FMTx: si4713: Add files to handle si4713 i2c device Eduardo Valentin
  2009-06-14 11:14             ` [PATCHv7 6/9] FMTx: si4713: Add files to add radio interface for si4713 Hans Verkuil
  2009-06-14 10:41           ` [PATCHv7 5/9] v4l2-spec: Add documentation description for FM TX extended control class Hans Verkuil
  1 sibling, 2 replies; 33+ messages in thread
From: Eduardo Valentin @ 2009-06-12 17:30 UTC (permalink / raw)
  To: ext Hans Verkuil, ext Mauro Carvalho Chehab
  Cc: Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media, Eduardo Valentin

This patch adds files which creates the radio interface
for si4713 FM transmitter (modulator) devices.

In order to do the real access to device registers, this
driver uses the v4l2 subdev interface exported by si4713 i2c driver.

Signed-off-by: "Eduardo Valentin <eduardo.valentin@nokia.com>"
---
 linux/drivers/media/radio/radio-si4713.c |  325 ++++++++++++++++++++++++++++++
 linux/include/media/si4713.h             |   40 ++++
 2 files changed, 365 insertions(+), 0 deletions(-)
 create mode 100644 linux/drivers/media/radio/radio-si4713.c
 create mode 100644 linux/include/media/si4713.h

diff --git a/linux/drivers/media/radio/radio-si4713.c b/linux/drivers/media/radio/radio-si4713.c
new file mode 100644
index 0000000..4c23120
--- /dev/null
+++ b/linux/drivers/media/radio/radio-si4713.c
@@ -0,0 +1,325 @@
+/*
+ * 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 <eduardo.valentin@nokia.com>
+ *
+ * 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 <media/si4713.h>
+
+/* Driver state struct */
+struct radio_si4713_device {
+	struct v4l2_device		v4l2_dev;
+	struct video_device		*radio_dev;
+};
+
+/* 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_fill_audout(struct v4l2_audioout *vao)
+{
+	/* TODO: check presence of audio output */
+	memset(vao, 0, sizeof(*vao));
+	strlcpy(vao->name, "FM Modulator Audio Out", 32);
+
+	return 0;
+}
+
+static int radio_si4713_enumaudout(struct file *file, void *priv,
+						struct v4l2_audioout *vao)
+{
+	return radio_si4713_fill_audout(vao);
+}
+
+static int radio_si4713_g_audout(struct file *file, void *priv,
+					struct v4l2_audioout *vao)
+{
+	int rval = radio_si4713_fill_audout(vao);
+
+	vao->index = 0;
+
+	return rval;
+}
+
+static int radio_si4713_s_audout(struct file *file, void *priv,
+					struct v4l2_audioout *vao)
+{
+	if (vao->index != 0)
+		return -EINVAL;
+
+	return radio_si4713_fill_audout(vao);
+}
+
+/* radio_si4713_querycap - query device capabilities */
+static int radio_si4713_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 Modulator",
+				sizeof(capability->card));
+	capability->capabilities = V4L2_CAP_MODULATOR;
+
+	return 0;
+}
+
+/* radio_si4713_queryctrl - enumerate control items */
+static int radio_si4713_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_MUTE,
+		0
+	};
+
+	/* Must be sorted from low to high control ID! */
+	static const u32 fmtx_ctrls[] = {
+		V4L2_CID_FM_TX_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_PREEMPHASIS,
+		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_FM_TX_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_template - Produce a v4l2 call back.
+ * Can be used because we are just a wrapper for v4l2_sub_devs.
+ */
+#define radio_si4713_template(type, callback, arg_type)			\
+static int radio_si4713_##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_template(core, g_ext_ctrls, struct v4l2_ext_controls *)
+radio_si4713_template(core, s_ext_ctrls, struct v4l2_ext_controls *)
+radio_si4713_template(core, g_ctrl, struct v4l2_control *)
+radio_si4713_template(core, s_ctrl, struct v4l2_control *)
+radio_si4713_template(tuner, g_modulator, struct v4l2_modulator *)
+radio_si4713_template(tuner, s_modulator, struct v4l2_modulator *)
+radio_si4713_template(tuner, g_frequency, struct v4l2_frequency *)
+radio_si4713_template(tuner, s_frequency, struct v4l2_frequency *)
+
+static struct v4l2_ioctl_ops radio_si4713_ioctl_ops = {
+	.vidioc_enumaudout	= radio_si4713_enumaudout,
+	.vidioc_g_audout	= radio_si4713_g_audout,
+	.vidioc_s_audout	= radio_si4713_s_audout,
+	.vidioc_querycap	= radio_si4713_querycap,
+	.vidioc_queryctrl	= radio_si4713_queryctrl,
+	.vidioc_g_ext_ctrls	= radio_si4713_g_ext_ctrls,
+	.vidioc_s_ext_ctrls	= radio_si4713_s_ext_ctrls,
+	.vidioc_g_ctrl		= radio_si4713_g_ctrl,
+	.vidioc_s_ctrl		= radio_si4713_s_ctrl,
+	.vidioc_g_modulator	= radio_si4713_g_modulator,
+	.vidioc_s_modulator	= radio_si4713_s_modulator,
+	.vidioc_g_frequency	= radio_si4713_g_frequency,
+	.vidioc_s_frequency	= radio_si4713_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->dev.platform_data;
+	struct radio_si4713_device *rsdev;
+	struct i2c_adapter *adapter;
+	struct v4l2_subdev *sd;
+	int rval = 0;
+
+	if (!pdata) {
+		dev_err(&pdev->dev, "Cannot 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, "Cannot get i2c adapter %d\n",
+							pdata->i2c_bus);
+		rval = -ENODEV;
+		goto unregister_v4l2_dev;
+	}
+
+	sd = v4l2_i2c_new_subdev_board(&rsdev->v4l2_dev, adapter, "si4713_i2c",
+					pdata->subdev_board_info, NULL);
+	if (!sd) {
+		dev_err(&pdev->dev, "Cannot 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 radio_si4713_device *rsdev = container_of(v4l2_dev,
+						struct radio_si4713_device,
+						v4l2_dev);
+
+	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 <eduardo.valentin@nokia.com>");
+MODULE_DESCRIPTION("Platform driver for Si4713 FM Radio Transmitter");
+MODULE_VERSION("0.0.1");
diff --git a/linux/include/media/si4713.h b/linux/include/media/si4713.h
new file mode 100644
index 0000000..de43f83
--- /dev/null
+++ b/linux/include/media/si4713.h
@@ -0,0 +1,40 @@
+/*
+ * include/media/si4713.h
+ *
+ * Board related data definitions for Si4713 radio transmitter chip.
+ *
+ * Copyright (c) 2009 Nokia Corporation
+ * Contact: Eduardo Valentin <eduardo.valentin@nokia.com>
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ *
+ */
+
+#ifndef SI4713_H
+#define SI4713_H
+
+#include <linux/i2c.h>
+#include <media/v4l2-device.h>
+
+#define SI4713_NAME "radio-si4713"
+
+/* The SI4713 I2C sensor chip has a fixed slave address of 0xc6. */
+#define SI4713_I2C_ADDR_BUSEN_HIGH	0x63
+#define SI4713_I2C_ADDR_BUSEN_LOW	0x11
+
+/*
+ * Platform dependent definition
+ */
+struct si4713_platform_data {
+	/* Set power state, zero is off, non-zero is on. */
+	int (*set_power)(int power);
+};
+
+struct radio_si4713_platform_data {
+	int i2c_bus;
+	struct i2c_board_info *subdev_board_info;
+};
+
+#endif /* ifndef SI4713_H*/
-- 
1.6.2.GIT


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCHv7 7/9] FMTx: si4713: Add files to handle si4713 i2c device
  2009-06-12 17:30           ` [PATCHv7 6/9] FMTx: si4713: Add files to add radio interface for si4713 Eduardo Valentin
@ 2009-06-12 17:30             ` Eduardo Valentin
  2009-06-12 17:30               ` [PATCHv7 8/9] FMTx: si4713: Add Kconfig and Makefile entries Eduardo Valentin
  2009-06-14 12:31               ` [PATCHv7 7/9] FMTx: si4713: Add files to handle si4713 i2c device Hans Verkuil
  2009-06-14 11:14             ` [PATCHv7 6/9] FMTx: si4713: Add files to add radio interface for si4713 Hans Verkuil
  1 sibling, 2 replies; 33+ messages in thread
From: Eduardo Valentin @ 2009-06-12 17:30 UTC (permalink / raw)
  To: ext Hans Verkuil, ext Mauro Carvalho Chehab
  Cc: Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media, Eduardo Valentin

This 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.

Signed-off-by: Eduardo Valentin <eduardo.valentin@nokia.com>
---
 linux/drivers/media/radio/si4713-i2c.c | 2813 ++++++++++++++++++++++++++++++++
 linux/drivers/media/radio/si4713-i2c.h |  226 +++
 2 files changed, 3039 insertions(+), 0 deletions(-)
 create mode 100644 linux/drivers/media/radio/si4713-i2c.c
 create mode 100644 linux/drivers/media/radio/si4713-i2c.h

diff --git a/linux/drivers/media/radio/si4713-i2c.c b/linux/drivers/media/radio/si4713-i2c.c
new file mode 100644
index 0000000..f640d33
--- /dev/null
+++ b/linux/drivers/media/radio/si4713-i2c.c
@@ -0,0 +1,2813 @@
+/*
+ * drivers/media/radio/si4713-i2c.c
+ *
+ * Silicon Labs Si4713 FM Radio Transmitter I2C commands.
+ *
+ * Copyright (c) 2009 Nokia Corporation
+ * Contact: Eduardo Valentin <eduardo.valentin@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <linux/mutex.h>
+#include <linux/completion.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/i2c.h>
+#include <media/v4l2-device.h>
+#include <media/v4l2-ioctl.h>
+
+#include "si4713-i2c.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_MUTE			0x01
+#define DEFAULT_POWER_LEVEL		88
+#define DEFAULT_FREQUENCY		8800
+#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 si4713_to_v4l2(f)	((f * FREQDEV_UNIT) / FREQV4L2_MULTI)
+#define v4l2_to_si4713(f)	((f * FREQV4L2_MULTI) / FREQDEV_UNIT)
+
+#define MAX_ARGS 7
+
+#define RDS_BLOCK			8
+#define RDS_BLOCK_CLEAR			0x03
+#define RDS_BLOCK_LOAD			0x04
+#define RDS_RADIOTEXT_2A		0x20
+#define RDS_RADIOTEXT_BLK_SIZE		4
+#define RDS_RADIOTEXT_INDEX_MAX		0x0F
+#define RDS_CARRIAGE_RETURN		0x0D
+
+#define rds_ps_nblocks(len)	((len / RDS_BLOCK) + (len % RDS_BLOCK ? 1 : 0))
+#define enable_rds(p)		(p | (1 << 2))
+#define disable_rds(p)		(p & ~(1 << 2))
+#define get_rds_status(p)	((p >> 2) & 0x01)
+
+#define enable_stereo(p)	(p | (1 << 1))
+#define disable_stereo(p)	(p & ~(1 << 1))
+#define get_stereo_status(p)	((p >> 1) & 0x01)
+
+#define enable_limiter(p)	(p | (1 << 1))
+#define disable_limiter(p)	(p & ~(1 << 1))
+#define get_limiter_status(p)	((p >> 1) & 0x01)
+
+#define enable_pilot(p)		(p | (1 << 0))
+#define disable_pilot(p)	(p & ~(1 << 0))
+#define get_pilot_status(p)	((p >> 0) & 0x01)
+
+#define enable_acomp(p)		(p | (1 << 0))
+#define disable_acomp(p)	(p & ~(1 << 0))
+#define get_acomp_status(p)	((p >> 0) & 0x01)
+#define ATTACK_TIME_UNIT	500
+
+#define POWER_OFF			0x00
+#define POWER_ON			0x01
+
+#define msb(x)                  ((u8)((u16) x >> 8))
+#define lsb(x)                  ((u8)((u16) x &  0x00FF))
+#define compose_u16(msb, lsb)	(((u16)msb << 8) | lsb)
+#define check_command_failed(status)	(!(status & SI4713_CTS) || \
+					(status & SI4713_ERR))
+/* mute definition */
+#define set_mute(p)	((p & 1) | ((p & 1) << 1));
+#define get_mute(p)	(p & 0x01)
+#define set_pty(v, pty)	((v & 0xFC1F) | (pty << 5))
+#define get_pty(v)	((v >> 5) & 0x1F)
+
+#ifdef DEBUG
+#define DBG_BUFFER(device, message, buffer, size)			\
+	{								\
+		int i;							\
+		char str[(size)*5];					\
+		for (i = 0; i < size; i++)				\
+			sprintf(str + i * 5, " 0x%02x", buffer[i]);	\
+		dev_dbg(device, "%s:%s\n", message, str);		\
+	}
+#else
+#define DBG_BUFFER(device, message, buffer, size)
+#endif
+
+
+/*
+ * Values for limiter release time
+ *	device	release
+ *	value	time (us)
+ */
+static unsigned long const limiter_times[] = {
+	2000,	250,
+	1000,	500,
+	510,	1000,
+	255,	2000,
+	170,	3000,
+	127,	4020,
+	102,	5010,
+	85,	6020,
+	73,	7010,
+	64,	7990,
+	57,	8970,
+	51,	10030,
+	25,	20470,
+	17,	30110,
+	13,	39380,
+	10,	51190,
+	8,	63690,
+	7,	73140,
+	6,	85330,
+	5,	102390,
+};
+
+/*
+ * Values for audio compression release time
+ *	device	release
+ *	value	time (us)
+ */
+static unsigned long const acomp_rtimes[] = {
+	0,	100000,
+	1,	200000,
+	2,	350000,
+	3,	525000,
+	4,	1000000,
+};
+
+static int usecs_to_dev(unsigned long usecs, unsigned long const array[],
+			int size)
+{
+	int i;
+	int rval = -EINVAL;
+
+	for (i = 0; i < size / 2; i++)
+		if (array[(i * 2) + 1] >= usecs) {
+			rval = array[i * 2];
+			break;
+		}
+
+	return rval;
+}
+
+static unsigned long dev_to_usecs(int value, unsigned long const array[],
+			int size)
+{
+	int i;
+	int rval = -EINVAL;
+
+	for (i = 0; i < size / 2; i++)
+		if (array[i * 2] == value) {
+			rval = array[(i * 2) + 1];
+			break;
+		}
+
+	return rval;
+}
+
+/* si4713_handler: IRQ handler, just complete work */
+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;
+}
+
+/*
+ * si4713_send_command - sends a command to si4713 and waits its response
+ * @sdev: si4713_device structure for the device we are communicating
+ * @command: command id
+ * @args: command arguments we are sending (up to 7)
+ * @argn: actual size of @args
+ * @response: buffer to place the expected response from the device (up to 15)
+ * @respn: actual size of @response
+ * @usecs: amount of time to wait before reading the response (in usecs)
+ */
+static int si4713_send_command(struct si4713_device *sdev, const u8 command,
+				const u8 args[], const int argn,
+				u8 response[], const int respn, const int usecs)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
+	u8 data1[MAX_ARGS + 1];
+	int err;
+
+	if (!client->adapter)
+		return -ENODEV;
+
+	/* First send the command and its arguments */
+	data1[0] = command;
+	memcpy(data1 + 1, args, argn);
+	DBG_BUFFER(&client->dev, "Parameters", data1, argn + 1);
+
+	err = i2c_master_send(client, data1, argn + 1);
+	if (err != argn + 1) {
+		dev_err(&client->dev, "Error while sending command 0x%02x\n",
+			command);
+		return (err > 0) ? -EIO : err;
+	}
+
+	/* Wait response from interrupt */
+	if (!wait_for_completion_timeout(&sdev->work,
+				usecs_to_jiffies(usecs) + 1))
+		dev_dbg(&client->dev, "Device took too much time.\n");
+
+	/* Then get the response */
+	err = i2c_master_recv(client, response, respn);
+	if (err != respn) {
+		dev_err(&client->dev,
+			"Error while reading response for command 0x%02x\n",
+			command);
+		return (err > 0) ? -EIO : err;
+	}
+
+	DBG_BUFFER(&client->dev, "Response", response, respn);
+	if (check_command_failed(response[0]))
+		return -EBUSY;
+
+	return 0;
+}
+
+/*
+ * si4713_read_property - reads a si4713 property
+ * @sdev: si4713_device structure for the device we are communicating
+ * @prop: property identification number
+ */
+static int si4713_read_property(struct si4713_device *sdev, u16 prop)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
+	int err;
+	u8 val[SI4713_GET_PROP_NRESP];
+	/*
+	 * REVISIT: From Programming Manual
+	 * 	.First byte = 0
+	 * 	.Second byte = property's MSB
+	 * 	.Third byte = property's LSB
+	 */
+	const u8 args[SI4713_GET_PROP_NARGS] = {
+		0x00,
+		msb(prop),
+		lsb(prop),
+	};
+
+	err = si4713_send_command(sdev, SI4713_CMD_GET_PROPERTY,
+				  args, ARRAY_SIZE(args), val,
+				  ARRAY_SIZE(val), DEFAULT_TIMEOUT);
+
+	if (err < 0)
+		return err;
+
+	dev_dbg(&client->dev, "Status from read prop: 0x%02x\n", val[0]);
+
+	return compose_u16(val[2], val[3]);
+}
+
+/*
+ * si4713_write_property - modifies a si4713 property
+ * @sdev: si4713_device structure for the device we are communicating
+ * @prop: property identification number
+ * @val: new value for that property
+ */
+static int si4713_write_property(struct si4713_device *sdev, u16 prop, u16 val)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
+	int rval;
+	u8 resp[SI4713_SET_PROP_NRESP];
+	/*
+	 * REVISIT: From Programming Manual
+	 * 	.First byte = 0
+	 * 	.Second byte = property's MSB
+	 * 	.Third byte = property's LSB
+	 * 	.Fourth byte = value's MSB
+	 * 	.Fifth byte = value's LSB
+	 */
+	const u8 args[SI4713_SET_PROP_NARGS] = {
+		0x00,
+		msb(prop),
+		lsb(prop),
+		msb(val),
+		lsb(val),
+	};
+
+	rval = si4713_send_command(sdev, SI4713_CMD_SET_PROPERTY,
+					args, ARRAY_SIZE(args),
+					resp, ARRAY_SIZE(resp),
+					DEFAULT_TIMEOUT);
+
+	if (rval < 0)
+		return rval;
+
+	dev_dbg(&client->dev, "Status from write prop: 0x%02x\n",
+		resp[0]);
+
+	/*
+	 * As there is no command response for SET_PROPERTY,
+	 * wait Tcomp time to finish before proceed, in order
+	 * to have property properly set.
+	 */
+	msleep(TIMEOUT_SET_PROPERTY);
+
+	return rval;
+}
+
+/*
+ * si4713_powerup - Powers the device up
+ * @sdev: si4713_device structure for the device we are communicating
+ */
+static int si4713_powerup(struct si4713_device *sdev)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
+	int err;
+	u8 resp[SI4713_PWUP_NRESP];
+	/*
+	 * REVISIT: From Programming Manual
+	 * 	.First byte = Enabled interrupts and boot function
+	 * 	.Second byte = Input operation mode
+	 */
+	const u8 args[SI4713_PWUP_NARGS] = {
+		SI4713_PWUP_CTSIEN | SI4713_PWUP_GPO2OEN | SI4713_PWUP_FUNC_TX,
+		SI4713_PWUP_OPMOD_ANALOG,
+	};
+
+	if (sdev->power_state)
+		return 0;
+
+	sdev->platform_data->set_power(1);
+	err = si4713_send_command(sdev, SI4713_CMD_POWER_UP,
+					args, ARRAY_SIZE(args),
+					resp, ARRAY_SIZE(resp),
+					TIMEOUT_POWER_UP);
+
+	if (!err) {
+		dev_dbg(&client->dev, "Powerup response: 0x%02x\n",
+			resp[0]);
+		dev_dbg(&client->dev, "Device in power up mode\n");
+		sdev->power_state = POWER_ON;
+
+		err = si4713_write_property(sdev, SI4713_GPO_IEN,
+						SI4713_STC_INT | SI4713_CTS);
+	} else {
+		sdev->platform_data->set_power(0);
+	}
+
+	return err;
+}
+
+/*
+ * si4713_powerdown - Powers the device down
+ * @sdev: si4713_device structure for the device we are communicating
+ */
+static int si4713_powerdown(struct si4713_device *sdev)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
+	int err;
+	u8 resp[SI4713_PWDN_NRESP];
+
+	if (!sdev->power_state)
+		return 0;
+
+	err = si4713_send_command(sdev, SI4713_CMD_POWER_DOWN,
+					NULL, 0,
+					resp, ARRAY_SIZE(resp),
+					DEFAULT_TIMEOUT);
+
+	if (!err) {
+		dev_dbg(&client->dev, "Power down response: 0x%02x\n",
+			resp[0]);
+		dev_dbg(&client->dev, "Device in reset mode\n");
+		sdev->platform_data->set_power(0);
+		sdev->power_state = POWER_OFF;
+	}
+
+	return err;
+}
+
+/*
+ * si4713_checkrev - Checks if we are treating a device with the correct rev.
+ * @sdev: si4713_device structure for the device we are communicating
+ */
+#define pr_revision(devicep, buffer)					\
+	dev_info(devicep, "Detected %s (0x%02x) Firmware: %d.%d"	\
+			  " Patch ID: %02x:%02x Component: %d.%d"	\
+			  " Chip Rev.: %s\n",				\
+			buffer[1] == SI4713_PRODUCT_NUMBER ? "Si4713" : "",\
+			buffer[1],					\
+			buffer[2] & 0xF, buffer[3] & 0xF,		\
+			buffer[4], buffer[5],				\
+			buffer[6] & 0xF, buffer[7] & 0xF,		\
+			buffer[8] == 0x41 ? "revA" : "unknown")
+static int si4713_checkrev(struct si4713_device *sdev)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
+	int rval;
+	u8 resp[SI4713_GETREV_NRESP];
+
+	mutex_lock(&sdev->mutex);
+
+	rval = si4713_send_command(sdev, SI4713_CMD_GET_REV,
+					NULL, 0,
+					resp, ARRAY_SIZE(resp),
+					DEFAULT_TIMEOUT);
+
+	if (rval < 0)
+		goto unlock;
+
+	if (resp[1] == SI4713_PRODUCT_NUMBER) {
+		pr_revision(&client->dev, resp);
+	} else {
+		dev_err(&client->dev, "Invalid product number\n");
+		rval = -EINVAL;
+	}
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+/*
+ * si4713_wait_stc - Waits STC interrupt and clears status bits. Usefull
+ *		     for TX_TUNE_POWER, TX_TUNE_FREQ and TX_TUNE_MEAS
+ * @sdev: si4713_device structure for the device we are communicating
+ * @usecs: timeout to wait for STC interrupt signal
+ */
+static int si4713_wait_stc(struct si4713_device *sdev, const int usecs)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
+	int err;
+	u8 resp[SI4713_GET_STATUS_NRESP];
+
+	/* Wait response from STC interrupt */
+	if (!wait_for_completion_timeout(&sdev->work,
+			usecs_to_jiffies(TIMEOUT_TX_TUNE) + 1))
+		dev_dbg(&client->dev, "Device took too much time.\n");
+
+	/* Clear status bits */
+	err = si4713_send_command(sdev, SI4713_CMD_GET_INT_STATUS,
+					NULL, 0,
+					resp, ARRAY_SIZE(resp),
+					DEFAULT_TIMEOUT);
+
+	if (err < 0)
+		goto exit;
+
+	dev_dbg(&client->dev, "Status bits: 0x%02x\n", resp[0]);
+
+	if (!(resp[0] & SI4713_STC_INT))
+		err = -EIO;
+
+exit:
+	return err;
+}
+
+/*
+ * si4713_tx_tune_freq - Sets the state of the RF carrier and sets the tuning
+ * 			frequency between 76 and 108 MHz in 10 kHz units and
+ * 			steps of 50 kHz.
+ * @sdev: si4713_device structure for the device we are communicating
+ * @frequency: desired frequency (76 - 108 MHz, unit 10 KHz, step 50 kHz)
+ */
+static int si4713_tx_tune_freq(struct si4713_device *sdev, u16 frequency)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
+	int err;
+	u8 val[SI4713_TXFREQ_NRESP];
+	/*
+	 * REVISIT: From Programming Manual
+	 * 	.First byte = 0
+	 * 	.Second byte = frequency's MSB
+	 * 	.Third byte = frequency's LSB
+	 */
+	const u8 args[SI4713_TXFREQ_NARGS] = {
+		0x00,
+		msb(frequency),
+		lsb(frequency),
+	};
+
+	err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_FREQ,
+				  args, ARRAY_SIZE(args), val,
+				  ARRAY_SIZE(val), DEFAULT_TIMEOUT);
+
+	if (err < 0)
+		return err;
+
+	dev_dbg(&client->dev, "Status from tx tune freq: 0x%02x\n",
+		val[0]);
+
+	err = si4713_wait_stc(sdev, TIMEOUT_TX_TUNE);
+	if (err < 0)
+		return err;
+
+	return compose_u16(args[1], args[2]);
+}
+
+/*
+ * si4713_tx_tune_power - Sets the RF voltage level between 88 and 115 dBuV in
+ * 			1 dB units. A value of 0x00 indicates off. The command
+ * 			also sets the antenna tuning capacitance. A value of 0
+ * 			indicates autotuning, and a value of 1 - 191 indicates
+ * 			a manual override, which results in a tuning
+ * 			capacitance of 0.25 pF x @antcap.
+ * @sdev: si4713_device structure for the device we are communicating
+ * @power: tuning power (88 - 115 dBuV, unit/step 1 dB)
+ * @antcap: value of antenna tuning capacitor (0 - 191)
+ */
+static int si4713_tx_tune_power(struct si4713_device *sdev, u8 power,
+				u8 antcap)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
+	int err;
+	u8 val[SI4713_TXPWR_NRESP];
+	/*
+	 * REVISIT: From Programming Manual
+	 * 	.First byte = 0
+	 * 	.Second byte = 0
+	 * 	.Third byte = power
+	 * 	.Fourth byte = antcap
+	 */
+	const u8 args[SI4713_TXPWR_NARGS] = {
+		0x00,
+		0x00,
+		power,
+		antcap,
+	};
+
+	if (((power > 0) && (power < SI4713_MIN_POWER)) ||
+		power > SI4713_MAX_POWER || antcap > SI4713_MAX_ANTCAP)
+		return -EDOM;
+
+	err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_POWER,
+				  args, ARRAY_SIZE(args), val,
+				  ARRAY_SIZE(val), DEFAULT_TIMEOUT);
+
+	if (err < 0)
+		return err;
+
+	dev_dbg(&client->dev, "Status from tx tune power: 0x%02x\n",
+		val[0]);
+
+	return si4713_wait_stc(sdev, TIMEOUT_TX_TUNE_POWER);
+}
+
+/*
+ * si4713_tx_tune_measure - Enters receive mode and measures the received noise
+ * 			level in units of dBuV on the selected frequency.
+ * 			The Frequency must be between 76 and 108 MHz in 10 kHz
+ * 			units and steps of 50 kHz. The command also sets the
+ * 			antenna	tuning capacitance. A value of 0 means
+ * 			autotuning, and a value of 1 to 191 indicates manual
+ * 			override.
+ * @sdev: si4713_device structure for the device we are communicating
+ * @frequency: desired frequency (76 - 108 MHz, unit 10 KHz, step 50 kHz)
+ * @antcap: value of antenna tuning capacitor (0 - 191)
+ */
+static int si4713_tx_tune_measure(struct si4713_device *sdev, u16 frequency,
+					u8 antcap)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
+	int err;
+	u8 val[SI4713_TXMEA_NRESP];
+	/*
+	 * REVISIT: From Programming Manual
+	 * 	.First byte = 0
+	 * 	.Second byte = frequency's MSB
+	 * 	.Third byte = frequency's LSB
+	 * 	.Fourth byte = antcap
+	 */
+	const u8 args[SI4713_TXMEA_NARGS] = {
+		0x00,
+		msb(frequency),
+		lsb(frequency),
+		antcap,
+	};
+
+	sdev->tune_rssi = DEFAULT_TUNE_RSSI;
+
+	if (antcap > SI4713_MAX_ANTCAP)
+		return -EDOM;
+
+	err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_MEASURE,
+				  args, ARRAY_SIZE(args), val,
+				  ARRAY_SIZE(val), DEFAULT_TIMEOUT);
+
+	if (err < 0)
+		return err;
+
+	dev_dbg(&client->dev, "Status from tx tune measure: 0x%02x\n",
+		val[0]);
+
+	return si4713_wait_stc(sdev, TIMEOUT_TX_TUNE);
+}
+
+/*
+ * si4713_tx_tune_status- Returns the status of the tx_tune_freq, tx_tune_mea or
+ * 			tx_tune_power commands. This command return the current
+ * 			frequency, output voltage in dBuV, the antenna tunning
+ * 			capacitance value and the received noise level. The
+ * 			command also clears the stcint interrupt bit when the
+ * 			first bit of its arguments is high.
+ * @sdev: si4713_device structure for the device we are communicating
+ * @intack: 0x01 to clear the seek/tune complete interrupt status indicator.
+ * @frequency: returned frequency
+ * @power: returned power
+ * @antcap: returned antenna capacitance
+ * @noise: returned noise level
+ */
+static int si4713_tx_tune_status(struct si4713_device *sdev, u8 intack,
+					u16 *frequency,	u8 *power,
+					u8 *antcap, u8 *noise)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
+	int err;
+	u8 val[SI4713_TXSTATUS_NRESP];
+	/*
+	 * REVISIT: From Programming Manual
+	 * 	.First byte = intack bit
+	 */
+	const u8 args[SI4713_TXSTATUS_NARGS] = {
+		intack & SI4713_INTACK_MASK,
+	};
+
+	err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_STATUS,
+				  args, ARRAY_SIZE(args), val,
+				  ARRAY_SIZE(val), DEFAULT_TIMEOUT);
+
+	if (!err) {
+		dev_dbg(&client->dev,
+			"Status from tx tune status: 0x%02x\n", val[0]);
+		*frequency = compose_u16(val[2], val[3]);
+		sdev->frequency = *frequency;
+		*power = val[5];
+		*antcap = val[6];
+		*noise = val[7];
+		dev_dbg(&client->dev, "Tune status: %d x 10 kHz "
+				"(power %d, antcap %d, rnl %d)\n",
+				*frequency, *power, *antcap, *noise);
+	}
+
+	return err;
+}
+
+/*
+ * si4713_tx_rds_buff - Loads the RDS group buffer FIFO or circular buffer.
+ * @sdev: si4713_device structure for the device we are communicating
+ * @mode: the buffer operation mode.
+ * @rdsb: RDS Block B
+ * @rdsc: RDS Block C
+ * @rdsd: RDS Block D
+ * @intstatus: returns current interrupt status
+ * @cbavail: returns the number of available circular buffer blocks.
+ * @cbused: returns the number of used circular buffer blocks.
+ * @fifoavail: returns the number of available fifo buffer blocks.
+ * @fifoused: returns the number of used fifo buffer blocks.
+ */
+static int si4713_tx_rds_buff(struct si4713_device *sdev, u8 mode, u16 rdsb,
+				u16 rdsc, u16 rdsd, u8 *intstatus, u8 *cbavail,
+				u8 *cbused, u8 *fifoavail, u8 *fifoused)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
+	int err;
+	u8 val[SI4713_RDSBUFF_NRESP];
+
+	const u8 args[SI4713_RDSBUFF_NARGS] = {
+		mode & SI4713_RDSBUFF_MODE_MASK,
+		msb(rdsb),
+		lsb(rdsb),
+		msb(rdsc),
+		lsb(rdsc),
+		msb(rdsd),
+		lsb(rdsd),
+	};
+
+	err = si4713_send_command(sdev, SI4713_CMD_TX_RDS_BUFF,
+				  args, ARRAY_SIZE(args), val,
+				  ARRAY_SIZE(val), DEFAULT_TIMEOUT);
+
+	if (!err) {
+		dev_dbg(&client->dev,
+			"Status from tx rds buff: 0x%02x\n", val[0]);
+		*intstatus = val[1];
+		*cbavail = val[2];
+		*cbused = val[3];
+		*fifoavail = val[4];
+		*fifoused = val[5];
+		dev_dbg(&client->dev, "rds buffer status: interrupts"
+				" 0x%02x cb avail: %d cb used %d fifo avail"
+				" %d fifo used %d\n", *intstatus, *cbavail,
+				*cbused, *fifoavail, *fifoused);
+	}
+
+	return err;
+}
+
+/*
+ * si4713_tx_rds_ps - Loads the program service buffer.
+ * @sdev: si4713_device structure for the device we are communicating
+ * @psid: program service id to be loaded.
+ * @pschar: assumed 4 size char array to be loaded into the program service
+ */
+static int si4713_tx_rds_ps(struct si4713_device *sdev, u8 psid,
+				unsigned char *pschar)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
+	int err;
+	u8 val[SI4713_RDSPS_NRESP];
+
+	const u8 args[SI4713_RDSPS_NARGS] = {
+		psid & SI4713_RDSPS_PSID_MASK,
+		pschar[0],
+		pschar[1],
+		pschar[2],
+		pschar[3],
+	};
+
+	err = si4713_send_command(sdev, SI4713_CMD_TX_RDS_PS,
+				  args, ARRAY_SIZE(args), val,
+				  ARRAY_SIZE(val), DEFAULT_TIMEOUT);
+
+	if (err < 0)
+		return err;
+
+	dev_dbg(&client->dev, "Status from tx rds ps: 0x%02x\n",
+		val[0]);
+
+	return err;
+}
+
+/* TODO: Remove getters and setters functions and simplify driver code */
+
+/* getters */
+/* tx_tune_status */
+static int si4713_get_power_level(struct si4713_device *sdev)
+{
+	int rval;
+	u16 f = 0;
+	u8 p, a, n;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_tx_tune_status(sdev, 0x00, &f, &p, &a, &n);
+
+		if (rval < 0)
+			goto unlock;
+
+		sdev->power_level = p;
+	}
+
+	rval = sdev->power_level;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_get_antenna_capacitor(struct si4713_device *sdev)
+{
+	int rval = 0;
+	u16 f = 0;
+	u8 p, a, n;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_tx_tune_status(sdev, 0x00, &f, &p, &a, &n);
+
+		if (rval < 0)
+			goto unlock;
+
+		sdev->antenna_capacitor = a;
+	}
+
+	rval = sdev->antenna_capacitor;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_get_tune_measure(struct si4713_device *sdev)
+{
+	int rval;
+	u16 f = 0;
+	u8 p, a, n;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_tx_tune_status(sdev, 0x00, &f, &p, &a, &n);
+
+		if (rval < 0)
+			goto unlock;
+
+		sdev->tune_rssi = n;
+	}
+
+	rval = sdev->tune_rssi;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_get_frequency(struct si4713_device *sdev)
+{
+	int rval;
+	u16 f = 0;
+	u8 p, a, n;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_tx_tune_status(sdev, 0x00, &f, &p, &a, &n);
+
+		if (rval < 0)
+			goto unlock;
+
+		sdev->frequency = f;
+	}
+
+	rval = sdev->frequency;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+/* read_property */
+static int si4713_get_mute(struct si4713_device *sdev)
+{
+	int rval;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_LINE_INPUT_MUTE);
+
+		if (rval < 0)
+			goto unlock;
+
+		sdev->mute = rval;
+	}
+
+	rval = get_mute(sdev->mute);
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_get_rds_pi(struct si4713_device *sdev)
+{
+	int rval;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_RDS_PI);
+
+		if (rval < 0)
+			goto unlock;
+
+		sdev->rds_info.pi = rval;
+	}
+
+	rval = sdev->rds_info.pi;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_get_rds_pty(struct si4713_device *sdev)
+{
+	int rval;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_RDS_PS_MISC);
+
+		if (rval < 0)
+			goto unlock;
+
+		sdev->rds_info.pty = get_pty(rval);
+	}
+
+	rval = sdev->rds_info.pty;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+
+static int si4713_get_rds_enabled(struct si4713_device *sdev)
+{
+	int rval;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE);
+		if (rval < 0)
+			goto unlock;
+
+		sdev->rds_info.enabled = get_rds_status(rval);
+	}
+
+	rval = sdev->rds_info.enabled;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_get_preemphasis(struct si4713_device *sdev)
+{
+	int rval;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_PREEMPHASIS);
+
+		if (rval < 0)
+			goto unlock;
+
+		switch (rval) {
+		case FMPE_USA:
+			sdev->preemphasis = V4L2_FM_TX_PREEMPHASIS_75_uS;
+			break;
+		case FMPE_EU:
+			sdev->preemphasis = V4L2_FM_TX_PREEMPHASIS_50_uS;
+			break;
+		case FMPE_DISABLED:
+			sdev->preemphasis = V4L2_FM_TX_PREEMPHASIS_DISABLED;
+			break;
+		default:
+			rval = -EINVAL;
+			goto unlock;
+		}
+	}
+
+	rval = sdev->preemphasis;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_get_limiter_enabled(struct si4713_device *sdev)
+{
+	int rval;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_ACOMP_ENABLE);
+		if (rval < 0)
+			goto unlock;
+
+		sdev->limiter_info.enabled = get_limiter_status(rval);
+	}
+
+	rval = sdev->limiter_info.enabled;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static long si4713_get_limiter_deviation(struct si4713_device *sdev)
+{
+	int rval;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_AUDIO_DEVIATION);
+
+		if (rval < 0)
+			goto unlock;
+
+		/* Device returns in 10Hz units */
+		sdev->limiter_info.deviation = rval * 10;
+	}
+
+	rval = sdev->limiter_info.deviation;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static long si4713_get_limiter_release_time(struct si4713_device *sdev)
+{
+	int rval;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev,
+				SI4713_TX_LIMITER_RELEASE_TIME);
+
+		if (rval < 0)
+			goto unlock;
+
+		sdev->limiter_info.release_time = dev_to_usecs(rval,
+						limiter_times,
+						ARRAY_SIZE(limiter_times));
+	}
+
+	rval = sdev->limiter_info.release_time;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_get_stereo_enabled(struct si4713_device *sdev)
+{
+	int rval;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE);
+		if (rval < 0)
+			goto unlock;
+
+		sdev->stereo = get_stereo_status(rval);
+	}
+
+	rval = sdev->stereo;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_get_pilot_enabled(struct si4713_device *sdev)
+{
+	int rval;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE);
+		if (rval < 0)
+			goto unlock;
+
+		sdev->pilot_info.enabled = get_pilot_status(rval);
+	}
+
+	rval = sdev->pilot_info.enabled;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static long si4713_get_pilot_deviation(struct si4713_device *sdev)
+{
+	int rval;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_PILOT_DEVIATION);
+
+		if (rval < 0)
+			goto unlock;
+
+		/* Device returns in 10Hz units */
+		sdev->pilot_info.deviation = rval * 10;
+	}
+
+	rval = sdev->pilot_info.deviation;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_get_pilot_frequency(struct si4713_device *sdev)
+{
+	int rval;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_PILOT_FREQUENCY);
+
+		if (rval < 0)
+			goto unlock;
+
+		sdev->pilot_info.frequency = rval;
+	}
+
+	rval = sdev->pilot_info.frequency;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_get_acomp_enabled(struct si4713_device *sdev)
+{
+	int rval;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_ACOMP_ENABLE);
+		if (rval < 0)
+			goto unlock;
+
+		sdev->acomp_info.enabled = get_acomp_status(rval);
+	}
+
+	rval = sdev->acomp_info.enabled;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_get_acomp_gain(struct si4713_device *sdev)
+{
+	int rval;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_ACOMP_GAIN);
+
+		if (rval < 0)
+			goto unlock;
+
+		sdev->acomp_info.gain = rval;
+	}
+
+	rval = sdev->acomp_info.gain;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_get_acomp_threshold(struct si4713_device *sdev, s8 *threshold)
+{
+	int rval;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_ACOMP_THRESHOLD);
+
+		if (rval < 0)
+			goto unlock;
+
+		sdev->acomp_info.threshold = rval;
+	}
+
+	*threshold = sdev->acomp_info.threshold;
+	rval = 0;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static long si4713_get_acomp_release_time(struct si4713_device *sdev)
+{
+	int rval;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev,
+				SI4713_TX_ACOMP_RELEASE_TIME);
+
+		if (rval < 0)
+			goto unlock;
+
+		sdev->acomp_info.release_time = dev_to_usecs(rval,
+						acomp_rtimes,
+						ARRAY_SIZE(acomp_rtimes));
+	}
+
+	rval = sdev->acomp_info.release_time;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+
+static int si4713_get_acomp_attack_time(struct si4713_device *sdev)
+{
+	int rval;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev,
+				SI4713_TX_ACOMP_RELEASE_TIME);
+
+		if (rval < 0)
+			goto unlock;
+
+		sdev->acomp_info.attack_time = rval * ATTACK_TIME_UNIT;
+	}
+
+	rval = sdev->acomp_info.attack_time;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+/* not read property */
+static int si4713_get_rds_ps_name(struct si4713_device *sdev, char *ps_name)
+{
+	mutex_lock(&sdev->mutex);
+	strncpy(ps_name, sdev->rds_info.ps_name, MAX_RDS_PS_NAME);
+	mutex_unlock(&sdev->mutex);
+
+	return 0;
+}
+
+static int si4713_get_rds_radio_text(struct si4713_device *sdev,
+							char *radio_text)
+{
+	mutex_lock(&sdev->mutex);
+	strncpy(radio_text, sdev->rds_info.radio_text, MAX_RDS_RADIO_TEXT);
+	mutex_unlock(&sdev->mutex);
+
+	return 0;
+}
+
+/* setters */
+static int si4713_set_power_level(struct si4713_device *sdev, u8 power_level)
+{
+	int rval;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_tx_tune_power(sdev, power_level,
+						sdev->antenna_capacitor);
+
+		if (rval < 0)
+			goto unlock;
+	}
+
+	sdev->power_level = power_level;
+	rval = 0;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_set_antenna_capacitor(struct si4713_device *sdev, u8 value)
+{
+	int rval = 0;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state)
+		rval = si4713_tx_tune_power(sdev, sdev->power_level, value);
+
+	if (!rval)
+		sdev->antenna_capacitor = value;
+
+	mutex_unlock(&sdev->mutex);
+
+	return rval;
+}
+
+static int si4713_set_power_state(struct si4713_device *sdev, u8 value)
+{
+	int rval;
+
+	mutex_lock(&sdev->mutex);
+
+	if (value)
+		rval = si4713_powerup(sdev);
+	else
+		rval = si4713_powerdown(sdev);
+
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_set_frequency(struct si4713_device *sdev, u16 frequency)
+{
+	int rval = 0;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_tx_tune_freq(sdev, frequency);
+		if (rval < 0)
+			goto unlock;
+		frequency = rval;
+	}
+	sdev->frequency = frequency;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_set_mute(struct si4713_device *sdev, u16 mute)
+{
+	int rval = 0;
+
+	mute = set_mute(mute);
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state)
+		rval = si4713_write_property(sdev,
+				SI4713_TX_LINE_INPUT_MUTE, mute);
+
+	if (rval >= 0)
+		sdev->mute = get_mute(mute);
+
+	mutex_unlock(&sdev->mutex);
+
+	return rval;
+}
+
+static int si4713_set_rds_pi(struct si4713_device *sdev, u16 pi)
+{
+	int rval = 0;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state)
+		rval = si4713_write_property(sdev, SI4713_TX_RDS_PI, pi);
+
+	if (rval >= 0)
+		sdev->rds_info.pi = pi;
+
+	mutex_unlock(&sdev->mutex);
+
+	return rval;
+}
+
+static int si4713_set_rds_pty(struct si4713_device *sdev, u8 pty)
+{
+	int rval = 0;
+	u16 p;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_RDS_PS_MISC);
+		if (rval < 0)
+			goto unlock;
+
+		p = set_pty(rval, pty);
+
+		rval = si4713_write_property(sdev, SI4713_TX_RDS_PS_MISC, p);
+		if (rval < 0)
+			goto unlock;
+	}
+
+	sdev->rds_info.pty = pty;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_set_rds_ps_name(struct si4713_device *sdev, char *ps_name)
+{
+	int rval = 0, i;
+	u8 len = 0;
+	u8 *tmp;
+
+	if (!strlen(ps_name))
+		return -EINVAL;
+
+	tmp = kzalloc(MAX_RDS_PS_NAME + 1, GFP_KERNEL);
+	if (!tmp)
+		return -ENOMEM;
+
+	strncpy(tmp, ps_name, MAX_RDS_PS_NAME);
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		/* Write the new ps name and clear the padding */
+		for (i = 0; i < MAX_RDS_PS_NAME; i += (RDS_BLOCK / 2)) {
+			rval = si4713_tx_rds_ps(sdev, (i / (RDS_BLOCK / 2)),
+						tmp + i);
+			if (rval < 0)
+				goto unlock;
+		}
+
+		/* Setup the size to be sent */
+		len = strlen(tmp) - 1;
+
+		rval = si4713_write_property(sdev,
+				SI4713_TX_RDS_PS_MESSAGE_COUNT,
+				rds_ps_nblocks(len));
+		if (rval < 0)
+			goto unlock;
+
+		rval = si4713_write_property(sdev,
+				SI4713_TX_RDS_PS_REPEAT_COUNT,
+				DEFAULT_RDS_PS_REPEAT_COUNT * 2);
+		if (rval < 0)
+			goto unlock;
+	}
+
+	strncpy(sdev->rds_info.ps_name, tmp, MAX_RDS_PS_NAME);
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	kfree(tmp);
+	return rval;
+}
+
+static int si4713_set_rds_radio_text(struct si4713_device *sdev,
+							char *radio_text)
+{
+	int rval = 0, i;
+	u16 t_index = 0;
+	u8 s, a, u, fa, fu, b_index = 0, cr_inserted = 0;
+	u8 *tmp;
+
+	if (!strlen(radio_text))
+		return -EINVAL;
+
+	tmp = kzalloc(MAX_RDS_RADIO_TEXT + 1, GFP_KERNEL);
+	if (!tmp)
+		return -ENOMEM;
+
+	strncpy(tmp, radio_text, MAX_RDS_RADIO_TEXT);
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_tx_rds_buff(sdev, RDS_BLOCK_CLEAR, 0, 0, 0,
+						&s, &a, &u, &fa, &fu);
+		if (rval < 0)
+			goto unlock;
+		do {
+			/* RDS spec says that if the last block isn't used,
+			 * then apply a carriage return
+			 */
+			if (t_index < (RDS_RADIOTEXT_INDEX_MAX * \
+				RDS_RADIOTEXT_BLK_SIZE)) {
+				for (i = 0; i < RDS_RADIOTEXT_BLK_SIZE; i++) {
+					if (!tmp[t_index + i] ||
+						tmp[t_index + i] == \
+						RDS_CARRIAGE_RETURN) {
+						tmp[t_index + i] =
+							RDS_CARRIAGE_RETURN;
+						cr_inserted = 1;
+						break;
+					}
+				}
+			}
+
+			rval = si4713_tx_rds_buff(sdev, RDS_BLOCK_LOAD,
+					compose_u16(RDS_RADIOTEXT_2A,
+						b_index++),
+					compose_u16(tmp[t_index],
+						tmp[t_index + 1]),
+					compose_u16(tmp[t_index + 2],
+						tmp[t_index + 3]),
+					&s, &a, &u, &fa, &fu);
+			if (rval < 0)
+				goto unlock;
+
+			t_index += RDS_RADIOTEXT_BLK_SIZE;
+
+			if (cr_inserted)
+				break;
+		} while (u < a);
+	}
+
+	strncpy(sdev->rds_info.radio_text, tmp, MAX_RDS_RADIO_TEXT);
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	kfree(tmp);
+	return rval;
+}
+
+static int si4713_set_rds_enabled(struct si4713_device *sdev, u8 enabled)
+{
+	int rval = 0;
+	u16 p;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE);
+		if (rval < 0)
+			goto unlock;
+
+		p = rval;
+		if (enabled)
+			p = enable_rds(p);
+		else
+			p = disable_rds(p);
+
+		rval = si4713_write_property(sdev, SI4713_TX_COMPONENT_ENABLE,
+				p);
+		if (rval < 0)
+			goto unlock;
+
+		if (enabled) {
+			rval = si4713_write_property(sdev,
+				SI4713_TX_RDS_DEVIATION,
+				DEFAULT_RDS_DEVIATION);
+			if (rval < 0)
+				goto unlock;
+		}
+	}
+
+	sdev->rds_info.enabled = enabled & 0x01;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_set_preemphasis(struct si4713_device *sdev, u8 preemphasis)
+{
+	int rval = 0;
+	u8 val;
+
+	switch (preemphasis) {
+	case V4L2_FM_TX_PREEMPHASIS_75_uS:
+		val = FMPE_USA;
+		break;
+	case V4L2_FM_TX_PREEMPHASIS_50_uS:
+		val = FMPE_EU;
+		break;
+	case V4L2_FM_TX_PREEMPHASIS_DISABLED:
+		val = FMPE_DISABLED;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state)
+		rval = si4713_write_property(sdev, SI4713_TX_PREEMPHASIS, val);
+
+	if (rval >= 0)
+		sdev->preemphasis = preemphasis;
+
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_set_limiter_enabled(struct si4713_device *sdev, u8 enabled)
+{
+	int rval = 0;
+	u16 p;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_ACOMP_ENABLE);
+		if (rval < 0)
+			goto unlock;
+
+		p = rval;
+		if (enabled)
+			p = enable_limiter(p);
+		else
+			p = disable_limiter(p);
+
+		rval = si4713_write_property(sdev, SI4713_TX_ACOMP_ENABLE,
+				p);
+
+		if (rval < 0)
+			goto unlock;
+	}
+
+	sdev->limiter_info.enabled = enabled & 0x01;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_set_limiter_deviation(struct si4713_device *sdev,
+					unsigned long deviation)
+{
+	int rval = 0;
+
+	/* Device receives in 10Hz units */
+	deviation /= 10;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state)
+		rval = si4713_write_property(sdev, SI4713_TX_AUDIO_DEVIATION,
+						deviation);
+
+	/* Device returns in 10Hz units */
+	if (rval >= 0)
+		sdev->limiter_info.deviation = deviation * 10;
+
+	mutex_unlock(&sdev->mutex);
+
+	return rval;
+}
+
+static int si4713_set_limiter_release_time(struct si4713_device *sdev,
+					unsigned long rtime)
+{
+	int rval;
+
+	rval = usecs_to_dev(rtime, limiter_times, ARRAY_SIZE(limiter_times));
+	if (rval < 0)
+		goto exit;
+
+	rtime = rval;
+	rval = 0;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state)
+		rval = si4713_write_property(sdev,
+				SI4713_TX_LIMITER_RELEASE_TIME,	rtime);
+
+	if (rval >= 0)
+		sdev->limiter_info.release_time = dev_to_usecs(rtime,
+						limiter_times,
+						ARRAY_SIZE(limiter_times));
+
+	mutex_unlock(&sdev->mutex);
+
+exit:
+	return rval;
+}
+
+static int si4713_set_stereo_enabled(struct si4713_device *sdev, u8 enabled)
+{
+	int rval = 0;
+	u16 p;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE);
+		if (rval < 0)
+			goto unlock;
+
+		p = rval;
+		if (enabled)
+			p = enable_stereo(p);
+		else
+			p = disable_stereo(p);
+
+		rval = si4713_write_property(sdev, SI4713_TX_COMPONENT_ENABLE,
+				p);
+
+		if (rval < 0)
+			goto unlock;
+	}
+
+	sdev->stereo = enabled & 0x01;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_set_pilot_enabled(struct si4713_device *sdev, u8 enabled)
+{
+	int rval = 0;
+	u16 p;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE);
+		if (rval < 0)
+			goto unlock;
+
+		p = rval;
+		if (enabled)
+			p = enable_pilot(p);
+		else
+			p = disable_pilot(p);
+
+		rval = si4713_write_property(sdev, SI4713_TX_COMPONENT_ENABLE,
+				p);
+
+		if (rval < 0)
+			goto unlock;
+	}
+
+	sdev->pilot_info.enabled = enabled & 0x01;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_set_pilot_deviation(struct si4713_device *sdev,
+					unsigned long deviation)
+{
+	int rval = 0;
+
+	/* Device receives in 10Hz units */
+	deviation /= 10;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state)
+		rval = si4713_write_property(sdev, SI4713_TX_PILOT_DEVIATION,
+						deviation);
+
+	/* Device returns in 10Hz units */
+	if (rval >= 0)
+		sdev->pilot_info.deviation = deviation * 10;
+
+	mutex_unlock(&sdev->mutex);
+
+	return rval;
+}
+
+static int si4713_set_pilot_frequency(struct si4713_device *sdev, u16 freq)
+{
+	int rval = 0;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state)
+		rval = si4713_write_property(sdev, SI4713_TX_PILOT_FREQUENCY,
+						freq);
+
+	if (rval >= 0)
+		sdev->pilot_info.frequency = freq;
+
+	mutex_unlock(&sdev->mutex);
+
+	return rval;
+}
+
+static int si4713_set_acomp_enabled(struct si4713_device *sdev, u8 enabled)
+{
+	int rval = 0;
+	u16 p;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state) {
+		rval = si4713_read_property(sdev, SI4713_TX_ACOMP_ENABLE);
+		if (rval < 0)
+			goto unlock;
+
+		p = rval;
+		if (enabled)
+			p = enable_acomp(p);
+		else
+			p = disable_acomp(p);
+
+		rval = si4713_write_property(sdev, SI4713_TX_ACOMP_ENABLE, p);
+
+		if (rval < 0)
+			goto unlock;
+	}
+
+	sdev->acomp_info.enabled = enabled & 0x01;
+
+unlock:
+	mutex_unlock(&sdev->mutex);
+	return rval;
+}
+
+static int si4713_set_acomp_gain(struct si4713_device *sdev, u8 gain)
+{
+	int rval = 0;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state)
+		rval = si4713_write_property(sdev, SI4713_TX_ACOMP_GAIN, gain);
+
+	if (rval >= 0)
+		sdev->acomp_info.gain = gain;
+
+	mutex_unlock(&sdev->mutex);
+
+	return rval;
+}
+
+static int si4713_set_acomp_threshold(struct si4713_device *sdev, s8 threshold)
+{
+	int rval = 0;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state)
+		rval = si4713_write_property(sdev, SI4713_TX_ACOMP_THRESHOLD,
+						threshold);
+
+	if (rval >= 0)
+		sdev->acomp_info.threshold = threshold;
+
+	mutex_unlock(&sdev->mutex);
+
+	return rval;
+}
+
+static int si4713_set_acomp_release_time(struct si4713_device *sdev,
+					unsigned long rtime)
+{
+	int rval;
+
+	rval = usecs_to_dev(rtime, acomp_rtimes, ARRAY_SIZE(acomp_rtimes));
+	if (rval < 0)
+		goto exit;
+
+	rtime = rval;
+	rval = 0;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state)
+		rval = si4713_write_property(sdev,
+				SI4713_TX_ACOMP_RELEASE_TIME, rtime);
+
+	if (rval >= 0)
+		sdev->acomp_info.release_time = dev_to_usecs(rtime,
+						acomp_rtimes,
+						ARRAY_SIZE(acomp_rtimes));
+
+	mutex_unlock(&sdev->mutex);
+
+exit:
+	return rval;
+}
+
+static int si4713_set_acomp_attack_time(struct si4713_device *sdev, u16 atime)
+{
+	int rval = 0;
+
+	/* Device receives in 0.5 ms units */
+	atime /= ATTACK_TIME_UNIT;
+
+	mutex_lock(&sdev->mutex);
+
+	if (sdev->power_state)
+		rval = si4713_write_property(sdev,
+				SI4713_TX_ACOMP_ATTACK_TIME, atime);
+
+	if (rval >= 0)
+		sdev->acomp_info.attack_time = atime * ATTACK_TIME_UNIT;
+
+	mutex_unlock(&sdev->mutex);
+
+	return rval;
+}
+
+static int si4713_set_tune_measure(struct si4713_device *sdev, u32 frequency)
+{
+	int rval = -ENODEV;
+
+	mutex_lock(&sdev->mutex);
+	if (sdev->power_state)
+		rval = si4713_tx_tune_measure(sdev, frequency / 10, 0);
+	mutex_unlock(&sdev->mutex);
+
+	return rval;
+}
+
+/*
+ * si4713_init - Sets the device up with default configuration.
+ * @sdev: si4713_device structure for the device we are communicating
+ */
+static int si4713_init(struct si4713_device *sdev)
+{
+	int rval;
+
+	rval = si4713_set_rds_pi(sdev, DEFAULT_RDS_PI);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_rds_pty(sdev, DEFAULT_RDS_PTY);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_rds_ps_name(sdev, DEFAULT_RDS_PS_NAME);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_rds_radio_text(sdev, DEFAULT_RDS_RADIO_TEXT);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_rds_enabled(sdev, 1);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_limiter_release_time(sdev, DEFAULT_LIMITER_RTIME);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_limiter_deviation(sdev, DEFAULT_LIMITER_DEV);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_limiter_enabled(sdev, 1);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_pilot_frequency(sdev, DEFAULT_PILOT_FREQUENCY);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_pilot_deviation(sdev, DEFAULT_PILOT_DEVIATION);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_pilot_enabled(sdev, 1);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_stereo_enabled(sdev, 1);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_acomp_attack_time(sdev, DEFAULT_ACOMP_ATIME);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_acomp_release_time(sdev, DEFAULT_ACOMP_RTIME);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_acomp_gain(sdev, DEFAULT_ACOMP_GAIN);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_acomp_threshold(sdev, DEFAULT_ACOMP_THRESHOLD);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_acomp_enabled(sdev, 1);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_mute(sdev, DEFAULT_MUTE);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_power_level(sdev, DEFAULT_POWER_LEVEL);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_preemphasis(sdev, V4L2_FM_TX_PREEMPHASIS_50_uS);
+	if (rval < 0)
+		goto exit;
+
+exit:
+	return rval;
+}
+
+/*
+ * si4713_setup - Sets the device up with current configuration.
+ * @sdev: si4713_device structure for the device we are communicating
+ */
+static int si4713_setup(struct si4713_device *sdev)
+{
+	struct si4713_device *tmp;
+	int rval;
+
+	tmp = kmalloc(sizeof(*tmp), GFP_KERNEL);
+	if (!tmp)
+		return -ENOMEM;
+
+	/* Get a local copy to avoid race */
+	mutex_lock(&sdev->mutex);
+	memcpy(tmp, sdev, sizeof(*sdev));
+	mutex_unlock(&sdev->mutex);
+
+	rval = si4713_set_rds_pi(sdev, tmp->rds_info.pi);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_rds_pty(sdev, tmp->rds_info.pty);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_rds_ps_name(sdev, tmp->rds_info.ps_name);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_rds_radio_text(sdev, tmp->rds_info.radio_text);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_rds_enabled(sdev, tmp->rds_info.enabled);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_limiter_release_time(sdev,
+				tmp->limiter_info.release_time);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_limiter_deviation(sdev, tmp->limiter_info.deviation);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_limiter_enabled(sdev, tmp->limiter_info.enabled);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_pilot_frequency(sdev, tmp->pilot_info.frequency);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_pilot_deviation(sdev, tmp->pilot_info.deviation);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_pilot_enabled(sdev, tmp->pilot_info.enabled);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_stereo_enabled(sdev, tmp->stereo);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_acomp_attack_time(sdev, tmp->acomp_info.attack_time);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_acomp_release_time(sdev,
+						tmp->acomp_info.release_time);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_acomp_gain(sdev, tmp->acomp_info.gain);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_acomp_threshold(sdev, tmp->acomp_info.threshold);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_acomp_enabled(sdev, tmp->acomp_info.enabled);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_mute(sdev, tmp->mute);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_preemphasis(sdev, tmp->preemphasis);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_frequency(sdev, tmp->frequency ? tmp->frequency :
+					DEFAULT_FREQUENCY);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_power_level(sdev, tmp->power_level ?
+					tmp->power_level :
+					DEFAULT_POWER_LEVEL);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_antenna_capacitor(sdev, tmp->antenna_capacitor);
+
+exit:
+	kfree(tmp);
+	return rval;
+}
+
+static int si4713_probe(struct si4713_device *sdev)
+{
+	int rval;
+
+	rval = si4713_set_power_state(sdev, POWER_ON);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_checkrev(sdev);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_set_power_state(sdev, POWER_OFF);
+	if (rval < 0)
+		goto exit;
+
+	rval = si4713_init(sdev);
+
+exit:
+	return rval;
+}
+
+static int si4713_write_econtrol(struct si4713_device *sdev,
+					struct v4l2_ext_control *control)
+{
+	char ps_name[MAX_RDS_PS_NAME + 1];
+	char radio_text[MAX_RDS_RADIO_TEXT + 1];
+	int size;
+	s32 rval = 0;
+
+	switch (control->id) {
+	/* User class controls */
+	case V4L2_CID_AUDIO_MUTE:
+		rval = si4713_set_mute(sdev, control->value);
+		break;
+	/* FM_TX 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;
+	case V4L2_CID_RDS_PS_NAME:
+		size = control->length > MAX_RDS_PS_NAME ? MAX_RDS_PS_NAME :
+								control->length;
+		rval = copy_from_user(ps_name, control->string, size + 1);
+		if (rval < 0)
+			goto exit;
+		rval = si4713_set_rds_ps_name(sdev, ps_name);
+		goto exit;
+	case V4L2_CID_RDS_RADIO_TEXT:
+		size = control->length > MAX_RDS_RADIO_TEXT ?
+					MAX_RDS_RADIO_TEXT : control->length;
+		rval = copy_from_user(radio_text, control->string, size + 1);
+		if (rval < 0)
+			goto exit;
+		rval = si4713_set_rds_radio_text(sdev, radio_text);
+		goto exit;
+
+	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_PREEMPHASIS:
+		rval = si4713_set_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;
+	}
+
+exit:
+	return rval;
+}
+
+static int si4713_read_econtrol(struct si4713_device *sdev,
+				struct v4l2_ext_control *control)
+{
+	s32 rval = 0;
+	s8 val = 0;
+	char ps_name[MAX_RDS_PS_NAME + 1];
+	char radio_text[MAX_RDS_RADIO_TEXT + 1];
+
+	switch (control->id) {
+	/* User class controls */
+	case V4L2_CID_AUDIO_MUTE:
+		rval = si4713_get_mute(sdev);
+		break;
+	/* FM_TX 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;
+
+	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)
+			control->value = val;
+		/* We can have negative value, so return earlier */
+		goto exit;
+	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_PREEMPHASIS:
+		rval = si4713_get_preemphasis(sdev);
+		break;
+
+	/* here we do not use read property */
+	case V4L2_CID_RDS_PS_NAME:
+		rval = si4713_get_rds_ps_name(sdev, ps_name);
+		if (rval < 0)
+			goto exit;
+		rval = copy_to_user(control->string, ps_name,
+							strlen(ps_name) + 1);
+		control->length = strlen(ps_name);
+		goto exit;
+	case V4L2_CID_RDS_RADIO_TEXT:
+		rval = si4713_get_rds_radio_text(sdev, radio_text);
+		if (rval < 0)
+			goto exit;
+		rval = copy_to_user(control->string, radio_text,
+							strlen(radio_text) + 1);
+		control->length = strlen(radio_text);
+		goto exit;
+
+	/* here we use tx tune status */
+	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;
+	};
+
+	if (rval >= 0) {
+		control->value = rval;
+		rval = 0;
+	}
+
+exit:
+	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_FM_TX)
+		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_FM_TX)
+		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 */
+	case V4L2_CID_AUDIO_MUTE:
+		rval = v4l2_ctrl_query_fill(qc, 0, 1, 1, DEFAULT_MUTE);
+		break;
+	/* FM_TX 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_PREEMPHASIS:
+		rval = v4l2_ctrl_query_fill(qc, V4L2_FM_TX_PREEMPHASIS_DISABLED,
+						V4L2_FM_TX_PREEMPHASIS_75_uS, 1,
+						V4L2_FM_TX_PREEMPHASIS_50_uS);
+		break;
+	case V4L2_CID_TUNE_POWER_LEVEL:
+		rval = v4l2_ctrl_query_fill(qc, 0, 120, 1, DEFAULT_POWER_LEVEL);
+		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;
+			rval = 0;
+		}
+		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 = {
+	.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,
+};
+
+/*
+ * si4713_g_modulator - get modulator attributes
+ */
+static int si4713_g_modulator(struct v4l2_subdev *sd, struct v4l2_modulator *vm)
+{
+	struct si4713_device *sdev = to_si4713_device(sd);
+	int rval;
+
+	if (!sdev) {
+		rval = -ENODEV;
+		goto exit;
+	}
+
+	if (vm->index > 0) {
+		rval = -EINVAL;
+		goto exit;
+	}
+
+	strncpy(vm->name, "FM Modulator", 32);
+	vm->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LOW;
+
+	/* Report current frequency range limits */
+	vm->rangelow = si4713_to_v4l2(7600);
+	vm->rangehigh = si4713_to_v4l2(10800);
+
+	/* Report current audio mode: mono or stereo */
+	vm->txsubchans = V4L2_TUNER_SUB_MONO;
+	rval = si4713_get_stereo_enabled(sdev);
+	if (rval < 0)
+		goto exit;
+	if (rval)
+		vm->txsubchans |= V4L2_TUNER_SUB_STEREO;
+
+	/* TODO: Report current signal length */
+
+	rval = 0;
+exit:
+	return rval;
+}
+
+/*
+ * si4713_s_modulator - set modulator attributes
+ */
+static int si4713_s_modulator(struct v4l2_subdev *sd, struct v4l2_modulator *vm)
+{
+	struct si4713_device *sdev = to_si4713_device(sd);
+	int rval;
+
+	if (!sdev) {
+		rval = -ENODEV;
+		goto exit;
+	}
+
+	if (vm->index > 0) {
+		rval = -EINVAL;
+		goto exit;
+	}
+
+	/* Set audio mode: mono or stereo */
+	rval = si4713_set_stereo_enabled(sdev,
+				!!(vm->txsubchans & V4L2_TUNER_SUB_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 = si4713_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;
+
+	rval = si4713_set_frequency(sdev, v4l2_to_si4713(f->frequency));
+	if (rval > 0) {
+		f->frequency = si4713_to_v4l2(rval);
+		rval = 0;
+	}
+
+	return rval;
+}
+
+static const struct v4l2_subdev_tuner_ops si4713_subdev_tuner_ops = {
+	.g_frequency	= si4713_g_frequency,
+	.s_frequency	= si4713_s_frequency,
+	.g_modulator	= si4713_g_modulator,
+	.s_modulator	= si4713_s_modulator,
+};
+
+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 = si4713_probe(sdev);
+	if (rval < 0) {
+		dev_err(&client->dev, "Failed to probe device information.\n");
+		goto free_irq;
+	}
+
+	return 0;
+
+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) {
+		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 i2c_driver si4713_i2c_driver = {
+	.driver		= {
+		.name	= "si4713",
+	},
+	.probe		= si4713_i2c_driver_probe,
+	.remove         = __exit_p(si4713_i2c_driver_remove),
+	.id_table       = si4713_id,
+};
+
+/*
+ * Module Interface
+ */
+static int __init si4713_module_init(void)
+{
+	return i2c_add_driver(&si4713_i2c_driver);
+}
+
+static void __exit si4713_module_exit(void)
+{
+	i2c_del_driver(&si4713_i2c_driver);
+}
+
+module_init(si4713_module_init);
+module_exit(si4713_module_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Eduardo Valentin <eduardo.valentin@nokia.com>");
+MODULE_DESCRIPTION("I2C driver for Si4713 FM Radio Transmitter");
+MODULE_VERSION("0.0.1");
+
diff --git a/linux/drivers/media/radio/si4713-i2c.h b/linux/drivers/media/radio/si4713-i2c.h
new file mode 100644
index 0000000..d3c9259
--- /dev/null
+++ b/linux/drivers/media/radio/si4713-i2c.h
@@ -0,0 +1,226 @@
+/*
+ * drivers/media/radio/si4713-i2c.h
+ *
+ * Property and commands definitions for Si4713 radio transmitter chip.
+ *
+ * Copyright (c) 2008 Instituto Nokia de Tecnologia - INdT
+ * Contact: Eduardo Valentin <eduardo.valentin@nokia.com>
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ *
+ */
+
+#ifndef SI4713_I2C_H
+#define SI4713_I2C_H
+
+#include <media/v4l2-subdev.h>
+#include <media/si4713.h>
+
+#define SI4713_PRODUCT_NUMBER		0x0D
+
+/* Command Timeouts */
+#define DEFAULT_TIMEOUT			500
+#define TIMEOUT_SET_PROPERTY		20
+#define TIMEOUT_TX_TUNE_POWER		30000
+#define TIMEOUT_TX_TUNE			110000
+#define TIMEOUT_POWER_UP		200000
+
+/*
+ * Command and its arguments definitions
+ */
+#define SI4713_PWUP_CTSIEN		(1<<7)
+#define SI4713_PWUP_GPO2OEN		(1<<6)
+#define SI4713_PWUP_PATCH		(1<<5)
+#define SI4713_PWUP_XOSCEN		(1<<4)
+#define SI4713_PWUP_FUNC_TX		0x02
+#define SI4713_PWUP_FUNC_PATCH		0x0F
+#define SI4713_PWUP_OPMOD_ANALOG	0x50
+#define SI4713_PWUP_OPMOD_DIGITAL	0x0F
+#define SI4713_PWUP_NARGS		2
+#define SI4713_PWUP_NRESP		1
+#define SI4713_CMD_POWER_UP		0x01
+
+#define SI4713_GETREV_NRESP		9
+#define SI4713_CMD_GET_REV		0x10
+
+#define SI4713_PWDN_NRESP		1
+#define SI4713_CMD_POWER_DOWN		0x11
+
+#define SI4713_SET_PROP_NARGS		5
+#define SI4713_SET_PROP_NRESP		1
+#define SI4713_CMD_SET_PROPERTY		0x12
+
+#define SI4713_GET_PROP_NARGS		3
+#define SI4713_GET_PROP_NRESP		4
+#define SI4713_CMD_GET_PROPERTY		0x13
+
+#define SI4713_GET_STATUS_NRESP		1
+#define SI4713_CMD_GET_INT_STATUS	0x14
+
+#define SI4713_CMD_PATCH_ARGS		0x15
+#define SI4713_CMD_PATCH_DATA		0x16
+
+#define SI4713_MAX_FREQ			10800
+#define SI4713_MIN_FREQ			7600
+#define SI4713_TXFREQ_NARGS		3
+#define SI4713_TXFREQ_NRESP		1
+#define SI4713_CMD_TX_TUNE_FREQ		0x30
+
+#define SI4713_MAX_POWER		120
+#define SI4713_MIN_POWER		88
+#define SI4713_MAX_ANTCAP		191
+#define SI4713_MIN_ANTCAP		0
+#define SI4713_TXPWR_NARGS		4
+#define SI4713_TXPWR_NRESP		1
+#define SI4713_CMD_TX_TUNE_POWER	0x31
+
+#define SI4713_TXMEA_NARGS		4
+#define SI4713_TXMEA_NRESP		1
+#define SI4713_CMD_TX_TUNE_MEASURE	0x32
+
+#define SI4713_INTACK_MASK		0x01
+#define SI4713_TXSTATUS_NARGS		1
+#define SI4713_TXSTATUS_NRESP		8
+#define SI4713_CMD_TX_TUNE_STATUS	0x33
+
+#define SI4713_OVERMOD_BIT		(1 << 2)
+#define SI4713_IALH_BIT			(1 << 1)
+#define SI4713_IALL_BIT			(1 << 0)
+#define SI4713_ASQSTATUS_NARGS		1
+#define SI4713_ASQSTATUS_NRESP		5
+#define SI4713_CMD_TX_ASQ_STATUS	0x34
+
+#define SI4713_RDSBUFF_MODE_MASK	0x87
+#define SI4713_RDSBUFF_NARGS		7
+#define SI4713_RDSBUFF_NRESP		6
+#define SI4713_CMD_TX_RDS_BUFF		0x35
+
+#define SI4713_RDSPS_PSID_MASK		0x1F
+#define SI4713_RDSPS_NARGS		5
+#define SI4713_RDSPS_NRESP		1
+#define SI4713_CMD_TX_RDS_PS		0x36
+
+#define SI4713_CMD_GPO_CTL		0x80
+#define SI4713_CMD_GPO_SET		0x81
+
+/*
+ * Bits from status response
+ */
+#define SI4713_CTS			(1<<7)
+#define SI4713_ERR			(1<<6)
+#define SI4713_RDS_INT			(1<<2)
+#define SI4713_ASQ_INT			(1<<1)
+#define SI4713_STC_INT			(1<<0)
+
+/*
+ * Property definitions
+ */
+#define SI4713_GPO_IEN			0x0001
+#define SI4713_DIG_INPUT_FORMAT		0x0101
+#define SI4713_DIG_INPUT_SAMPLE_RATE	0x0103
+#define SI4713_REFCLK_FREQ		0x0201
+#define SI4713_REFCLK_PRESCALE		0x0202
+#define SI4713_TX_COMPONENT_ENABLE	0x2100
+#define SI4713_TX_AUDIO_DEVIATION	0x2101
+#define SI4713_TX_PILOT_DEVIATION	0x2102
+#define SI4713_TX_RDS_DEVIATION		0x2103
+#define SI4713_TX_LINE_INPUT_LEVEL	0x2104
+#define SI4713_TX_LINE_INPUT_MUTE	0x2105
+#define SI4713_TX_PREEMPHASIS		0x2106
+#define SI4713_TX_PILOT_FREQUENCY	0x2107
+#define SI4713_TX_ACOMP_ENABLE		0x2200
+#define SI4713_TX_ACOMP_THRESHOLD	0x2201
+#define SI4713_TX_ACOMP_ATTACK_TIME	0x2202
+#define SI4713_TX_ACOMP_RELEASE_TIME	0x2203
+#define SI4713_TX_ACOMP_GAIN		0x2204
+#define SI4713_TX_LIMITER_RELEASE_TIME	0x2205
+#define SI4713_TX_ASQ_INTERRUPT_SOURCE	0x2300
+#define SI4713_TX_ASQ_LEVEL_LOW		0x2301
+#define SI4713_TX_ASQ_DURATION_LOW	0x2302
+#define SI4713_TX_ASQ_LEVEL_HIGH	0x2303
+#define SI4713_TX_ASQ_DURATION_HIGH	0x2304
+#define SI4713_TX_RDS_INTERRUPT_SOURCE	0x2C00
+#define SI4713_TX_RDS_PI		0x2C01
+#define SI4713_TX_RDS_PS_MIX		0x2C02
+#define SI4713_TX_RDS_PS_MISC		0x2C03
+#define SI4713_TX_RDS_PS_REPEAT_COUNT	0x2C04
+#define SI4713_TX_RDS_PS_MESSAGE_COUNT	0x2C05
+#define SI4713_TX_RDS_PS_AF		0x2C06
+#define SI4713_TX_RDS_FIFO_SIZE		0x2C07
+
+#define PREEMPHASIS_USA			75
+#define PREEMPHASIS_EU			50
+#define PREEMPHASIS_DISABLED		0
+#define FMPE_USA			0x00
+#define FMPE_EU				0x01
+#define FMPE_DISABLED			0x02
+
+#define POWER_UP			0x01
+#define POWER_DOWN			0x00
+
+struct rds_info {
+	u16 pi;
+#define MAX_RDS_PTY			31
+	u8 pty;
+#define MAX_RDS_PS_NAME			96
+	u8 ps_name[MAX_RDS_PS_NAME + 1];
+#define MAX_RDS_RADIO_TEXT		384
+	u8 radio_text[MAX_RDS_RADIO_TEXT + 1];
+	u8 enabled;
+};
+
+struct limiter_info {
+#define MAX_LIMITER_RELEASE_TIME	102390
+	unsigned long release_time;
+#define MAX_LIMITER_DEVIATION		90000
+	unsigned long deviation;
+	u8 enabled;
+};
+
+struct pilot_info {
+#define MAX_PILOT_DEVIATION		90000
+	unsigned long deviation;
+#define MAX_PILOT_FREQUENCY		19000
+	u16 frequency;
+	u8 enabled;
+};
+
+struct acomp_info {
+#define MAX_ACOMP_RELEASE_TIME		1000000
+	unsigned long release_time;
+#define MAX_ACOMP_ATTACK_TIME		5000
+	u16 attack_time;
+#define MAX_ACOMP_THRESHOLD		0
+#define MIN_ACOMP_THRESHOLD		(-40)
+	s8 threshold;
+#define MAX_ACOMP_GAIN			20
+	u8 gain;
+	u8 enabled;
+};
+
+/*
+ * si4713_device - private data
+ */
+struct si4713_device {
+	/* v4l2_subdev and i2c reference (v4l2_subdev priv data) */
+	struct v4l2_subdev sd;
+	/* private data structures */
+	struct mutex mutex;
+	struct completion work;
+	struct si4713_platform_data *platform_data;
+	struct rds_info rds_info;
+	struct limiter_info limiter_info;
+	struct pilot_info pilot_info;
+	struct acomp_info acomp_info;
+	u16 frequency;
+	u8 preemphasis;
+	u8 mute;
+	u8 power_level;
+	u8 power_state;
+	u8 antenna_capacitor;
+	u8 stereo;
+	u8 tune_rssi;
+};
+#endif /* ifndef SI4713_I2C_H */
-- 
1.6.2.GIT


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCHv7 8/9] FMTx: si4713: Add Kconfig and Makefile entries
  2009-06-12 17:30             ` [PATCHv7 7/9] FMTx: si4713: Add files to handle si4713 i2c device Eduardo Valentin
@ 2009-06-12 17:30               ` Eduardo Valentin
  2009-06-12 17:30                 ` [PATCHv7 9/9] FMTx: si4713: Add document file Eduardo Valentin
  2009-06-14 12:31               ` [PATCHv7 7/9] FMTx: si4713: Add files to handle si4713 i2c device Hans Verkuil
  1 sibling, 1 reply; 33+ messages in thread
From: Eduardo Valentin @ 2009-06-12 17:30 UTC (permalink / raw)
  To: ext Hans Verkuil, ext Mauro Carvalho Chehab
  Cc: Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media, Eduardo Valentin

Simple add Makefile and Kconfig entries.

Signed-off-by: Eduardo Valentin <eduardo.valentin@nokia.com>
---
 linux/drivers/media/radio/Kconfig  |   22 ++++++++++++++++++++++
 linux/drivers/media/radio/Makefile |    2 ++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/linux/drivers/media/radio/Kconfig b/linux/drivers/media/radio/Kconfig
index 3315cac..6c6a409 100644
--- a/linux/drivers/media/radio/Kconfig
+++ b/linux/drivers/media/radio/Kconfig
@@ -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
diff --git a/linux/drivers/media/radio/Makefile b/linux/drivers/media/radio/Makefile
index 0f2b35b..34ae761 100644
--- a/linux/drivers/media/radio/Makefile
+++ b/linux/drivers/media/radio/Makefile
@@ -15,6 +15,8 @@ obj-$(CONFIG_RADIO_ZOLTRIX) += radio-zoltrix.o
 obj-$(CONFIG_RADIO_GEMTEK) += radio-gemtek.o
 obj-$(CONFIG_RADIO_GEMTEK_PCI) += radio-gemtek-pci.o
 obj-$(CONFIG_RADIO_TRUST) += radio-trust.o
+obj-$(CONFIG_I2C_SI4713) += si4713-i2c.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
-- 
1.6.2.GIT


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCHv7 9/9] FMTx: si4713: Add document file
  2009-06-12 17:30               ` [PATCHv7 8/9] FMTx: si4713: Add Kconfig and Makefile entries Eduardo Valentin
@ 2009-06-12 17:30                 ` Eduardo Valentin
  0 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2009-06-12 17:30 UTC (permalink / raw)
  To: ext Hans Verkuil, ext Mauro Carvalho Chehab
  Cc: Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media, Eduardo Valentin

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 6694 bytes --]

This patch adds a document file for si4713 device driver.
It describes the driver interfaces and organization.

Signed-off-by: Eduardo Valentin <eduardo.valentin@nokia.com>
---
 linux/Documentation/video4linux/si4713.txt |  137 ++++++++++++++++++++++++++++
 1 files changed, 137 insertions(+), 0 deletions(-)
 create mode 100644 linux/Documentation/video4linux/si4713.txt

diff --git a/linux/Documentation/video4linux/si4713.txt b/linux/Documentation/video4linux/si4713.txt
new file mode 100644
index 0000000..46e5e58
--- /dev/null
+++ b/linux/Documentation/video4linux/si4713.txt
@@ -0,0 +1,137 @@
+Driver for I2C radios for the Silicon Labs Si4713 FM Radio Transmitters
+
+Copyright (c) 2009 Nokia Corporation
+Contact: Eduardo Valentin <eduardo.valentin@nokia.com>
+
+
+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.
+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.
+
+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.
+
+When the v4l2 mute property is set to 1 (true), the driver will turn the chip off.
+
+Properties description
+======================
+
+The properties can be accessed using v4l2 extended controls.
+Here is an output from v4l2-ctl util:
+
+# v4l2-ctl -d /dev/radio0 -l --all
+Driver Info:
+        Driver name   : radio-si4713
+        Card type     : Silicon Labs Si4713 Modulator
+        Bus info      : 
+        Driver version: 0
+        Capabilities  : 0x00080000
+                Modulator
+Audio output: 0 (FM Modulator Audio Out)
+Frequency: 1408000 (88000.000000 MHz)
+Video Standard = 0x00000000
+Modulator:
+        Name                 : FM Modulator
+        Capabilities         : 62.5 Hz stereo 
+        Frequency range      : 76.0 MHz - 108.0 MHz
+        Available subchannels: mono stereo 
+
+User Controls
+
+                           mute (bool) : default=1 value=0
+
+FM Radio Modulator Controls
+
+            rds_feature_enabled (bool) : default=1 value=1
+                 rds_program_id (int)  : min=0 max=65535 step=1 default=0 value=0
+               rds_program_type (int)  : min=0 max=31 step=1 default=0 value=0
+                    rds_ps_name (str)  : value='Si4713  ' len=8
+' len=9          rds_radio_text (str)  : value='Si4713  
+  audio_limiter_feature_enabled (bool) : default=1 value=1
+     audio_limiter_release_time (int)  : min=250 max=102390 step=50 default=5010 value=5010 flags=slider
+        audio_limiter_deviation (int)  : min=0 max=90000 step=10 default=66250 value=66250 flags=slider
+audio_compression_feature_enabl (bool) : default=1 value=1
+         audio_compression_gain (int)  : min=0 max=20 step=1 default=15 value=15 flags=slider
+    audio_compression_threshold (int)  : min=-40 max=0 step=1 default=-40 value=-40 flags=slider
+  audio_compression_attack_time (int)  : min=0 max=5000 step=500 default=0 value=2000 flags=slider
+ audio_compression_release_time (int)  : min=100000 max=1000000 step=100000 default=1000000 value=1000000 flags=slider
+     pilot_tone_feature_enabled (bool) : default=1 value=1
+           pilot_tone_deviation (int)  : min=0 max=90000 step=10 default=6750 value=6750 flags=slider
+           pilot_tone_frequency (int)  : min=0 max=19000 step=1 default=19000 value=19000 flags=slider
+          pre_emphasis_settings (menu) : min=0 max=2 default=1 value=2
+               tune_power_level (int)  : min=0 max=120 step=1 default=88 value=88 flags=slider
+         tune_antenna_capacitor (int)  : min=0 max=191 step=1 default=0 value=110 flags=slider
+
+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.
+
+* 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
+
+preemphasis - sets the preemphasis to be applied for transmission.
+
+Testing
+=======
+Testing is usually done with v4l2-ctl utility for managing FM tuner cards.
+The tool can be found in v4l-dvb repository under v4l2-apps/util directory.
+
+Example for setting rds ps name:
+# v4l2-ctl -d /dev/radio0 --set-ctrl=rds_ps_name="Dummy"
+
-- 
1.6.2.GIT


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 5/9] v4l2-spec: Add documentation description for FM TX extended control class
  2009-06-12 17:30         ` [PATCHv7 5/9] v4l2-spec: Add documentation description for FM TX extended control class Eduardo Valentin
  2009-06-12 17:30           ` [PATCHv7 6/9] FMTx: si4713: Add files to add radio interface for si4713 Eduardo Valentin
@ 2009-06-14 10:41           ` Hans Verkuil
  2009-06-14 10:46             ` Eduardo Valentin
  1 sibling, 1 reply; 33+ messages in thread
From: Hans Verkuil @ 2009-06-14 10:41 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: ext Mauro Carvalho Chehab, Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

On Friday 12 June 2009 19:30:36 Eduardo Valentin wrote:
> This single patch adds documentation description for FM Modulator (FM_TX)
> Extended Control Class and its Control IDs. The text was added under
> "Extended Controls" section.
> 
> Signed-off-by: Eduardo Valentin <eduardo.valentin@nokia.com>
> ---
>  v4l2-spec/Makefile      |    1 +
>  v4l2-spec/biblio.sgml   |   10 +++
>  v4l2-spec/controls.sgml |  205 +++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 216 insertions(+), 0 deletions(-)
> 
> diff --git a/v4l2-spec/Makefile b/v4l2-spec/Makefile
> index 7a19924..bfe2965 100644
> --- a/v4l2-spec/Makefile
> +++ b/v4l2-spec/Makefile
> @@ -242,6 +242,7 @@ ENUMS = \
>  	v4l2_power_line_frequency \
>  	v4l2_priority \
>  	v4l2_tuner_type \
> +	v4l2_fm_tx_preemphasis \
>  
>  STRUCTS = \
>  	v4l2_audio \
> diff --git a/v4l2-spec/biblio.sgml b/v4l2-spec/biblio.sgml
> index b013ece..0921849 100644
> --- a/v4l2-spec/biblio.sgml
> +++ b/v4l2-spec/biblio.sgml
> @@ -11,6 +11,16 @@ url="http://www.eia.org">http://www.eia.org</ulink>)</corpauthor>
>  Service"</title>
>      </biblioentry>
>  
> +    <biblioentry id="en50067">
> +      <abbrev>EN&nbsp;50067</abbrev>
> +      <authorgroup>
> +	<corpauthor>CENELEC European Committee for Electrotechnical Standardization
> +(<ulink url="http://www.cenelec.eu">http://www.cenelec.eu</ulink>)</corpauthor>
> +      </authorgroup>
> +      <title>EN 50067 "Specification of the radio data system (RDS) for
> +VHF/FM sound broadcasting in the frequency range from 87,5 to 108,0 MHz"</title>
> +    </biblioentry>
> +
>      <biblioentry id="en300294">
>        <abbrev>EN&nbsp;300&nbsp;294</abbrev>
>        <authorgroup>
> diff --git a/v4l2-spec/controls.sgml b/v4l2-spec/controls.sgml
> index 477a970..0bb6f00 100644
> --- a/v4l2-spec/controls.sgml
> +++ b/v4l2-spec/controls.sgml
> @@ -458,6 +458,12 @@ video is actually encoded into that format.</para>
>        <para>Unfortunately, the original control API lacked some
>  features needed for these new uses and so it was extended into the
>  (not terribly originally named) extended control API.</para>
> +
> +      <para>Even though the MPEG encoding API was the first effort
> +to use the Extended Control API, nowadays there are also other classes
> +of Extended Controls, such as Camera Controls and FM Transmitter Controls.
> +The Extended Controls API as well as all Extended Controls classes are
> +described in the following text.</para>
>      </section>
>  
>      <section>
> @@ -1816,6 +1822,205 @@ control must support read access and may support write access.</entry>
>        </tgroup>
>      </table>
>    </section>
> +
> +    <section id="fm-tx-controls">
> +      <title>FM Transmitter Control Reference</title>
> +
> +      <para>The FM Transmitter (FM_TX) class includes controls for common features of
> +FM transmissions capable devices. Currently this class include parameters for audio
> +compression, pilot tone generation, audio deviation limiter, RDS transmission and
> +tuning power features.</para>
> +
> +      <table pgwide="1" frame="none" id="fm-tx-control-id">
> +      <title>FM_TX Control IDs</title>
> +
> +      <tgroup cols="4">
> +	<colspec colname="c1" colwidth="1*">
> +	<colspec colname="c2" colwidth="6*">
> +	<colspec colname="c3" colwidth="2*">
> +	<colspec colname="c4" colwidth="6*">
> +	<spanspec namest="c1" nameend="c2" spanname="id">
> +	<spanspec namest="c2" nameend="c4" spanname="descr">
> +	<thead>
> +	  <row>
> +	    <entry spanname="id" align="left">ID</entry>
> +	    <entry align="left">Type</entry>
> +	  </row><row rowsep="1"><entry spanname="descr" align="left">Description</entry>
> +	  </row>
> +	</thead>
> +	<tbody valign="top">
> +	  <row><entry></entry></row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_FM_TX_CLASS</constant>&nbsp;</entry>
> +	    <entry>class</entry>
> +	  </row><row><entry spanname="descr">The FM_TX class
> +descriptor. Calling &VIDIOC-QUERYCTRL; for this control will return a
> +description of this control class.</entry>
> +	  </row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_RDS_ENABLED</constant>&nbsp;</entry>
> +	    <entry>boolean</entry>
> +	  </row>
> +	  <row><entry spanname="descr">Enables or disables the RDS transmission feature.</entry>
> +	  </row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_RDS_PI</constant>&nbsp;</entry>
> +	    <entry>integer</entry>
> +	  </row>
> +	  <row><entry spanname="descr">Sets the RDS Programme Identification field
> +for transmission.</entry>
> +	  </row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_RDS_PTY</constant>&nbsp;</entry>
> +	    <entry>integer</entry>
> +	  </row>
> +	  <row><entry spanname="descr">Sets the RDS Programme Type field for transmission.
> +This coding of up to 31 pre-defined programme types.</entry>

coding -> encodes

> +	  </row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_RDS_PS_NAME</constant>&nbsp;</entry>
> +	    <entry>string</entry>
> +	  </row>
> +	  <row><entry spanname="descr">Sets the Programme Service name (PS_NAME) for transmission.
> +It is intended for static display on a receiver. It is the primary aid to listeners in programme service
> +identification and selection. The use of PS to transmit text other than a single eight character name is not permitted.</entry>
> +	  </row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_RDS_RADIO_TEXT</constant>&nbsp;</entry>
> +	    <entry>string</entry>
> +	  </row>
> +	  <row><entry spanname="descr">Sets the Radio Text info for transmission. It is a textual description of
> +what is being broadcasted. If broadcaster wishes to transmit longer PS names, programme-related information or any other
> +text, then RadioText should be used.</entry>

This is slightly ambiguous. I would suggest changing the ending to:

"should be used in addition to <constant>V4L2_CID_RDS_PS_NAME</constant>."

> +	  </row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_AUDIO_LIMITER_ENABLED</constant>&nbsp;</entry>
> +	    <entry>boolean</entry>
> +	  </row>
> +	  <row><entry spanname="descr">Enables or disables the audio deviation limiter feature.
> +The limiter is useful when trying to maximize the audio volume, minimize receiver-generated
> +distortion and prevent overmodulation.
> +</entry>
> +	  </row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_AUDIO_LIMITER_RELEASE_TIME</constant>&nbsp;</entry>
> +	    <entry>integer</entry>
> +	  </row>
> +	  <row><entry spanname="descr">Sets the audio deviation limiter feature release time.
> +The unit, step and range are driver-specific.</entry>

I thought the unit was useconds?

> +	  </row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_AUDIO_LIMITER_DEVIATION</constant>&nbsp;</entry>
> +	    <entry>integer</entry>
> +	  </row>
> +	  <row><entry spanname="descr">Configures audio frequency deviation level in Hz.
> +The range and step are driver-specific.</entry>
> +	  </row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_AUDIO_COMPRESSION_ENABLED</constant>&nbsp;</entry>
> +	    <entry>boolean</entry>
> +	  </row>
> +	  <row><entry spanname="descr">Enables or disables the audio compression feature.
> +This feature amplifies signals below the threshold by a fixed gain and compresses audio
> +signals above the threshold by the ratio of Threshold/(Gain + Threshold).</entry>
> +	  </row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_AUDIO_COMPRESSION_GAIN</constant>&nbsp;</entry>
> +	    <entry>integer</entry>
> +	  </row>
> +	  <row><entry spanname="descr">Sets the gain for audio compression feature. It is
> +a dB value. The range and step are driver-specific.</entry>
> +	  </row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_AUDIO_COMPRESSION_THRESHOLD</constant>&nbsp;</entry>
> +	    <entry>integer</entry>
> +	  </row>
> +	  <row><entry spanname="descr">Sets the threshold level for audio compression freature.
> +It is a dB value. The range and step are driver-specific.</entry>
> +	  </row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME</constant>&nbsp;</entry>
> +	    <entry>integer</entry>
> +	  </row>
> +	  <row><entry spanname="descr">Sets the attack time for audio compression feature.
> +It is a useconds value. The range and step are driver-specific.</entry>
> +	  </row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME</constant>&nbsp;</entry>
> +	    <entry>integer</entry>
> +	  </row>
> +	  <row><entry spanname="descr">Sets the release time for audio compression feature.
> +It is a useconds value. The range and step are driver-specific.</entry>
> +	  </row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_PILOT_TONE_ENABLED</constant>&nbsp;</entry>
> +	    <entry>boolean</entry>
> +	  </row>
> +	  <row><entry spanname="descr">Enables or disables the pilot tone generation feature.</entry>
> +	  </row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_PILOT_TONE_DEVIATION</constant>&nbsp;</entry>
> +	    <entry>integer</entry>
> +	  </row>
> +	  <row><entry spanname="descr">Configures pilot tone frequency deviation level. Unit is
> +in Hz. The range and step are driver-specific.</entry>
> +	  </row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_PILOT_TONE_FREQUENCY</constant>&nbsp;</entry>
> +	    <entry>integer</entry>
> +	  </row>
> +	  <row><entry spanname="descr">Configures pilot tone frequency value. Unit is
> +in Hz. The range and step are driver-specific.</entry>
> +	  </row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_PREEMPHASIS</constant>&nbsp;</entry>
> +	    <entry>integer</entry>
> +	  </row>
> +	  <row id="v4l2-fm-tx-preemphasis"><entry spanname="descr">Configures the pre-emphasis value for broadcasting.
> +A pre-emphasis filter is applied to the broadcast to accentuate the high audio frequencies.
> +Depending on the region, a time constant of either 50 or 75 useconds is used. The enum&nbsp;v4l2_fm_tx_preemphasis
> +defines possible values for pre-emphasis. Here they are:</entry>
> +	</row><row>
> +	<entrytbl spanname="descr" cols="2">
> +		  <tbody valign="top">
> +		    <row>
> +		      <entry><constant>V4L2_FM_TX_PREEMPHASIS_DISABLED</constant>&nbsp;</entry>
> +		      <entry>No pre-emphasis is applied.</entry>
> +		    </row>
> +		    <row>
> +		      <entry><constant>V4L2_FM_TX_PREEMPHASIS_50_uS</constant>&nbsp;</entry>
> +		      <entry>A pre-emphasis of 50 uS is used.</entry>
> +		    </row>
> +		    <row>
> +		      <entry><constant>V4L2_FM_TX_PREEMPHASIS_75_uS</constant>&nbsp;</entry>
> +		      <entry>A pre-emphasis of 75 uS is used.</entry>
> +		    </row>
> +		  </tbody>
> +		</entrytbl>
> +
> +	  </row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_TUNE_POWER_LEVEL</constant>&nbsp;</entry>
> +	    <entry>integer</entry>
> +	  </row>
> +	  <row><entry spanname="descr">Sets the output power level for signal transmission.
> +Unit is in dBuV. Range and step are driver-specific.</entry>
> +	  </row>
> +	  <row>
> +	    <entry spanname="id"><constant>V4L2_CID_TUNE_ANTENNA_CAPACITOR</constant>&nbsp;</entry>
> +	    <entry>integer</entry>
> +	  </row>
> +	  <row><entry spanname="descr">This selects the value of antenna tuning capacitor
> +manually or automatically if set to zero. Unit, range and step are driver-specific.</entry>
> +	  </row>
> +	  <row><entry></entry></row>
> +	</tbody>
> +      </tgroup>
> +      </table>
> +
> +<para>For more details about RDS specification, refer to
> +<xref linkend="en50067"> document, from CENELEC.</para>
> +    </section>
>  </section>
>  
>    <!--

Regards,

	Hans

-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 2/9] v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX controls
  2009-06-12 17:30   ` [PATCHv7 2/9] v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX controls Eduardo Valentin
  2009-06-12 17:30     ` [PATCHv7 3/9] v4l2: video device: Add FM_TX controls default configurations Eduardo Valentin
@ 2009-06-14 10:46     ` Hans Verkuil
  2009-06-14 10:50       ` Eduardo Valentin
  1 sibling, 1 reply; 33+ messages in thread
From: Hans Verkuil @ 2009-06-14 10:46 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: ext Mauro Carvalho Chehab, Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

On Friday 12 June 2009 19:30:33 Eduardo Valentin wrote:
> This patch adds a new class of extended controls. This class
> is intended to support FM Radio Modulators properties such as:
> rds, audio limiters, audio compression, pilot tone generation,
> tuning power levels and preemphasis properties.
> 
> Signed-off-by: Eduardo Valentin <eduardo.valentin@nokia.com>
> ---
>  linux/include/linux/videodev2.h |   34 ++++++++++++++++++++++++++++++++++
>  1 files changed, 34 insertions(+), 0 deletions(-)
> 
> diff --git a/linux/include/linux/videodev2.h b/linux/include/linux/videodev2.h
> index b8cffc9..9733435 100644
> --- a/linux/include/linux/videodev2.h
> +++ b/linux/include/linux/videodev2.h
> @@ -806,6 +806,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_FM_TX 0x009b0000	/* FM Modulator control class */
>  
>  #define V4L2_CTRL_ID_MASK      	  (0x0fffffff)
>  #define V4L2_CTRL_ID2CLASS(id)    ((id) & 0x0fff0000UL)
> @@ -1144,6 +1145,39 @@ enum  v4l2_exposure_auto_type {
>  
>  #define V4L2_CID_PRIVACY			(V4L2_CID_CAMERA_CLASS_BASE+16)
>  
> +/* FM Modulator class control IDs */
> +#define V4L2_CID_FM_TX_CLASS_BASE		(V4L2_CTRL_CLASS_FM_TX | 0x900)
> +#define V4L2_CID_FM_TX_CLASS			(V4L2_CTRL_CLASS_FM_TX | 1)
> +
> +#define V4L2_CID_RDS_ENABLED			(V4L2_CID_FM_TX_CLASS_BASE + 1)
> +#define V4L2_CID_RDS_PI				(V4L2_CID_FM_TX_CLASS_BASE + 2)
> +#define V4L2_CID_RDS_PTY			(V4L2_CID_FM_TX_CLASS_BASE + 3)
> +#define V4L2_CID_RDS_PS_NAME			(V4L2_CID_FM_TX_CLASS_BASE + 4)
> +#define V4L2_CID_RDS_RADIO_TEXT			(V4L2_CID_FM_TX_CLASS_BASE + 5)

I think these RDS controls should be renamed to V4L2_CID_RDS_TX_. This makes
it clear that these controls relate to the RDS transmitter instead of a
receiver. I would not be surprised to see similar controls appear for an RDS
receiver in the future.

> +
> +#define V4L2_CID_AUDIO_LIMITER_ENABLED		(V4L2_CID_FM_TX_CLASS_BASE + 6)
> +#define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME	(V4L2_CID_FM_TX_CLASS_BASE + 7)
> +#define V4L2_CID_AUDIO_LIMITER_DEVIATION	(V4L2_CID_FM_TX_CLASS_BASE + 8)
> +
> +#define V4L2_CID_AUDIO_COMPRESSION_ENABLED	(V4L2_CID_FM_TX_CLASS_BASE + 9)
> +#define V4L2_CID_AUDIO_COMPRESSION_GAIN		(V4L2_CID_FM_TX_CLASS_BASE + 10)
> +#define V4L2_CID_AUDIO_COMPRESSION_THRESHOLD	(V4L2_CID_FM_TX_CLASS_BASE + 11)
> +#define V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME	(V4L2_CID_FM_TX_CLASS_BASE + 12)
> +#define V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME	(V4L2_CID_FM_TX_CLASS_BASE + 13)
> +
> +#define V4L2_CID_PILOT_TONE_ENABLED		(V4L2_CID_FM_TX_CLASS_BASE + 14)
> +#define V4L2_CID_PILOT_TONE_DEVIATION		(V4L2_CID_FM_TX_CLASS_BASE + 15)
> +#define V4L2_CID_PILOT_TONE_FREQUENCY		(V4L2_CID_FM_TX_CLASS_BASE + 16)
> +
> +#define V4L2_CID_PREEMPHASIS			(V4L2_CID_FM_TX_CLASS_BASE + 17)
> +enum v4l2_fm_tx_preemphasis {
> +	V4L2_FM_TX_PREEMPHASIS_DISABLED		= 0,
> +	V4L2_FM_TX_PREEMPHASIS_50_uS		= 1,
> +	V4L2_FM_TX_PREEMPHASIS_75_uS		= 2,
> +};

I suggest renaming this to V4L2_CID_FM_TX_PREEMPHASIS. There is already a
similar V4L2_CID_MPEG_EMPHASIS control and others might well appear in the
future, so I think this name should be more specific to the FM_TX API.

> +#define V4L2_CID_TUNE_POWER_LEVEL		(V4L2_CID_FM_TX_CLASS_BASE + 18)
> +#define V4L2_CID_TUNE_ANTENNA_CAPACITOR		(V4L2_CID_FM_TX_CLASS_BASE + 19)
> +
>  /*
>   *	T U N I N G
>   */

Regards,

	Hans

-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 5/9] v4l2-spec: Add documentation description for FM TX extended control class
  2009-06-14 10:41           ` [PATCHv7 5/9] v4l2-spec: Add documentation description for FM TX extended control class Hans Verkuil
@ 2009-06-14 10:46             ` Eduardo Valentin
  0 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2009-06-14 10:46 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Eduardo Valentin, ext Mauro Carvalho Chehab,
	Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

Hi Hans,

On Sun, Jun 14, 2009 at 1:41 PM, Hans Verkuil<hverkuil@xs4all.nl> wrote:
> On Friday 12 June 2009 19:30:36 Eduardo Valentin wrote:
>> This single patch adds documentation description for FM Modulator (FM_TX)
>> Extended Control Class and its Control IDs. The text was added under
>> "Extended Controls" section.
>>
>> Signed-off-by: Eduardo Valentin <eduardo.valentin@nokia.com>
>> ---
>>  v4l2-spec/Makefile      |    1 +
>>  v4l2-spec/biblio.sgml   |   10 +++
>>  v4l2-spec/controls.sgml |  205 +++++++++++++++++++++++++++++++++++++++++++++++
>>  3 files changed, 216 insertions(+), 0 deletions(-)
>>
>> diff --git a/v4l2-spec/Makefile b/v4l2-spec/Makefile
>> index 7a19924..bfe2965 100644
>> --- a/v4l2-spec/Makefile
>> +++ b/v4l2-spec/Makefile
>> @@ -242,6 +242,7 @@ ENUMS = \
>>       v4l2_power_line_frequency \
>>       v4l2_priority \
>>       v4l2_tuner_type \
>> +     v4l2_fm_tx_preemphasis \
>>
>>  STRUCTS = \
>>       v4l2_audio \
>> diff --git a/v4l2-spec/biblio.sgml b/v4l2-spec/biblio.sgml
>> index b013ece..0921849 100644
>> --- a/v4l2-spec/biblio.sgml
>> +++ b/v4l2-spec/biblio.sgml
>> @@ -11,6 +11,16 @@ url="http://www.eia.org">http://www.eia.org</ulink>)</corpauthor>
>>  Service"</title>
>>      </biblioentry>
>>
>> +    <biblioentry id="en50067">
>> +      <abbrev>EN&nbsp;50067</abbrev>
>> +      <authorgroup>
>> +     <corpauthor>CENELEC European Committee for Electrotechnical Standardization
>> +(<ulink url="http://www.cenelec.eu">http://www.cenelec.eu</ulink>)</corpauthor>
>> +      </authorgroup>
>> +      <title>EN 50067 "Specification of the radio data system (RDS) for
>> +VHF/FM sound broadcasting in the frequency range from 87,5 to 108,0 MHz"</title>
>> +    </biblioentry>
>> +
>>      <biblioentry id="en300294">
>>        <abbrev>EN&nbsp;300&nbsp;294</abbrev>
>>        <authorgroup>
>> diff --git a/v4l2-spec/controls.sgml b/v4l2-spec/controls.sgml
>> index 477a970..0bb6f00 100644
>> --- a/v4l2-spec/controls.sgml
>> +++ b/v4l2-spec/controls.sgml
>> @@ -458,6 +458,12 @@ video is actually encoded into that format.</para>
>>        <para>Unfortunately, the original control API lacked some
>>  features needed for these new uses and so it was extended into the
>>  (not terribly originally named) extended control API.</para>
>> +
>> +      <para>Even though the MPEG encoding API was the first effort
>> +to use the Extended Control API, nowadays there are also other classes
>> +of Extended Controls, such as Camera Controls and FM Transmitter Controls.
>> +The Extended Controls API as well as all Extended Controls classes are
>> +described in the following text.</para>
>>      </section>
>>
>>      <section>
>> @@ -1816,6 +1822,205 @@ control must support read access and may support write access.</entry>
>>        </tgroup>
>>      </table>
>>    </section>
>> +
>> +    <section id="fm-tx-controls">
>> +      <title>FM Transmitter Control Reference</title>
>> +
>> +      <para>The FM Transmitter (FM_TX) class includes controls for common features of
>> +FM transmissions capable devices. Currently this class include parameters for audio
>> +compression, pilot tone generation, audio deviation limiter, RDS transmission and
>> +tuning power features.</para>
>> +
>> +      <table pgwide="1" frame="none" id="fm-tx-control-id">
>> +      <title>FM_TX Control IDs</title>
>> +
>> +      <tgroup cols="4">
>> +     <colspec colname="c1" colwidth="1*">
>> +     <colspec colname="c2" colwidth="6*">
>> +     <colspec colname="c3" colwidth="2*">
>> +     <colspec colname="c4" colwidth="6*">
>> +     <spanspec namest="c1" nameend="c2" spanname="id">
>> +     <spanspec namest="c2" nameend="c4" spanname="descr">
>> +     <thead>
>> +       <row>
>> +         <entry spanname="id" align="left">ID</entry>
>> +         <entry align="left">Type</entry>
>> +       </row><row rowsep="1"><entry spanname="descr" align="left">Description</entry>
>> +       </row>
>> +     </thead>
>> +     <tbody valign="top">
>> +       <row><entry></entry></row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_FM_TX_CLASS</constant>&nbsp;</entry>
>> +         <entry>class</entry>
>> +       </row><row><entry spanname="descr">The FM_TX class
>> +descriptor. Calling &VIDIOC-QUERYCTRL; for this control will return a
>> +description of this control class.</entry>
>> +       </row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_RDS_ENABLED</constant>&nbsp;</entry>
>> +         <entry>boolean</entry>
>> +       </row>
>> +       <row><entry spanname="descr">Enables or disables the RDS transmission feature.</entry>
>> +       </row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_RDS_PI</constant>&nbsp;</entry>
>> +         <entry>integer</entry>
>> +       </row>
>> +       <row><entry spanname="descr">Sets the RDS Programme Identification field
>> +for transmission.</entry>
>> +       </row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_RDS_PTY</constant>&nbsp;</entry>
>> +         <entry>integer</entry>
>> +       </row>
>> +       <row><entry spanname="descr">Sets the RDS Programme Type field for transmission.
>> +This coding of up to 31 pre-defined programme types.</entry>
>
> coding -> encodes

Right.

>
>> +       </row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_RDS_PS_NAME</constant>&nbsp;</entry>
>> +         <entry>string</entry>
>> +       </row>
>> +       <row><entry spanname="descr">Sets the Programme Service name (PS_NAME) for transmission.
>> +It is intended for static display on a receiver. It is the primary aid to listeners in programme service
>> +identification and selection. The use of PS to transmit text other than a single eight character name is not permitted.</entry>
>> +       </row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_RDS_RADIO_TEXT</constant>&nbsp;</entry>
>> +         <entry>string</entry>
>> +       </row>
>> +       <row><entry spanname="descr">Sets the Radio Text info for transmission. It is a textual description of
>> +what is being broadcasted. If broadcaster wishes to transmit longer PS names, programme-related information or any other
>> +text, then RadioText should be used.</entry>
>
> This is slightly ambiguous. I would suggest changing the ending to:
>
> "should be used in addition to <constant>V4L2_CID_RDS_PS_NAME</constant>."

I see. I'll change this.

>
>> +       </row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_AUDIO_LIMITER_ENABLED</constant>&nbsp;</entry>
>> +         <entry>boolean</entry>
>> +       </row>
>> +       <row><entry spanname="descr">Enables or disables the audio deviation limiter feature.
>> +The limiter is useful when trying to maximize the audio volume, minimize receiver-generated
>> +distortion and prevent overmodulation.
>> +</entry>
>> +       </row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_AUDIO_LIMITER_RELEASE_TIME</constant>&nbsp;</entry>
>> +         <entry>integer</entry>
>> +       </row>
>> +       <row><entry spanname="descr">Sets the audio deviation limiter feature release time.
>> +The unit, step and range are driver-specific.</entry>
>
> I thought the unit was useconds?

Yeah. Changing.

>
>> +       </row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_AUDIO_LIMITER_DEVIATION</constant>&nbsp;</entry>
>> +         <entry>integer</entry>
>> +       </row>
>> +       <row><entry spanname="descr">Configures audio frequency deviation level in Hz.
>> +The range and step are driver-specific.</entry>
>> +       </row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_AUDIO_COMPRESSION_ENABLED</constant>&nbsp;</entry>
>> +         <entry>boolean</entry>
>> +       </row>
>> +       <row><entry spanname="descr">Enables or disables the audio compression feature.
>> +This feature amplifies signals below the threshold by a fixed gain and compresses audio
>> +signals above the threshold by the ratio of Threshold/(Gain + Threshold).</entry>
>> +       </row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_AUDIO_COMPRESSION_GAIN</constant>&nbsp;</entry>
>> +         <entry>integer</entry>
>> +       </row>
>> +       <row><entry spanname="descr">Sets the gain for audio compression feature. It is
>> +a dB value. The range and step are driver-specific.</entry>
>> +       </row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_AUDIO_COMPRESSION_THRESHOLD</constant>&nbsp;</entry>
>> +         <entry>integer</entry>
>> +       </row>
>> +       <row><entry spanname="descr">Sets the threshold level for audio compression freature.
>> +It is a dB value. The range and step are driver-specific.</entry>
>> +       </row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME</constant>&nbsp;</entry>
>> +         <entry>integer</entry>
>> +       </row>
>> +       <row><entry spanname="descr">Sets the attack time for audio compression feature.
>> +It is a useconds value. The range and step are driver-specific.</entry>
>> +       </row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME</constant>&nbsp;</entry>
>> +         <entry>integer</entry>
>> +       </row>
>> +       <row><entry spanname="descr">Sets the release time for audio compression feature.
>> +It is a useconds value. The range and step are driver-specific.</entry>
>> +       </row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_PILOT_TONE_ENABLED</constant>&nbsp;</entry>
>> +         <entry>boolean</entry>
>> +       </row>
>> +       <row><entry spanname="descr">Enables or disables the pilot tone generation feature.</entry>
>> +       </row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_PILOT_TONE_DEVIATION</constant>&nbsp;</entry>
>> +         <entry>integer</entry>
>> +       </row>
>> +       <row><entry spanname="descr">Configures pilot tone frequency deviation level. Unit is
>> +in Hz. The range and step are driver-specific.</entry>
>> +       </row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_PILOT_TONE_FREQUENCY</constant>&nbsp;</entry>
>> +         <entry>integer</entry>
>> +       </row>
>> +       <row><entry spanname="descr">Configures pilot tone frequency value. Unit is
>> +in Hz. The range and step are driver-specific.</entry>
>> +       </row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_PREEMPHASIS</constant>&nbsp;</entry>
>> +         <entry>integer</entry>
>> +       </row>
>> +       <row id="v4l2-fm-tx-preemphasis"><entry spanname="descr">Configures the pre-emphasis value for broadcasting.
>> +A pre-emphasis filter is applied to the broadcast to accentuate the high audio frequencies.
>> +Depending on the region, a time constant of either 50 or 75 useconds is used. The enum&nbsp;v4l2_fm_tx_preemphasis
>> +defines possible values for pre-emphasis. Here they are:</entry>
>> +     </row><row>
>> +     <entrytbl spanname="descr" cols="2">
>> +               <tbody valign="top">
>> +                 <row>
>> +                   <entry><constant>V4L2_FM_TX_PREEMPHASIS_DISABLED</constant>&nbsp;</entry>
>> +                   <entry>No pre-emphasis is applied.</entry>
>> +                 </row>
>> +                 <row>
>> +                   <entry><constant>V4L2_FM_TX_PREEMPHASIS_50_uS</constant>&nbsp;</entry>
>> +                   <entry>A pre-emphasis of 50 uS is used.</entry>
>> +                 </row>
>> +                 <row>
>> +                   <entry><constant>V4L2_FM_TX_PREEMPHASIS_75_uS</constant>&nbsp;</entry>
>> +                   <entry>A pre-emphasis of 75 uS is used.</entry>
>> +                 </row>
>> +               </tbody>
>> +             </entrytbl>
>> +
>> +       </row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_TUNE_POWER_LEVEL</constant>&nbsp;</entry>
>> +         <entry>integer</entry>
>> +       </row>
>> +       <row><entry spanname="descr">Sets the output power level for signal transmission.
>> +Unit is in dBuV. Range and step are driver-specific.</entry>
>> +       </row>
>> +       <row>
>> +         <entry spanname="id"><constant>V4L2_CID_TUNE_ANTENNA_CAPACITOR</constant>&nbsp;</entry>
>> +         <entry>integer</entry>
>> +       </row>
>> +       <row><entry spanname="descr">This selects the value of antenna tuning capacitor
>> +manually or automatically if set to zero. Unit, range and step are driver-specific.</entry>
>> +       </row>
>> +       <row><entry></entry></row>
>> +     </tbody>
>> +      </tgroup>
>> +      </table>
>> +
>> +<para>For more details about RDS specification, refer to
>> +<xref linkend="en50067"> document, from CENELEC.</para>
>> +    </section>
>>  </section>
>>
>>    <!--
>
> Regards,
>
>        Hans
>
> --
> Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>



-- 
Eduardo Bezerra Valentin

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 2/9] v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX controls
  2009-06-14 10:46     ` [PATCHv7 2/9] v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX controls Hans Verkuil
@ 2009-06-14 10:50       ` Eduardo Valentin
  2009-06-14 16:23         ` Trent Piepho
  0 siblings, 1 reply; 33+ messages in thread
From: Eduardo Valentin @ 2009-06-14 10:50 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Eduardo Valentin, ext Mauro Carvalho Chehab,
	Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

Hi Hans,

On Sun, Jun 14, 2009 at 1:46 PM, Hans Verkuil<hverkuil@xs4all.nl> wrote:
> On Friday 12 June 2009 19:30:33 Eduardo Valentin wrote:
>> This patch adds a new class of extended controls. This class
>> is intended to support FM Radio Modulators properties such as:
>> rds, audio limiters, audio compression, pilot tone generation,
>> tuning power levels and preemphasis properties.
>>
>> Signed-off-by: Eduardo Valentin <eduardo.valentin@nokia.com>
>> ---
>>  linux/include/linux/videodev2.h |   34 ++++++++++++++++++++++++++++++++++
>>  1 files changed, 34 insertions(+), 0 deletions(-)
>>
>> diff --git a/linux/include/linux/videodev2.h b/linux/include/linux/videodev2.h
>> index b8cffc9..9733435 100644
>> --- a/linux/include/linux/videodev2.h
>> +++ b/linux/include/linux/videodev2.h
>> @@ -806,6 +806,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_FM_TX 0x009b0000     /* FM Modulator control class */
>>
>>  #define V4L2_CTRL_ID_MASK              (0x0fffffff)
>>  #define V4L2_CTRL_ID2CLASS(id)    ((id) & 0x0fff0000UL)
>> @@ -1144,6 +1145,39 @@ enum  v4l2_exposure_auto_type {
>>
>>  #define V4L2_CID_PRIVACY                     (V4L2_CID_CAMERA_CLASS_BASE+16)
>>
>> +/* FM Modulator class control IDs */
>> +#define V4L2_CID_FM_TX_CLASS_BASE            (V4L2_CTRL_CLASS_FM_TX | 0x900)
>> +#define V4L2_CID_FM_TX_CLASS                 (V4L2_CTRL_CLASS_FM_TX | 1)
>> +
>> +#define V4L2_CID_RDS_ENABLED                 (V4L2_CID_FM_TX_CLASS_BASE + 1)
>> +#define V4L2_CID_RDS_PI                              (V4L2_CID_FM_TX_CLASS_BASE + 2)
>> +#define V4L2_CID_RDS_PTY                     (V4L2_CID_FM_TX_CLASS_BASE + 3)
>> +#define V4L2_CID_RDS_PS_NAME                 (V4L2_CID_FM_TX_CLASS_BASE + 4)
>> +#define V4L2_CID_RDS_RADIO_TEXT                      (V4L2_CID_FM_TX_CLASS_BASE + 5)
>
> I think these RDS controls should be renamed to V4L2_CID_RDS_TX_. This makes
> it clear that these controls relate to the RDS transmitter instead of a
> receiver. I would not be surprised to see similar controls appear for an RDS
> receiver in the future.
>
>> +
>> +#define V4L2_CID_AUDIO_LIMITER_ENABLED               (V4L2_CID_FM_TX_CLASS_BASE + 6)
>> +#define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME  (V4L2_CID_FM_TX_CLASS_BASE + 7)
>> +#define V4L2_CID_AUDIO_LIMITER_DEVIATION     (V4L2_CID_FM_TX_CLASS_BASE + 8)
>> +
>> +#define V4L2_CID_AUDIO_COMPRESSION_ENABLED   (V4L2_CID_FM_TX_CLASS_BASE + 9)
>> +#define V4L2_CID_AUDIO_COMPRESSION_GAIN              (V4L2_CID_FM_TX_CLASS_BASE + 10)
>> +#define V4L2_CID_AUDIO_COMPRESSION_THRESHOLD (V4L2_CID_FM_TX_CLASS_BASE + 11)
>> +#define V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME       (V4L2_CID_FM_TX_CLASS_BASE + 12)
>> +#define V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME      (V4L2_CID_FM_TX_CLASS_BASE + 13)
>> +
>> +#define V4L2_CID_PILOT_TONE_ENABLED          (V4L2_CID_FM_TX_CLASS_BASE + 14)
>> +#define V4L2_CID_PILOT_TONE_DEVIATION                (V4L2_CID_FM_TX_CLASS_BASE + 15)
>> +#define V4L2_CID_PILOT_TONE_FREQUENCY                (V4L2_CID_FM_TX_CLASS_BASE + 16)
>> +
>> +#define V4L2_CID_PREEMPHASIS                 (V4L2_CID_FM_TX_CLASS_BASE + 17)
>> +enum v4l2_fm_tx_preemphasis {
>> +     V4L2_FM_TX_PREEMPHASIS_DISABLED         = 0,
>> +     V4L2_FM_TX_PREEMPHASIS_50_uS            = 1,
>> +     V4L2_FM_TX_PREEMPHASIS_75_uS            = 2,
>> +};
>
> I suggest renaming this to V4L2_CID_FM_TX_PREEMPHASIS. There is already a
> similar V4L2_CID_MPEG_EMPHASIS control and others might well appear in the
> future, so I think this name should be more specific to the FM_TX API.

Right. Agreed for both suggestions.

>
>> +#define V4L2_CID_TUNE_POWER_LEVEL            (V4L2_CID_FM_TX_CLASS_BASE + 18)
>> +#define V4L2_CID_TUNE_ANTENNA_CAPACITOR              (V4L2_CID_FM_TX_CLASS_BASE + 19)
>> +
>>  /*
>>   *   T U N I N G
>>   */
>
> Regards,
>
>        Hans
>
> --
> Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>



-- 
Eduardo Bezerra Valentin

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 6/9] FMTx: si4713: Add files to add radio interface for si4713
  2009-06-12 17:30           ` [PATCHv7 6/9] FMTx: si4713: Add files to add radio interface for si4713 Eduardo Valentin
  2009-06-12 17:30             ` [PATCHv7 7/9] FMTx: si4713: Add files to handle si4713 i2c device Eduardo Valentin
@ 2009-06-14 11:14             ` Hans Verkuil
  2009-06-14 11:22               ` Eduardo Valentin
  1 sibling, 1 reply; 33+ messages in thread
From: Hans Verkuil @ 2009-06-14 11:14 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: ext Mauro Carvalho Chehab, Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

On Friday 12 June 2009 19:30:37 Eduardo Valentin wrote:
> This patch adds files which creates the radio interface
> for si4713 FM transmitter (modulator) devices.
> 
> In order to do the real access to device registers, this
> driver uses the v4l2 subdev interface exported by si4713 i2c driver.
> 
> Signed-off-by: "Eduardo Valentin <eduardo.valentin@nokia.com>"
> ---
>  linux/drivers/media/radio/radio-si4713.c |  325 ++++++++++++++++++++++++++++++
>  linux/include/media/si4713.h             |   40 ++++
>  2 files changed, 365 insertions(+), 0 deletions(-)
>  create mode 100644 linux/drivers/media/radio/radio-si4713.c
>  create mode 100644 linux/include/media/si4713.h
> 
> diff --git a/linux/drivers/media/radio/radio-si4713.c b/linux/drivers/media/radio/radio-si4713.c
> new file mode 100644
> index 0000000..4c23120
> --- /dev/null
> +++ b/linux/drivers/media/radio/radio-si4713.c
> @@ -0,0 +1,325 @@
> +/*
> + * 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 <eduardo.valentin@nokia.com>
> + *
> + * 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 <media/si4713.h>
> +
> +/* Driver state struct */
> +struct radio_si4713_device {
> +	struct v4l2_device		v4l2_dev;
> +	struct video_device		*radio_dev;
> +};
> +
> +/* 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_fill_audout(struct v4l2_audioout *vao)
> +{
> +	/* TODO: check presence of audio output */
> +	memset(vao, 0, sizeof(*vao));

No need for memset, the v4l2 core has done that for you already.

> +	strlcpy(vao->name, "FM Modulator Audio Out", 32);
> +
> +	return 0;
> +}
> +
> +static int radio_si4713_enumaudout(struct file *file, void *priv,
> +						struct v4l2_audioout *vao)
> +{
> +	return radio_si4713_fill_audout(vao);
> +}
> +
> +static int radio_si4713_g_audout(struct file *file, void *priv,
> +					struct v4l2_audioout *vao)
> +{
> +	int rval = radio_si4713_fill_audout(vao);
> +
> +	vao->index = 0;
> +
> +	return rval;
> +}
> +
> +static int radio_si4713_s_audout(struct file *file, void *priv,
> +					struct v4l2_audioout *vao)
> +{
> +	if (vao->index != 0)
> +		return -EINVAL;
> +
> +	return radio_si4713_fill_audout(vao);

It is a write only ioctl, so you can just do this:

	return vao->index ? -EINVAL : 0;

> +}
> +
> +/* radio_si4713_querycap - query device capabilities */
> +static int radio_si4713_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 Modulator",
> +				sizeof(capability->card));
> +	capability->capabilities = V4L2_CAP_MODULATOR;
> +
> +	return 0;
> +}
> +
> +/* radio_si4713_queryctrl - enumerate control items */
> +static int radio_si4713_queryctrl(struct file *file, void *priv,
> +						struct v4l2_queryctrl *qc)
> +{
> +

Unnecessary empty line.

> +	/* Must be sorted from low to high control ID! */
> +	static const u32 user_ctrls[] = {
> +		V4L2_CID_USER_CLASS,
> +		V4L2_CID_AUDIO_MUTE,
> +		0
> +	};
> +
> +	/* Must be sorted from low to high control ID! */
> +	static const u32 fmtx_ctrls[] = {
> +		V4L2_CID_FM_TX_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_PREEMPHASIS,
> +		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_FM_TX_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_template - Produce a v4l2 call back.
> + * Can be used because we are just a wrapper for v4l2_sub_devs.
> + */
> +#define radio_si4713_template(type, callback, arg_type)			\
> +static int radio_si4713_##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_template(core, g_ext_ctrls, struct v4l2_ext_controls *)
> +radio_si4713_template(core, s_ext_ctrls, struct v4l2_ext_controls *)
> +radio_si4713_template(core, g_ctrl, struct v4l2_control *)
> +radio_si4713_template(core, s_ctrl, struct v4l2_control *)
> +radio_si4713_template(tuner, g_modulator, struct v4l2_modulator *)
> +radio_si4713_template(tuner, s_modulator, struct v4l2_modulator *)
> +radio_si4713_template(tuner, g_frequency, struct v4l2_frequency *)
> +radio_si4713_template(tuner, s_frequency, struct v4l2_frequency *)

I still don't like this macro, especially since there is really no need for it.

> +
> +static struct v4l2_ioctl_ops radio_si4713_ioctl_ops = {
> +	.vidioc_enumaudout	= radio_si4713_enumaudout,
> +	.vidioc_g_audout	= radio_si4713_g_audout,
> +	.vidioc_s_audout	= radio_si4713_s_audout,
> +	.vidioc_querycap	= radio_si4713_querycap,
> +	.vidioc_queryctrl	= radio_si4713_queryctrl,
> +	.vidioc_g_ext_ctrls	= radio_si4713_g_ext_ctrls,
> +	.vidioc_s_ext_ctrls	= radio_si4713_s_ext_ctrls,
> +	.vidioc_g_ctrl		= radio_si4713_g_ctrl,
> +	.vidioc_s_ctrl		= radio_si4713_s_ctrl,
> +	.vidioc_g_modulator	= radio_si4713_g_modulator,
> +	.vidioc_s_modulator	= radio_si4713_s_modulator,
> +	.vidioc_g_frequency	= radio_si4713_g_frequency,
> +	.vidioc_s_frequency	= radio_si4713_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->dev.platform_data;
> +	struct radio_si4713_device *rsdev;
> +	struct i2c_adapter *adapter;
> +	struct v4l2_subdev *sd;
> +	int rval = 0;
> +
> +	if (!pdata) {
> +		dev_err(&pdev->dev, "Cannot 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, "Cannot get i2c adapter %d\n",
> +							pdata->i2c_bus);
> +		rval = -ENODEV;
> +		goto unregister_v4l2_dev;
> +	}
> +
> +	sd = v4l2_i2c_new_subdev_board(&rsdev->v4l2_dev, adapter, "si4713_i2c",
> +					pdata->subdev_board_info, NULL);
> +	if (!sd) {
> +		dev_err(&pdev->dev, "Cannot 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 radio_si4713_device *rsdev = container_of(v4l2_dev,
> +						struct radio_si4713_device,
> +						v4l2_dev);
> +
> +	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 <eduardo.valentin@nokia.com>");
> +MODULE_DESCRIPTION("Platform driver for Si4713 FM Radio Transmitter");
> +MODULE_VERSION("0.0.1");
> diff --git a/linux/include/media/si4713.h b/linux/include/media/si4713.h
> new file mode 100644
> index 0000000..de43f83
> --- /dev/null
> +++ b/linux/include/media/si4713.h
> @@ -0,0 +1,40 @@
> +/*
> + * include/media/si4713.h
> + *
> + * Board related data definitions for Si4713 radio transmitter chip.
> + *
> + * Copyright (c) 2009 Nokia Corporation
> + * Contact: Eduardo Valentin <eduardo.valentin@nokia.com>
> + *
> + * This file is licensed under the terms of the GNU General Public License
> + * version 2. This program is licensed "as is" without any warranty of any
> + * kind, whether express or implied.
> + *
> + */
> +
> +#ifndef SI4713_H
> +#define SI4713_H
> +
> +#include <linux/i2c.h>
> +#include <media/v4l2-device.h>
> +
> +#define SI4713_NAME "radio-si4713"
> +
> +/* The SI4713 I2C sensor chip has a fixed slave address of 0xc6. */
> +#define SI4713_I2C_ADDR_BUSEN_HIGH	0x63
> +#define SI4713_I2C_ADDR_BUSEN_LOW	0x11

I think the comment should be: 'has a fixed slave address of either 0xc6 or
0x22'. Right?

> +
> +/*
> + * Platform dependent definition
> + */
> +struct si4713_platform_data {
> +	/* Set power state, zero is off, non-zero is on. */
> +	int (*set_power)(int power);
> +};
> +
> +struct radio_si4713_platform_data {
> +	int i2c_bus;
> +	struct i2c_board_info *subdev_board_info;
> +};
> +
> +#endif /* ifndef SI4713_H*/

No, this is not right. You need two headers here: one for the i2c driver and
one for the v4l2 driver. The radio_si4713_platform_data struct is specific to
the v4l2 driver and another future v4l2 driver that uses the si4713 i2c device
might have different platform data.

So media/si4713.h should contain only the bits that are relevant to the i2c
driver. For the v4l2 driver you should make a media/radio-si4713.h header
instead.

Regards,

	Hans

-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 6/9] FMTx: si4713: Add files to add radio interface for si4713
  2009-06-14 11:14             ` [PATCHv7 6/9] FMTx: si4713: Add files to add radio interface for si4713 Hans Verkuil
@ 2009-06-14 11:22               ` Eduardo Valentin
  0 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2009-06-14 11:22 UTC (permalink / raw)
  To: ext Hans Verkuil
  Cc: Valentin Eduardo (Nokia-D/Helsinki),
	ext Mauro Carvalho Chehab, Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

On Sun, Jun 14, 2009 at 01:14:06PM +0200, ext Hans Verkuil wrote:
> On Friday 12 June 2009 19:30:37 Eduardo Valentin wrote:
> > This patch adds files which creates the radio interface
> > for si4713 FM transmitter (modulator) devices.
> >
> > In order to do the real access to device registers, this
> > driver uses the v4l2 subdev interface exported by si4713 i2c driver.
> >
> > Signed-off-by: "Eduardo Valentin <eduardo.valentin@nokia.com>"
> > ---
> >  linux/drivers/media/radio/radio-si4713.c |  325 ++++++++++++++++++++++++++++++
> >  linux/include/media/si4713.h             |   40 ++++
> >  2 files changed, 365 insertions(+), 0 deletions(-)
> >  create mode 100644 linux/drivers/media/radio/radio-si4713.c
> >  create mode 100644 linux/include/media/si4713.h
> >
> > diff --git a/linux/drivers/media/radio/radio-si4713.c b/linux/drivers/media/radio/radio-si4713.c
> > new file mode 100644
> > index 0000000..4c23120
> > --- /dev/null
> > +++ b/linux/drivers/media/radio/radio-si4713.c
> > @@ -0,0 +1,325 @@
> > +/*
> > + * 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 <eduardo.valentin@nokia.com>
> > + *
> > + * 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 <media/si4713.h>
> > +
> > +/* Driver state struct */
> > +struct radio_si4713_device {
> > +     struct v4l2_device              v4l2_dev;
> > +     struct video_device             *radio_dev;
> > +};
> > +
> > +/* 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_fill_audout(struct v4l2_audioout *vao)
> > +{
> > +     /* TODO: check presence of audio output */
> > +     memset(vao, 0, sizeof(*vao));
> 
> No need for memset, the v4l2 core has done that for you already.

Right. 

> 
> > +     strlcpy(vao->name, "FM Modulator Audio Out", 32);
> > +
> > +     return 0;
> > +}
> > +
> > +static int radio_si4713_enumaudout(struct file *file, void *priv,
> > +                                             struct v4l2_audioout *vao)
> > +{
> > +     return radio_si4713_fill_audout(vao);
> > +}
> > +
> > +static int radio_si4713_g_audout(struct file *file, void *priv,
> > +                                     struct v4l2_audioout *vao)
> > +{
> > +     int rval = radio_si4713_fill_audout(vao);
> > +
> > +     vao->index = 0;
> > +
> > +     return rval;
> > +}
> > +
> > +static int radio_si4713_s_audout(struct file *file, void *priv,
> > +                                     struct v4l2_audioout *vao)
> > +{
> > +     if (vao->index != 0)
> > +             return -EINVAL;
> > +
> > +     return radio_si4713_fill_audout(vao);
> 
> It is a write only ioctl, so you can just do this:
> 
>         return vao->index ? -EINVAL : 0;

Ok.

> 
> > +}
> > +
> > +/* radio_si4713_querycap - query device capabilities */
> > +static int radio_si4713_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 Modulator",
> > +                             sizeof(capability->card));
> > +     capability->capabilities = V4L2_CAP_MODULATOR;
> > +
> > +     return 0;
> > +}
> > +
> > +/* radio_si4713_queryctrl - enumerate control items */
> > +static int radio_si4713_queryctrl(struct file *file, void *priv,
> > +                                             struct v4l2_queryctrl *qc)
> > +{
> > +
> 
> Unnecessary empty line.

Yes.

> 
> > +     /* Must be sorted from low to high control ID! */
> > +     static const u32 user_ctrls[] = {
> > +             V4L2_CID_USER_CLASS,
> > +             V4L2_CID_AUDIO_MUTE,
> > +             0
> > +     };
> > +
> > +     /* Must be sorted from low to high control ID! */
> > +     static const u32 fmtx_ctrls[] = {
> > +             V4L2_CID_FM_TX_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_PREEMPHASIS,
> > +             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_FM_TX_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_template - Produce a v4l2 call back.
> > + * Can be used because we are just a wrapper for v4l2_sub_devs.
> > + */
> > +#define radio_si4713_template(type, callback, arg_type)                      \
> > +static int radio_si4713_##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_template(core, g_ext_ctrls, struct v4l2_ext_controls *)
> > +radio_si4713_template(core, s_ext_ctrls, struct v4l2_ext_controls *)
> > +radio_si4713_template(core, g_ctrl, struct v4l2_control *)
> > +radio_si4713_template(core, s_ctrl, struct v4l2_control *)
> > +radio_si4713_template(tuner, g_modulator, struct v4l2_modulator *)
> > +radio_si4713_template(tuner, s_modulator, struct v4l2_modulator *)
> > +radio_si4713_template(tuner, g_frequency, struct v4l2_frequency *)
> > +radio_si4713_template(tuner, s_frequency, struct v4l2_frequency *)
> 
> I still don't like this macro, especially since there is really no need for it.

Ok. I'm going to remove it.

> 
> > +
> > +static struct v4l2_ioctl_ops radio_si4713_ioctl_ops = {
> > +     .vidioc_enumaudout      = radio_si4713_enumaudout,
> > +     .vidioc_g_audout        = radio_si4713_g_audout,
> > +     .vidioc_s_audout        = radio_si4713_s_audout,
> > +     .vidioc_querycap        = radio_si4713_querycap,
> > +     .vidioc_queryctrl       = radio_si4713_queryctrl,
> > +     .vidioc_g_ext_ctrls     = radio_si4713_g_ext_ctrls,
> > +     .vidioc_s_ext_ctrls     = radio_si4713_s_ext_ctrls,
> > +     .vidioc_g_ctrl          = radio_si4713_g_ctrl,
> > +     .vidioc_s_ctrl          = radio_si4713_s_ctrl,
> > +     .vidioc_g_modulator     = radio_si4713_g_modulator,
> > +     .vidioc_s_modulator     = radio_si4713_s_modulator,
> > +     .vidioc_g_frequency     = radio_si4713_g_frequency,
> > +     .vidioc_s_frequency     = radio_si4713_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->dev.platform_data;
> > +     struct radio_si4713_device *rsdev;
> > +     struct i2c_adapter *adapter;
> > +     struct v4l2_subdev *sd;
> > +     int rval = 0;
> > +
> > +     if (!pdata) {
> > +             dev_err(&pdev->dev, "Cannot 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, "Cannot get i2c adapter %d\n",
> > +                                                     pdata->i2c_bus);
> > +             rval = -ENODEV;
> > +             goto unregister_v4l2_dev;
> > +     }
> > +
> > +     sd = v4l2_i2c_new_subdev_board(&rsdev->v4l2_dev, adapter, "si4713_i2c",
> > +                                     pdata->subdev_board_info, NULL);
> > +     if (!sd) {
> > +             dev_err(&pdev->dev, "Cannot 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 radio_si4713_device *rsdev = container_of(v4l2_dev,
> > +                                             struct radio_si4713_device,
> > +                                             v4l2_dev);
> > +
> > +     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 <eduardo.valentin@nokia.com>");
> > +MODULE_DESCRIPTION("Platform driver for Si4713 FM Radio Transmitter");
> > +MODULE_VERSION("0.0.1");
> > diff --git a/linux/include/media/si4713.h b/linux/include/media/si4713.h
> > new file mode 100644
> > index 0000000..de43f83
> > --- /dev/null
> > +++ b/linux/include/media/si4713.h
> > @@ -0,0 +1,40 @@
> > +/*
> > + * include/media/si4713.h
> > + *
> > + * Board related data definitions for Si4713 radio transmitter chip.
> > + *
> > + * Copyright (c) 2009 Nokia Corporation
> > + * Contact: Eduardo Valentin <eduardo.valentin@nokia.com>
> > + *
> > + * This file is licensed under the terms of the GNU General Public License
> > + * version 2. This program is licensed "as is" without any warranty of any
> > + * kind, whether express or implied.
> > + *
> > + */
> > +
> > +#ifndef SI4713_H
> > +#define SI4713_H
> > +
> > +#include <linux/i2c.h>
> > +#include <media/v4l2-device.h>
> > +
> > +#define SI4713_NAME "radio-si4713"
> > +
> > +/* The SI4713 I2C sensor chip has a fixed slave address of 0xc6. */
> > +#define SI4713_I2C_ADDR_BUSEN_HIGH   0x63
> > +#define SI4713_I2C_ADDR_BUSEN_LOW    0x11
> 
> I think the comment should be: 'has a fixed slave address of either 0xc6 or
> 0x22'. Right?

yes

> 
> > +
> > +/*
> > + * Platform dependent definition
> > + */
> > +struct si4713_platform_data {
> > +     /* Set power state, zero is off, non-zero is on. */
> > +     int (*set_power)(int power);
> > +};
> > +
> > +struct radio_si4713_platform_data {
> > +     int i2c_bus;
> > +     struct i2c_board_info *subdev_board_info;
> > +};
> > +
> > +#endif /* ifndef SI4713_H*/
> 
> No, this is not right. You need two headers here: one for the i2c driver and
> one for the v4l2 driver. The radio_si4713_platform_data struct is specific to
> the v4l2 driver and another future v4l2 driver that uses the si4713 i2c device
> might have different platform data.
> 
> So media/si4713.h should contain only the bits that are relevant to the i2c
> driver. For the v4l2 driver you should make a media/radio-si4713.h header
> instead.

Right. I first thought in putting them in separated files. Will resend them separated.

> 
> Regards,
> 
>         Hans
> 
> --
> Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom

-- 
Eduardo Valentin

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 0/9] FM Transmitter (si4713) and another changes
  2009-06-12 17:30 [PATCHv7 0/9] FM Transmitter (si4713) and another changes Eduardo Valentin
  2009-06-12 17:30 ` [PATCHv7 1/9] v4l2-subdev.h: Add g_modulator callbacks to subdev api Eduardo Valentin
@ 2009-06-14 11:37 ` Hans Verkuil
  2009-06-16 10:47   ` Eduardo Valentin
  1 sibling, 1 reply; 33+ messages in thread
From: Hans Verkuil @ 2009-06-14 11:37 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: ext Mauro Carvalho Chehab, Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

On Friday 12 June 2009 19:30:31 Eduardo Valentin wrote:
> Hello all,
> 
>   I'm resending the FM transmitter driver and the proposed changes in
> v4l2 api files in order to cover the fmtx extended controls class.
> 
>   Difference from version #6 is that now I've added added lots of comments
> made by Hans. Here is a list of changes:
> - Reduce card type string
> - Remove unused ext controls
> - Remove s/g_audio and add s/g_audout and enumaudout
> - remove g/s_input
> - remove s/g_tuner and add s/g_modulator on subdev and platform driver
> - reduce function names
> - Update documentation
> - remove a few unused and empty lines
> - remove sysfs interface
> - rename dev_to_v4l2 to si4713_to_v4l2 (and vice-versa) macros
> - Remove disabled controls
> - Add string support
> - remove v4l2_i2c_driver_data
> - Join si4713.c with si4713-subdev.c
> - move platform data to include/media
> - update documentation
> 
> And now this series is based on two of Hans' trees:
> http://www.linuxtv.org/hg/~hverkuil/v4l-dvb-subdev2.
> http://www.linuxtv.org/hg/~hverkuil/v4l-dvb-str.
> 
> The first tree has refactoring of v4l2 i2c helper functions. The second
> one has string support for extended controls, which is used in this driver.
> 
>   So, now the series includes changes to add the new v4l2
> FMTX extended controls (and its documetation) and si4713 i2c and platform
> drivers (and its documentation as well). Besides that, there is also
> a patch to add g_modulator to v4l2-subdev and a patch to add support
> for fm tx class in v4l2-ctl util.
> 
>   In the TODO list there are two things:
> i. the signal level measurement property is missing.
> ii. Re-factor the driver so all that get/set internal functions are removed.
> 
>   I believe those TODO's can be done later on, if there is still time to get
> this driver merged into this window. But of course, this is my opinion,
> I will understand also if you ask to do them before merge it.

I think the refactoring should be done first. I don't believe it is that much
work and experience shows that it is better to do this right away while you are
still motivated :-)

The string control support should not go into 2.6.31. I would like to do that
only in the v4l-dvb tree (so it will appear in 2.6.32) since I want to give that
a bit more time to mature. I implemented it very quickly and I do not feel
comfortable queueing this for 2.6.31.

In addition it is still unclear if Mauro will merge my v4l-dvb-subdev2 tree for
2.6.31. I hope so, since otherwise it will hamper the development of this and
other embedded platforms.

I also need to add a new V4L2_CAP_MODULATOR (which needs a review as well).

And finally I realized that we need to add some v4l2_modulator capabilities
for the RDS encoder similar to the upcoming v4l2_tuner RDS capabilities as
is described in this RFC:

http://www.mail-archive.com/linux-media%40vger.kernel.org/msg02498.html

I haven't had time to implement this RFC and I know that is not going to make
2.6.31. It's now almost at the top of my TODO list, so it should go in soon
(pending unforeseen circumstances).

As a result of rereading this RFC I also started to wonder about whether
the si4713 supports the MMBS functionality. Do you know anything about that?

Taken all together I think that 2.6.31 is probably not feasible. If it was
another two weeks until the merge window, then it would. But the merge window
is already open, and there are just too many little TODOs for this driver. And
it's also a new API, so we need to be more careful than usual.

Regards,

	Hans

> 
>   With these series, the driver is now functional through the v4l2 extended
> controls changes. Here is an output of v4l2-ctl:
>  # v4l2-ctl -d /dev/radio0 -l --all
> Driver Info:
>         Driver name   : radio-si4713
>         Card type     : Silicon Labs Si4713 Modulator
>         Bus info      : 
>         Driver version: 0
>         Capabilities  : 0x00080000
>                 Modulator
> Audio output: 0 (FM Modulator Audio Out)
> Frequency: 1552000 (97000.000000 MHz)
> Video Standard = 0x00000000
> Modulator:
>         Name                 : FM Modulator
>         Capabilities         : 62.5 Hz stereo 
>         Frequency range      : 76.0 MHz - 108.0 MHz
>         Available subchannels: mono stereo 
> 
> User Controls
> 
>                            mute (bool) : default=1 value=0
> 
> FM Radio Modulator Controls
> 
>             rds_feature_enabled (bool) : default=1 value=1
>                  rds_program_id (int)  : min=0 max=65535 step=1 default=0 value=0
>                rds_program_type (int)  : min=0 max=31 step=1 default=0 value=0
>                     rds_ps_name (str)  : value='Si4713  ' len=8
> ' len=9          rds_radio_text (str)  : value='Si4713  
>   audio_limiter_feature_enabled (bool) : default=1 value=1
>      audio_limiter_release_time (int)  : min=250 max=102390 step=50 default=5010 value=5010 flags=slider
>         audio_limiter_deviation (int)  : min=0 max=90000 step=10 default=66250 value=66250 flags=slider
> audio_compression_feature_enabl (bool) : default=1 value=1
>          audio_compression_gain (int)  : min=0 max=20 step=1 default=15 value=15 flags=slider
>     audio_compression_threshold (int)  : min=-40 max=0 step=1 default=-40 value=-40 flags=slider
>   audio_compression_attack_time (int)  : min=0 max=5000 step=500 default=0 value=2000 flags=slider
>  audio_compression_release_time (int)  : min=100000 max=1000000 step=100000 default=1000000 value=1000000 flags=slider
>      pilot_tone_feature_enabled (bool) : default=1 value=1
>            pilot_tone_deviation (int)  : min=0 max=90000 step=10 default=6750 value=6750 flags=slider
>            pilot_tone_frequency (int)  : min=0 max=19000 step=1 default=19000 value=19000 flags=slider
>           pre_emphasis_settings (menu) : min=0 max=2 default=1 value=1
>                tune_power_level (int)  : min=0 max=120 step=1 default=88 value=120 flags=slider
>          tune_antenna_capacitor (int)  : min=0 max=191 step=1 default=0 value=68 flags=slider
> 
> 
>   Again, comments are welcome.
> 
> BR,
> 
> Eduardo Valentin (9):
>   v4l2-subdev.h: Add g_modulator callbacks to subdev api
>   v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX controls
>   v4l2: video device: Add FM_TX controls default configurations
>   v4l2-ctl: Add support for FM TX controls
>   v4l2-spec: Add documentation description for FM TX extended control
>     class
>   FMTx: si4713: Add files to add radio interface for si4713
>   FMTx: si4713: Add files to handle si4713 i2c device
>   FMTx: si4713: Add Kconfig and Makefile entries
>   FMTx: si4713: Add document file
> 
>  linux/Documentation/video4linux/si4713.txt |  137 ++
>  linux/drivers/media/radio/Kconfig          |   22 +
>  linux/drivers/media/radio/Makefile         |    2 +
>  linux/drivers/media/radio/radio-si4713.c   |  325 ++++
>  linux/drivers/media/radio/si4713-i2c.c     | 2813 ++++++++++++++++++++++++++++
>  linux/drivers/media/radio/si4713-i2c.h     |  226 +++
>  linux/drivers/media/video/v4l2-common.c    |   50 +
>  linux/include/linux/videodev2.h            |   34 +
>  linux/include/media/si4713.h               |   40 +
>  linux/include/media/v4l2-subdev.h          |    2 +
>  v4l2-apps/util/v4l2-ctl.cpp                |   36 +
>  v4l2-spec/Makefile                         |    1 +
>  v4l2-spec/biblio.sgml                      |   10 +
>  v4l2-spec/controls.sgml                    |  205 ++
>  14 files changed, 3903 insertions(+), 0 deletions(-)
>  create mode 100644 linux/Documentation/video4linux/si4713.txt
>  create mode 100644 linux/drivers/media/radio/radio-si4713.c
>  create mode 100644 linux/drivers/media/radio/si4713-i2c.c
>  create mode 100644 linux/drivers/media/radio/si4713-i2c.h
>  create mode 100644 linux/include/media/si4713.h
> 
> 
> 



-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 7/9] FMTx: si4713: Add files to handle si4713 i2c device
  2009-06-12 17:30             ` [PATCHv7 7/9] FMTx: si4713: Add files to handle si4713 i2c device Eduardo Valentin
  2009-06-12 17:30               ` [PATCHv7 8/9] FMTx: si4713: Add Kconfig and Makefile entries Eduardo Valentin
@ 2009-06-14 12:31               ` Hans Verkuil
  2009-06-16 11:06                 ` Eduardo Valentin
  1 sibling, 1 reply; 33+ messages in thread
From: Hans Verkuil @ 2009-06-14 12:31 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: ext Mauro Carvalho Chehab, Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

On Friday 12 June 2009 19:30:38 Eduardo Valentin wrote:
> This 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.
> 
> Signed-off-by: Eduardo Valentin <eduardo.valentin@nokia.com>
> ---
>  linux/drivers/media/radio/si4713-i2c.c | 2813 ++++++++++++++++++++++++++++++++
>  linux/drivers/media/radio/si4713-i2c.h |  226 +++
>  2 files changed, 3039 insertions(+), 0 deletions(-)
>  create mode 100644 linux/drivers/media/radio/si4713-i2c.c
>  create mode 100644 linux/drivers/media/radio/si4713-i2c.h
> 
> diff --git a/linux/drivers/media/radio/si4713-i2c.c b/linux/drivers/media/radio/si4713-i2c.c
> new file mode 100644
> index 0000000..f640d33
> --- /dev/null
> +++ b/linux/drivers/media/radio/si4713-i2c.c
> @@ -0,0 +1,2813 @@
> +/*
> + * drivers/media/radio/si4713-i2c.c
> + *
> + * Silicon Labs Si4713 FM Radio Transmitter I2C commands.
> + *
> + * Copyright (c) 2009 Nokia Corporation
> + * Contact: Eduardo Valentin <eduardo.valentin@nokia.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> + */
> +
> +#include <linux/mutex.h>
> +#include <linux/completion.h>
> +#include <linux/delay.h>
> +#include <linux/interrupt.h>
> +#include <linux/i2c.h>
> +#include <media/v4l2-device.h>
> +#include <media/v4l2-ioctl.h>
> +
> +#include "si4713-i2c.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_MUTE			0x01
> +#define DEFAULT_POWER_LEVEL		88
> +#define DEFAULT_FREQUENCY		8800
> +#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 si4713_to_v4l2(f)	((f * FREQDEV_UNIT) / FREQV4L2_MULTI)
> +#define v4l2_to_si4713(f)	((f * FREQV4L2_MULTI) / FREQDEV_UNIT)
> +
> +#define MAX_ARGS 7
> +
> +#define RDS_BLOCK			8
> +#define RDS_BLOCK_CLEAR			0x03
> +#define RDS_BLOCK_LOAD			0x04
> +#define RDS_RADIOTEXT_2A		0x20
> +#define RDS_RADIOTEXT_BLK_SIZE		4
> +#define RDS_RADIOTEXT_INDEX_MAX		0x0F
> +#define RDS_CARRIAGE_RETURN		0x0D
> +
> +#define rds_ps_nblocks(len)	((len / RDS_BLOCK) + (len % RDS_BLOCK ? 1 : 0))
> +#define enable_rds(p)		(p | (1 << 2))
> +#define disable_rds(p)		(p & ~(1 << 2))
> +#define get_rds_status(p)	((p >> 2) & 0x01)
> +
> +#define enable_stereo(p)	(p | (1 << 1))
> +#define disable_stereo(p)	(p & ~(1 << 1))
> +#define get_stereo_status(p)	((p >> 1) & 0x01)
> +
> +#define enable_limiter(p)	(p | (1 << 1))
> +#define disable_limiter(p)	(p & ~(1 << 1))
> +#define get_limiter_status(p)	((p >> 1) & 0x01)
> +
> +#define enable_pilot(p)		(p | (1 << 0))
> +#define disable_pilot(p)	(p & ~(1 << 0))
> +#define get_pilot_status(p)	((p >> 0) & 0x01)
> +
> +#define enable_acomp(p)		(p | (1 << 0))
> +#define disable_acomp(p)	(p & ~(1 << 0))
> +#define get_acomp_status(p)	((p >> 0) & 0x01)
> +#define ATTACK_TIME_UNIT	500
> +
> +#define POWER_OFF			0x00
> +#define POWER_ON			0x01
> +
> +#define msb(x)                  ((u8)((u16) x >> 8))
> +#define lsb(x)                  ((u8)((u16) x &  0x00FF))
> +#define compose_u16(msb, lsb)	(((u16)msb << 8) | lsb)
> +#define check_command_failed(status)	(!(status & SI4713_CTS) || \
> +					(status & SI4713_ERR))
> +/* mute definition */
> +#define set_mute(p)	((p & 1) | ((p & 1) << 1));
> +#define get_mute(p)	(p & 0x01)
> +#define set_pty(v, pty)	((v & 0xFC1F) | (pty << 5))
> +#define get_pty(v)	((v >> 5) & 0x1F)
> +
> +#ifdef DEBUG
> +#define DBG_BUFFER(device, message, buffer, size)			\
> +	{								\
> +		int i;							\
> +		char str[(size)*5];					\
> +		for (i = 0; i < size; i++)				\
> +			sprintf(str + i * 5, " 0x%02x", buffer[i]);	\
> +		dev_dbg(device, "%s:%s\n", message, str);		\
> +	}
> +#else
> +#define DBG_BUFFER(device, message, buffer, size)
> +#endif
> +
> +
> +/*
> + * Values for limiter release time
> + *	device	release
> + *	value	time (us)
> + */
> +static unsigned long const limiter_times[] = {
> +	2000,	250,
> +	1000,	500,
> +	510,	1000,
> +	255,	2000,
> +	170,	3000,
> +	127,	4020,
> +	102,	5010,
> +	85,	6020,
> +	73,	7010,
> +	64,	7990,
> +	57,	8970,
> +	51,	10030,
> +	25,	20470,
> +	17,	30110,
> +	13,	39380,
> +	10,	51190,
> +	8,	63690,
> +	7,	73140,
> +	6,	85330,
> +	5,	102390,
> +};
> +
> +/*
> + * Values for audio compression release time
> + *	device	release
> + *	value	time (us)
> + */
> +static unsigned long const acomp_rtimes[] = {
> +	0,	100000,
> +	1,	200000,
> +	2,	350000,
> +	3,	525000,
> +	4,	1000000,
> +};
> +
> +static int usecs_to_dev(unsigned long usecs, unsigned long const array[],
> +			int size)
> +{
> +	int i;
> +	int rval = -EINVAL;
> +
> +	for (i = 0; i < size / 2; i++)
> +		if (array[(i * 2) + 1] >= usecs) {
> +			rval = array[i * 2];
> +			break;
> +		}
> +
> +	return rval;
> +}
> +
> +static unsigned long dev_to_usecs(int value, unsigned long const array[],
> +			int size)
> +{
> +	int i;
> +	int rval = -EINVAL;
> +
> +	for (i = 0; i < size / 2; i++)
> +		if (array[i * 2] == value) {
> +			rval = array[(i * 2) + 1];
> +			break;
> +		}
> +
> +	return rval;
> +}
> +
> +/* si4713_handler: IRQ handler, just complete work */
> +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;
> +}
> +
> +/*
> + * si4713_send_command - sends a command to si4713 and waits its response
> + * @sdev: si4713_device structure for the device we are communicating
> + * @command: command id
> + * @args: command arguments we are sending (up to 7)
> + * @argn: actual size of @args
> + * @response: buffer to place the expected response from the device (up to 15)
> + * @respn: actual size of @response
> + * @usecs: amount of time to wait before reading the response (in usecs)
> + */
> +static int si4713_send_command(struct si4713_device *sdev, const u8 command,
> +				const u8 args[], const int argn,
> +				u8 response[], const int respn, const int usecs)
> +{
> +	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> +	u8 data1[MAX_ARGS + 1];
> +	int err;
> +
> +	if (!client->adapter)
> +		return -ENODEV;
> +
> +	/* First send the command and its arguments */
> +	data1[0] = command;
> +	memcpy(data1 + 1, args, argn);
> +	DBG_BUFFER(&client->dev, "Parameters", data1, argn + 1);
> +
> +	err = i2c_master_send(client, data1, argn + 1);
> +	if (err != argn + 1) {
> +		dev_err(&client->dev, "Error while sending command 0x%02x\n",
> +			command);
> +		return (err > 0) ? -EIO : err;
> +	}
> +
> +	/* Wait response from interrupt */
> +	if (!wait_for_completion_timeout(&sdev->work,
> +				usecs_to_jiffies(usecs) + 1))
> +		dev_dbg(&client->dev, "Device took too much time.\n");

Shouldn't this be a warning or error rather than a debug message?

> +
> +	/* Then get the response */
> +	err = i2c_master_recv(client, response, respn);
> +	if (err != respn) {
> +		dev_err(&client->dev,

For i2c drivers I recommend using v4l2_err and friends. These are used by all
other v4l2 i2c drivers as well and they format the prefix a bit better than
dev_err (these give a rather long prefix). It also ensures consistency over
the various v4l2 i2c drivers.

The v4l2_dbg macro also is a bit more efficient when debugging is turned off.

> +			"Error while reading response for command 0x%02x\n",
> +			command);
> +		return (err > 0) ? -EIO : err;
> +	}
> +
> +	DBG_BUFFER(&client->dev, "Response", response, respn);
> +	if (check_command_failed(response[0]))
> +		return -EBUSY;
> +
> +	return 0;
> +}
> +
> +/*
> + * si4713_read_property - reads a si4713 property
> + * @sdev: si4713_device structure for the device we are communicating
> + * @prop: property identification number
> + */
> +static int si4713_read_property(struct si4713_device *sdev, u16 prop)
> +{
> +	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> +	int err;
> +	u8 val[SI4713_GET_PROP_NRESP];
> +	/*
> +	 * REVISIT: From Programming Manual
> +	 * 	.First byte = 0
> +	 * 	.Second byte = property's MSB
> +	 * 	.Third byte = property's LSB
> +	 */
> +	const u8 args[SI4713_GET_PROP_NARGS] = {
> +		0x00,
> +		msb(prop),
> +		lsb(prop),
> +	};
> +
> +	err = si4713_send_command(sdev, SI4713_CMD_GET_PROPERTY,
> +				  args, ARRAY_SIZE(args), val,
> +				  ARRAY_SIZE(val), DEFAULT_TIMEOUT);
> +
> +	if (err < 0)
> +		return err;
> +
> +	dev_dbg(&client->dev, "Status from read prop: 0x%02x\n", val[0]);
> +
> +	return compose_u16(val[2], val[3]);
> +}
> +
> +/*
> + * si4713_write_property - modifies a si4713 property
> + * @sdev: si4713_device structure for the device we are communicating
> + * @prop: property identification number
> + * @val: new value for that property
> + */
> +static int si4713_write_property(struct si4713_device *sdev, u16 prop, u16 val)
> +{
> +	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> +	int rval;
> +	u8 resp[SI4713_SET_PROP_NRESP];
> +	/*
> +	 * REVISIT: From Programming Manual
> +	 * 	.First byte = 0
> +	 * 	.Second byte = property's MSB
> +	 * 	.Third byte = property's LSB
> +	 * 	.Fourth byte = value's MSB
> +	 * 	.Fifth byte = value's LSB
> +	 */
> +	const u8 args[SI4713_SET_PROP_NARGS] = {
> +		0x00,
> +		msb(prop),
> +		lsb(prop),
> +		msb(val),
> +		lsb(val),
> +	};
> +
> +	rval = si4713_send_command(sdev, SI4713_CMD_SET_PROPERTY,
> +					args, ARRAY_SIZE(args),
> +					resp, ARRAY_SIZE(resp),
> +					DEFAULT_TIMEOUT);
> +
> +	if (rval < 0)
> +		return rval;
> +
> +	dev_dbg(&client->dev, "Status from write prop: 0x%02x\n",
> +		resp[0]);
> +
> +	/*
> +	 * As there is no command response for SET_PROPERTY,
> +	 * wait Tcomp time to finish before proceed, in order
> +	 * to have property properly set.
> +	 */
> +	msleep(TIMEOUT_SET_PROPERTY);
> +
> +	return rval;
> +}
> +
> +/*
> + * si4713_powerup - Powers the device up
> + * @sdev: si4713_device structure for the device we are communicating
> + */
> +static int si4713_powerup(struct si4713_device *sdev)
> +{
> +	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> +	int err;
> +	u8 resp[SI4713_PWUP_NRESP];
> +	/*
> +	 * REVISIT: From Programming Manual
> +	 * 	.First byte = Enabled interrupts and boot function
> +	 * 	.Second byte = Input operation mode
> +	 */
> +	const u8 args[SI4713_PWUP_NARGS] = {
> +		SI4713_PWUP_CTSIEN | SI4713_PWUP_GPO2OEN | SI4713_PWUP_FUNC_TX,
> +		SI4713_PWUP_OPMOD_ANALOG,
> +	};
> +
> +	if (sdev->power_state)
> +		return 0;
> +
> +	sdev->platform_data->set_power(1);
> +	err = si4713_send_command(sdev, SI4713_CMD_POWER_UP,
> +					args, ARRAY_SIZE(args),
> +					resp, ARRAY_SIZE(resp),
> +					TIMEOUT_POWER_UP);
> +
> +	if (!err) {
> +		dev_dbg(&client->dev, "Powerup response: 0x%02x\n",
> +			resp[0]);
> +		dev_dbg(&client->dev, "Device in power up mode\n");
> +		sdev->power_state = POWER_ON;
> +
> +		err = si4713_write_property(sdev, SI4713_GPO_IEN,
> +						SI4713_STC_INT | SI4713_CTS);
> +	} else {
> +		sdev->platform_data->set_power(0);
> +	}
> +
> +	return err;
> +}
> +
> +/*
> + * si4713_powerdown - Powers the device down
> + * @sdev: si4713_device structure for the device we are communicating
> + */
> +static int si4713_powerdown(struct si4713_device *sdev)
> +{
> +	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> +	int err;
> +	u8 resp[SI4713_PWDN_NRESP];
> +
> +	if (!sdev->power_state)
> +		return 0;
> +
> +	err = si4713_send_command(sdev, SI4713_CMD_POWER_DOWN,
> +					NULL, 0,
> +					resp, ARRAY_SIZE(resp),
> +					DEFAULT_TIMEOUT);
> +
> +	if (!err) {
> +		dev_dbg(&client->dev, "Power down response: 0x%02x\n",
> +			resp[0]);
> +		dev_dbg(&client->dev, "Device in reset mode\n");
> +		sdev->platform_data->set_power(0);
> +		sdev->power_state = POWER_OFF;
> +	}
> +
> +	return err;
> +}
> +
> +/*
> + * si4713_checkrev - Checks if we are treating a device with the correct rev.
> + * @sdev: si4713_device structure for the device we are communicating
> + */
> +#define pr_revision(devicep, buffer)					\
> +	dev_info(devicep, "Detected %s (0x%02x) Firmware: %d.%d"	\
> +			  " Patch ID: %02x:%02x Component: %d.%d"	\
> +			  " Chip Rev.: %s\n",				\
> +			buffer[1] == SI4713_PRODUCT_NUMBER ? "Si4713" : "",\
> +			buffer[1],					\
> +			buffer[2] & 0xF, buffer[3] & 0xF,		\
> +			buffer[4], buffer[5],				\
> +			buffer[6] & 0xF, buffer[7] & 0xF,		\
> +			buffer[8] == 0x41 ? "revA" : "unknown")

Turn this into a static inline function.

> +static int si4713_checkrev(struct si4713_device *sdev)
> +{
> +	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> +	int rval;
> +	u8 resp[SI4713_GETREV_NRESP];
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	rval = si4713_send_command(sdev, SI4713_CMD_GET_REV,
> +					NULL, 0,
> +					resp, ARRAY_SIZE(resp),
> +					DEFAULT_TIMEOUT);
> +
> +	if (rval < 0)
> +		goto unlock;
> +
> +	if (resp[1] == SI4713_PRODUCT_NUMBER) {
> +		pr_revision(&client->dev, resp);
> +	} else {
> +		dev_err(&client->dev, "Invalid product number\n");
> +		rval = -EINVAL;
> +	}
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +/*
> + * si4713_wait_stc - Waits STC interrupt and clears status bits. Usefull
> + *		     for TX_TUNE_POWER, TX_TUNE_FREQ and TX_TUNE_MEAS
> + * @sdev: si4713_device structure for the device we are communicating
> + * @usecs: timeout to wait for STC interrupt signal
> + */
> +static int si4713_wait_stc(struct si4713_device *sdev, const int usecs)
> +{
> +	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> +	int err;
> +	u8 resp[SI4713_GET_STATUS_NRESP];
> +
> +	/* Wait response from STC interrupt */
> +	if (!wait_for_completion_timeout(&sdev->work,
> +			usecs_to_jiffies(TIMEOUT_TX_TUNE) + 1))
> +		dev_dbg(&client->dev, "Device took too much time.\n");
> +
> +	/* Clear status bits */
> +	err = si4713_send_command(sdev, SI4713_CMD_GET_INT_STATUS,
> +					NULL, 0,
> +					resp, ARRAY_SIZE(resp),
> +					DEFAULT_TIMEOUT);
> +
> +	if (err < 0)
> +		goto exit;
> +
> +	dev_dbg(&client->dev, "Status bits: 0x%02x\n", resp[0]);
> +
> +	if (!(resp[0] & SI4713_STC_INT))
> +		err = -EIO;
> +
> +exit:
> +	return err;
> +}
> +
> +/*
> + * si4713_tx_tune_freq - Sets the state of the RF carrier and sets the tuning
> + * 			frequency between 76 and 108 MHz in 10 kHz units and
> + * 			steps of 50 kHz.
> + * @sdev: si4713_device structure for the device we are communicating
> + * @frequency: desired frequency (76 - 108 MHz, unit 10 KHz, step 50 kHz)
> + */
> +static int si4713_tx_tune_freq(struct si4713_device *sdev, u16 frequency)
> +{
> +	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> +	int err;
> +	u8 val[SI4713_TXFREQ_NRESP];
> +	/*
> +	 * REVISIT: From Programming Manual

Revisit what? I'm not sure what you mean with REVISIT. If this just recaps
the manual, then I would suggest just removing the REVISIT: prefix.

> +	 * 	.First byte = 0
> +	 * 	.Second byte = frequency's MSB
> +	 * 	.Third byte = frequency's LSB
> +	 */
> +	const u8 args[SI4713_TXFREQ_NARGS] = {
> +		0x00,
> +		msb(frequency),
> +		lsb(frequency),
> +	};
> +
> +	err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_FREQ,
> +				  args, ARRAY_SIZE(args), val,
> +				  ARRAY_SIZE(val), DEFAULT_TIMEOUT);
> +
> +	if (err < 0)
> +		return err;
> +
> +	dev_dbg(&client->dev, "Status from tx tune freq: 0x%02x\n",
> +		val[0]);
> +
> +	err = si4713_wait_stc(sdev, TIMEOUT_TX_TUNE);
> +	if (err < 0)
> +		return err;
> +
> +	return compose_u16(args[1], args[2]);
> +}
> +
> +/*
> + * si4713_tx_tune_power - Sets the RF voltage level between 88 and 115 dBuV in
> + * 			1 dB units. A value of 0x00 indicates off. The command
> + * 			also sets the antenna tuning capacitance. A value of 0
> + * 			indicates autotuning, and a value of 1 - 191 indicates
> + * 			a manual override, which results in a tuning
> + * 			capacitance of 0.25 pF x @antcap.
> + * @sdev: si4713_device structure for the device we are communicating
> + * @power: tuning power (88 - 115 dBuV, unit/step 1 dB)
> + * @antcap: value of antenna tuning capacitor (0 - 191)
> + */
> +static int si4713_tx_tune_power(struct si4713_device *sdev, u8 power,
> +				u8 antcap)
> +{
> +	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> +	int err;
> +	u8 val[SI4713_TXPWR_NRESP];
> +	/*
> +	 * REVISIT: From Programming Manual
> +	 * 	.First byte = 0
> +	 * 	.Second byte = 0
> +	 * 	.Third byte = power
> +	 * 	.Fourth byte = antcap
> +	 */
> +	const u8 args[SI4713_TXPWR_NARGS] = {
> +		0x00,
> +		0x00,
> +		power,
> +		antcap,
> +	};
> +
> +	if (((power > 0) && (power < SI4713_MIN_POWER)) ||
> +		power > SI4713_MAX_POWER || antcap > SI4713_MAX_ANTCAP)
> +		return -EDOM;
> +
> +	err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_POWER,
> +				  args, ARRAY_SIZE(args), val,
> +				  ARRAY_SIZE(val), DEFAULT_TIMEOUT);
> +
> +	if (err < 0)
> +		return err;
> +
> +	dev_dbg(&client->dev, "Status from tx tune power: 0x%02x\n",
> +		val[0]);
> +
> +	return si4713_wait_stc(sdev, TIMEOUT_TX_TUNE_POWER);
> +}
> +
> +/*
> + * si4713_tx_tune_measure - Enters receive mode and measures the received noise
> + * 			level in units of dBuV on the selected frequency.
> + * 			The Frequency must be between 76 and 108 MHz in 10 kHz
> + * 			units and steps of 50 kHz. The command also sets the
> + * 			antenna	tuning capacitance. A value of 0 means
> + * 			autotuning, and a value of 1 to 191 indicates manual
> + * 			override.
> + * @sdev: si4713_device structure for the device we are communicating
> + * @frequency: desired frequency (76 - 108 MHz, unit 10 KHz, step 50 kHz)
> + * @antcap: value of antenna tuning capacitor (0 - 191)
> + */
> +static int si4713_tx_tune_measure(struct si4713_device *sdev, u16 frequency,
> +					u8 antcap)
> +{
> +	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> +	int err;
> +	u8 val[SI4713_TXMEA_NRESP];
> +	/*
> +	 * REVISIT: From Programming Manual
> +	 * 	.First byte = 0
> +	 * 	.Second byte = frequency's MSB
> +	 * 	.Third byte = frequency's LSB
> +	 * 	.Fourth byte = antcap
> +	 */
> +	const u8 args[SI4713_TXMEA_NARGS] = {
> +		0x00,
> +		msb(frequency),
> +		lsb(frequency),
> +		antcap,
> +	};
> +
> +	sdev->tune_rssi = DEFAULT_TUNE_RSSI;
> +
> +	if (antcap > SI4713_MAX_ANTCAP)
> +		return -EDOM;
> +
> +	err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_MEASURE,
> +				  args, ARRAY_SIZE(args), val,
> +				  ARRAY_SIZE(val), DEFAULT_TIMEOUT);
> +
> +	if (err < 0)
> +		return err;
> +
> +	dev_dbg(&client->dev, "Status from tx tune measure: 0x%02x\n",
> +		val[0]);
> +
> +	return si4713_wait_stc(sdev, TIMEOUT_TX_TUNE);
> +}
> +
> +/*
> + * si4713_tx_tune_status- Returns the status of the tx_tune_freq, tx_tune_mea or
> + * 			tx_tune_power commands. This command return the current
> + * 			frequency, output voltage in dBuV, the antenna tunning
> + * 			capacitance value and the received noise level. The
> + * 			command also clears the stcint interrupt bit when the
> + * 			first bit of its arguments is high.
> + * @sdev: si4713_device structure for the device we are communicating
> + * @intack: 0x01 to clear the seek/tune complete interrupt status indicator.
> + * @frequency: returned frequency
> + * @power: returned power
> + * @antcap: returned antenna capacitance
> + * @noise: returned noise level
> + */
> +static int si4713_tx_tune_status(struct si4713_device *sdev, u8 intack,
> +					u16 *frequency,	u8 *power,
> +					u8 *antcap, u8 *noise)
> +{
> +	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> +	int err;
> +	u8 val[SI4713_TXSTATUS_NRESP];
> +	/*
> +	 * REVISIT: From Programming Manual
> +	 * 	.First byte = intack bit
> +	 */
> +	const u8 args[SI4713_TXSTATUS_NARGS] = {
> +		intack & SI4713_INTACK_MASK,
> +	};
> +
> +	err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_STATUS,
> +				  args, ARRAY_SIZE(args), val,
> +				  ARRAY_SIZE(val), DEFAULT_TIMEOUT);
> +
> +	if (!err) {
> +		dev_dbg(&client->dev,
> +			"Status from tx tune status: 0x%02x\n", val[0]);
> +		*frequency = compose_u16(val[2], val[3]);
> +		sdev->frequency = *frequency;
> +		*power = val[5];
> +		*antcap = val[6];
> +		*noise = val[7];
> +		dev_dbg(&client->dev, "Tune status: %d x 10 kHz "
> +				"(power %d, antcap %d, rnl %d)\n",
> +				*frequency, *power, *antcap, *noise);
> +	}
> +
> +	return err;
> +}
> +
> +/*
> + * si4713_tx_rds_buff - Loads the RDS group buffer FIFO or circular buffer.
> + * @sdev: si4713_device structure for the device we are communicating
> + * @mode: the buffer operation mode.
> + * @rdsb: RDS Block B
> + * @rdsc: RDS Block C
> + * @rdsd: RDS Block D
> + * @intstatus: returns current interrupt status
> + * @cbavail: returns the number of available circular buffer blocks.
> + * @cbused: returns the number of used circular buffer blocks.
> + * @fifoavail: returns the number of available fifo buffer blocks.
> + * @fifoused: returns the number of used fifo buffer blocks.
> + */
> +static int si4713_tx_rds_buff(struct si4713_device *sdev, u8 mode, u16 rdsb,
> +				u16 rdsc, u16 rdsd, u8 *intstatus, u8 *cbavail,
> +				u8 *cbused, u8 *fifoavail, u8 *fifoused)
> +{
> +	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> +	int err;
> +	u8 val[SI4713_RDSBUFF_NRESP];
> +
> +	const u8 args[SI4713_RDSBUFF_NARGS] = {
> +		mode & SI4713_RDSBUFF_MODE_MASK,
> +		msb(rdsb),
> +		lsb(rdsb),
> +		msb(rdsc),
> +		lsb(rdsc),
> +		msb(rdsd),
> +		lsb(rdsd),
> +	};
> +
> +	err = si4713_send_command(sdev, SI4713_CMD_TX_RDS_BUFF,
> +				  args, ARRAY_SIZE(args), val,
> +				  ARRAY_SIZE(val), DEFAULT_TIMEOUT);
> +
> +	if (!err) {
> +		dev_dbg(&client->dev,
> +			"Status from tx rds buff: 0x%02x\n", val[0]);
> +		*intstatus = val[1];
> +		*cbavail = val[2];
> +		*cbused = val[3];
> +		*fifoavail = val[4];
> +		*fifoused = val[5];
> +		dev_dbg(&client->dev, "rds buffer status: interrupts"
> +				" 0x%02x cb avail: %d cb used %d fifo avail"
> +				" %d fifo used %d\n", *intstatus, *cbavail,
> +				*cbused, *fifoavail, *fifoused);
> +	}
> +
> +	return err;
> +}
> +
> +/*
> + * si4713_tx_rds_ps - Loads the program service buffer.
> + * @sdev: si4713_device structure for the device we are communicating
> + * @psid: program service id to be loaded.
> + * @pschar: assumed 4 size char array to be loaded into the program service
> + */
> +static int si4713_tx_rds_ps(struct si4713_device *sdev, u8 psid,
> +				unsigned char *pschar)
> +{
> +	struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> +	int err;
> +	u8 val[SI4713_RDSPS_NRESP];
> +
> +	const u8 args[SI4713_RDSPS_NARGS] = {
> +		psid & SI4713_RDSPS_PSID_MASK,
> +		pschar[0],
> +		pschar[1],
> +		pschar[2],
> +		pschar[3],
> +	};
> +
> +	err = si4713_send_command(sdev, SI4713_CMD_TX_RDS_PS,
> +				  args, ARRAY_SIZE(args), val,
> +				  ARRAY_SIZE(val), DEFAULT_TIMEOUT);
> +
> +	if (err < 0)
> +		return err;
> +
> +	dev_dbg(&client->dev, "Status from tx rds ps: 0x%02x\n",
> +		val[0]);
> +
> +	return err;
> +}
> +
> +/* TODO: Remove getters and setters functions and simplify driver code */
> +
> +/* getters */
> +/* tx_tune_status */
> +static int si4713_get_power_level(struct si4713_device *sdev)
> +{
> +	int rval;
> +	u16 f = 0;
> +	u8 p, a, n;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_tx_tune_status(sdev, 0x00, &f, &p, &a, &n);
> +
> +		if (rval < 0)
> +			goto unlock;
> +
> +		sdev->power_level = p;
> +	}
> +
> +	rval = sdev->power_level;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_get_antenna_capacitor(struct si4713_device *sdev)
> +{
> +	int rval = 0;
> +	u16 f = 0;
> +	u8 p, a, n;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_tx_tune_status(sdev, 0x00, &f, &p, &a, &n);
> +
> +		if (rval < 0)
> +			goto unlock;
> +
> +		sdev->antenna_capacitor = a;
> +	}
> +
> +	rval = sdev->antenna_capacitor;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_get_tune_measure(struct si4713_device *sdev)
> +{
> +	int rval;
> +	u16 f = 0;
> +	u8 p, a, n;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_tx_tune_status(sdev, 0x00, &f, &p, &a, &n);
> +
> +		if (rval < 0)
> +			goto unlock;
> +
> +		sdev->tune_rssi = n;
> +	}
> +
> +	rval = sdev->tune_rssi;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_get_frequency(struct si4713_device *sdev)
> +{
> +	int rval;
> +	u16 f = 0;
> +	u8 p, a, n;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_tx_tune_status(sdev, 0x00, &f, &p, &a, &n);
> +
> +		if (rval < 0)
> +			goto unlock;
> +
> +		sdev->frequency = f;
> +	}
> +
> +	rval = sdev->frequency;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +/* read_property */
> +static int si4713_get_mute(struct si4713_device *sdev)
> +{
> +	int rval;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_LINE_INPUT_MUTE);
> +
> +		if (rval < 0)
> +			goto unlock;
> +
> +		sdev->mute = rval;
> +	}
> +
> +	rval = get_mute(sdev->mute);
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_get_rds_pi(struct si4713_device *sdev)
> +{
> +	int rval;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_RDS_PI);
> +
> +		if (rval < 0)
> +			goto unlock;
> +
> +		sdev->rds_info.pi = rval;
> +	}
> +
> +	rval = sdev->rds_info.pi;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_get_rds_pty(struct si4713_device *sdev)
> +{
> +	int rval;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_RDS_PS_MISC);
> +
> +		if (rval < 0)
> +			goto unlock;
> +
> +		sdev->rds_info.pty = get_pty(rval);
> +	}
> +
> +	rval = sdev->rds_info.pty;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +
> +static int si4713_get_rds_enabled(struct si4713_device *sdev)
> +{
> +	int rval;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE);
> +		if (rval < 0)
> +			goto unlock;
> +
> +		sdev->rds_info.enabled = get_rds_status(rval);
> +	}
> +
> +	rval = sdev->rds_info.enabled;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_get_preemphasis(struct si4713_device *sdev)
> +{
> +	int rval;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_PREEMPHASIS);
> +
> +		if (rval < 0)
> +			goto unlock;
> +
> +		switch (rval) {
> +		case FMPE_USA:
> +			sdev->preemphasis = V4L2_FM_TX_PREEMPHASIS_75_uS;
> +			break;
> +		case FMPE_EU:
> +			sdev->preemphasis = V4L2_FM_TX_PREEMPHASIS_50_uS;
> +			break;
> +		case FMPE_DISABLED:
> +			sdev->preemphasis = V4L2_FM_TX_PREEMPHASIS_DISABLED;
> +			break;
> +		default:
> +			rval = -EINVAL;
> +			goto unlock;
> +		}
> +	}
> +
> +	rval = sdev->preemphasis;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_get_limiter_enabled(struct si4713_device *sdev)
> +{
> +	int rval;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_ACOMP_ENABLE);
> +		if (rval < 0)
> +			goto unlock;
> +
> +		sdev->limiter_info.enabled = get_limiter_status(rval);
> +	}
> +
> +	rval = sdev->limiter_info.enabled;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static long si4713_get_limiter_deviation(struct si4713_device *sdev)
> +{
> +	int rval;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_AUDIO_DEVIATION);
> +
> +		if (rval < 0)
> +			goto unlock;
> +
> +		/* Device returns in 10Hz units */
> +		sdev->limiter_info.deviation = rval * 10;
> +	}
> +
> +	rval = sdev->limiter_info.deviation;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static long si4713_get_limiter_release_time(struct si4713_device *sdev)
> +{
> +	int rval;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev,
> +				SI4713_TX_LIMITER_RELEASE_TIME);
> +
> +		if (rval < 0)
> +			goto unlock;
> +
> +		sdev->limiter_info.release_time = dev_to_usecs(rval,
> +						limiter_times,
> +						ARRAY_SIZE(limiter_times));
> +	}
> +
> +	rval = sdev->limiter_info.release_time;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_get_stereo_enabled(struct si4713_device *sdev)
> +{
> +	int rval;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE);
> +		if (rval < 0)
> +			goto unlock;
> +
> +		sdev->stereo = get_stereo_status(rval);
> +	}
> +
> +	rval = sdev->stereo;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_get_pilot_enabled(struct si4713_device *sdev)
> +{
> +	int rval;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE);
> +		if (rval < 0)
> +			goto unlock;
> +
> +		sdev->pilot_info.enabled = get_pilot_status(rval);
> +	}
> +
> +	rval = sdev->pilot_info.enabled;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static long si4713_get_pilot_deviation(struct si4713_device *sdev)
> +{
> +	int rval;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_PILOT_DEVIATION);
> +
> +		if (rval < 0)
> +			goto unlock;
> +
> +		/* Device returns in 10Hz units */
> +		sdev->pilot_info.deviation = rval * 10;
> +	}
> +
> +	rval = sdev->pilot_info.deviation;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_get_pilot_frequency(struct si4713_device *sdev)
> +{
> +	int rval;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_PILOT_FREQUENCY);
> +
> +		if (rval < 0)
> +			goto unlock;
> +
> +		sdev->pilot_info.frequency = rval;
> +	}
> +
> +	rval = sdev->pilot_info.frequency;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_get_acomp_enabled(struct si4713_device *sdev)
> +{
> +	int rval;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_ACOMP_ENABLE);
> +		if (rval < 0)
> +			goto unlock;
> +
> +		sdev->acomp_info.enabled = get_acomp_status(rval);
> +	}
> +
> +	rval = sdev->acomp_info.enabled;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_get_acomp_gain(struct si4713_device *sdev)
> +{
> +	int rval;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_ACOMP_GAIN);
> +
> +		if (rval < 0)
> +			goto unlock;
> +
> +		sdev->acomp_info.gain = rval;
> +	}
> +
> +	rval = sdev->acomp_info.gain;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_get_acomp_threshold(struct si4713_device *sdev, s8 *threshold)
> +{
> +	int rval;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_ACOMP_THRESHOLD);
> +
> +		if (rval < 0)
> +			goto unlock;
> +
> +		sdev->acomp_info.threshold = rval;
> +	}
> +
> +	*threshold = sdev->acomp_info.threshold;
> +	rval = 0;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static long si4713_get_acomp_release_time(struct si4713_device *sdev)
> +{
> +	int rval;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev,
> +				SI4713_TX_ACOMP_RELEASE_TIME);
> +
> +		if (rval < 0)
> +			goto unlock;
> +
> +		sdev->acomp_info.release_time = dev_to_usecs(rval,
> +						acomp_rtimes,
> +						ARRAY_SIZE(acomp_rtimes));
> +	}
> +
> +	rval = sdev->acomp_info.release_time;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +
> +static int si4713_get_acomp_attack_time(struct si4713_device *sdev)
> +{
> +	int rval;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev,
> +				SI4713_TX_ACOMP_RELEASE_TIME);
> +
> +		if (rval < 0)
> +			goto unlock;
> +
> +		sdev->acomp_info.attack_time = rval * ATTACK_TIME_UNIT;
> +	}
> +
> +	rval = sdev->acomp_info.attack_time;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +/* not read property */
> +static int si4713_get_rds_ps_name(struct si4713_device *sdev, char *ps_name)
> +{
> +	mutex_lock(&sdev->mutex);
> +	strncpy(ps_name, sdev->rds_info.ps_name, MAX_RDS_PS_NAME);
> +	mutex_unlock(&sdev->mutex);
> +
> +	return 0;
> +}
> +
> +static int si4713_get_rds_radio_text(struct si4713_device *sdev,
> +							char *radio_text)
> +{
> +	mutex_lock(&sdev->mutex);
> +	strncpy(radio_text, sdev->rds_info.radio_text, MAX_RDS_RADIO_TEXT);
> +	mutex_unlock(&sdev->mutex);
> +
> +	return 0;
> +}
> +
> +/* setters */
> +static int si4713_set_power_level(struct si4713_device *sdev, u8 power_level)
> +{
> +	int rval;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_tx_tune_power(sdev, power_level,
> +						sdev->antenna_capacitor);
> +
> +		if (rval < 0)
> +			goto unlock;
> +	}
> +
> +	sdev->power_level = power_level;
> +	rval = 0;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_set_antenna_capacitor(struct si4713_device *sdev, u8 value)
> +{
> +	int rval = 0;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state)
> +		rval = si4713_tx_tune_power(sdev, sdev->power_level, value);
> +
> +	if (!rval)
> +		sdev->antenna_capacitor = value;
> +
> +	mutex_unlock(&sdev->mutex);
> +
> +	return rval;
> +}
> +
> +static int si4713_set_power_state(struct si4713_device *sdev, u8 value)
> +{
> +	int rval;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (value)
> +		rval = si4713_powerup(sdev);
> +	else
> +		rval = si4713_powerdown(sdev);
> +
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_set_frequency(struct si4713_device *sdev, u16 frequency)
> +{
> +	int rval = 0;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_tx_tune_freq(sdev, frequency);
> +		if (rval < 0)
> +			goto unlock;
> +		frequency = rval;
> +	}
> +	sdev->frequency = frequency;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_set_mute(struct si4713_device *sdev, u16 mute)
> +{
> +	int rval = 0;
> +
> +	mute = set_mute(mute);
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state)
> +		rval = si4713_write_property(sdev,
> +				SI4713_TX_LINE_INPUT_MUTE, mute);
> +
> +	if (rval >= 0)
> +		sdev->mute = get_mute(mute);
> +
> +	mutex_unlock(&sdev->mutex);
> +
> +	return rval;
> +}
> +
> +static int si4713_set_rds_pi(struct si4713_device *sdev, u16 pi)
> +{
> +	int rval = 0;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state)
> +		rval = si4713_write_property(sdev, SI4713_TX_RDS_PI, pi);
> +
> +	if (rval >= 0)
> +		sdev->rds_info.pi = pi;
> +
> +	mutex_unlock(&sdev->mutex);
> +
> +	return rval;
> +}
> +
> +static int si4713_set_rds_pty(struct si4713_device *sdev, u8 pty)
> +{
> +	int rval = 0;
> +	u16 p;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_RDS_PS_MISC);
> +		if (rval < 0)
> +			goto unlock;
> +
> +		p = set_pty(rval, pty);
> +
> +		rval = si4713_write_property(sdev, SI4713_TX_RDS_PS_MISC, p);
> +		if (rval < 0)
> +			goto unlock;
> +	}
> +
> +	sdev->rds_info.pty = pty;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_set_rds_ps_name(struct si4713_device *sdev, char *ps_name)
> +{
> +	int rval = 0, i;
> +	u8 len = 0;
> +	u8 *tmp;
> +
> +	if (!strlen(ps_name))
> +		return -EINVAL;
> +
> +	tmp = kzalloc(MAX_RDS_PS_NAME + 1, GFP_KERNEL);
> +	if (!tmp)
> +		return -ENOMEM;
> +
> +	strncpy(tmp, ps_name, MAX_RDS_PS_NAME);
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		/* Write the new ps name and clear the padding */
> +		for (i = 0; i < MAX_RDS_PS_NAME; i += (RDS_BLOCK / 2)) {
> +			rval = si4713_tx_rds_ps(sdev, (i / (RDS_BLOCK / 2)),
> +						tmp + i);
> +			if (rval < 0)
> +				goto unlock;
> +		}
> +
> +		/* Setup the size to be sent */
> +		len = strlen(tmp) - 1;
> +
> +		rval = si4713_write_property(sdev,
> +				SI4713_TX_RDS_PS_MESSAGE_COUNT,
> +				rds_ps_nblocks(len));
> +		if (rval < 0)
> +			goto unlock;
> +
> +		rval = si4713_write_property(sdev,
> +				SI4713_TX_RDS_PS_REPEAT_COUNT,
> +				DEFAULT_RDS_PS_REPEAT_COUNT * 2);
> +		if (rval < 0)
> +			goto unlock;
> +	}
> +
> +	strncpy(sdev->rds_info.ps_name, tmp, MAX_RDS_PS_NAME);
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	kfree(tmp);
> +	return rval;
> +}
> +
> +static int si4713_set_rds_radio_text(struct si4713_device *sdev,
> +							char *radio_text)
> +{
> +	int rval = 0, i;
> +	u16 t_index = 0;
> +	u8 s, a, u, fa, fu, b_index = 0, cr_inserted = 0;
> +	u8 *tmp;
> +
> +	if (!strlen(radio_text))
> +		return -EINVAL;
> +
> +	tmp = kzalloc(MAX_RDS_RADIO_TEXT + 1, GFP_KERNEL);
> +	if (!tmp)
> +		return -ENOMEM;
> +
> +	strncpy(tmp, radio_text, MAX_RDS_RADIO_TEXT);
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_tx_rds_buff(sdev, RDS_BLOCK_CLEAR, 0, 0, 0,
> +						&s, &a, &u, &fa, &fu);
> +		if (rval < 0)
> +			goto unlock;
> +		do {
> +			/* RDS spec says that if the last block isn't used,
> +			 * then apply a carriage return
> +			 */
> +			if (t_index < (RDS_RADIOTEXT_INDEX_MAX * \
> +				RDS_RADIOTEXT_BLK_SIZE)) {
> +				for (i = 0; i < RDS_RADIOTEXT_BLK_SIZE; i++) {
> +					if (!tmp[t_index + i] ||
> +						tmp[t_index + i] == \
> +						RDS_CARRIAGE_RETURN) {
> +						tmp[t_index + i] =
> +							RDS_CARRIAGE_RETURN;
> +						cr_inserted = 1;
> +						break;
> +					}
> +				}
> +			}
> +
> +			rval = si4713_tx_rds_buff(sdev, RDS_BLOCK_LOAD,
> +					compose_u16(RDS_RADIOTEXT_2A,
> +						b_index++),
> +					compose_u16(tmp[t_index],
> +						tmp[t_index + 1]),
> +					compose_u16(tmp[t_index + 2],
> +						tmp[t_index + 3]),
> +					&s, &a, &u, &fa, &fu);
> +			if (rval < 0)
> +				goto unlock;
> +
> +			t_index += RDS_RADIOTEXT_BLK_SIZE;
> +
> +			if (cr_inserted)
> +				break;
> +		} while (u < a);
> +	}
> +
> +	strncpy(sdev->rds_info.radio_text, tmp, MAX_RDS_RADIO_TEXT);
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	kfree(tmp);
> +	return rval;
> +}
> +
> +static int si4713_set_rds_enabled(struct si4713_device *sdev, u8 enabled)
> +{
> +	int rval = 0;
> +	u16 p;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE);
> +		if (rval < 0)
> +			goto unlock;
> +
> +		p = rval;
> +		if (enabled)
> +			p = enable_rds(p);
> +		else
> +			p = disable_rds(p);
> +
> +		rval = si4713_write_property(sdev, SI4713_TX_COMPONENT_ENABLE,
> +				p);
> +		if (rval < 0)
> +			goto unlock;
> +
> +		if (enabled) {
> +			rval = si4713_write_property(sdev,
> +				SI4713_TX_RDS_DEVIATION,
> +				DEFAULT_RDS_DEVIATION);
> +			if (rval < 0)
> +				goto unlock;
> +		}
> +	}
> +
> +	sdev->rds_info.enabled = enabled & 0x01;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_set_preemphasis(struct si4713_device *sdev, u8 preemphasis)
> +{
> +	int rval = 0;
> +	u8 val;
> +
> +	switch (preemphasis) {
> +	case V4L2_FM_TX_PREEMPHASIS_75_uS:
> +		val = FMPE_USA;
> +		break;
> +	case V4L2_FM_TX_PREEMPHASIS_50_uS:
> +		val = FMPE_EU;
> +		break;
> +	case V4L2_FM_TX_PREEMPHASIS_DISABLED:
> +		val = FMPE_DISABLED;
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state)
> +		rval = si4713_write_property(sdev, SI4713_TX_PREEMPHASIS, val);
> +
> +	if (rval >= 0)
> +		sdev->preemphasis = preemphasis;
> +
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_set_limiter_enabled(struct si4713_device *sdev, u8 enabled)
> +{
> +	int rval = 0;
> +	u16 p;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_ACOMP_ENABLE);
> +		if (rval < 0)
> +			goto unlock;
> +
> +		p = rval;
> +		if (enabled)
> +			p = enable_limiter(p);
> +		else
> +			p = disable_limiter(p);
> +
> +		rval = si4713_write_property(sdev, SI4713_TX_ACOMP_ENABLE,
> +				p);
> +
> +		if (rval < 0)
> +			goto unlock;
> +	}
> +
> +	sdev->limiter_info.enabled = enabled & 0x01;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_set_limiter_deviation(struct si4713_device *sdev,
> +					unsigned long deviation)
> +{
> +	int rval = 0;
> +
> +	/* Device receives in 10Hz units */
> +	deviation /= 10;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state)
> +		rval = si4713_write_property(sdev, SI4713_TX_AUDIO_DEVIATION,
> +						deviation);
> +
> +	/* Device returns in 10Hz units */
> +	if (rval >= 0)
> +		sdev->limiter_info.deviation = deviation * 10;
> +
> +	mutex_unlock(&sdev->mutex);
> +
> +	return rval;
> +}
> +
> +static int si4713_set_limiter_release_time(struct si4713_device *sdev,
> +					unsigned long rtime)
> +{
> +	int rval;
> +
> +	rval = usecs_to_dev(rtime, limiter_times, ARRAY_SIZE(limiter_times));
> +	if (rval < 0)
> +		goto exit;
> +
> +	rtime = rval;
> +	rval = 0;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state)
> +		rval = si4713_write_property(sdev,
> +				SI4713_TX_LIMITER_RELEASE_TIME,	rtime);
> +
> +	if (rval >= 0)
> +		sdev->limiter_info.release_time = dev_to_usecs(rtime,
> +						limiter_times,
> +						ARRAY_SIZE(limiter_times));
> +
> +	mutex_unlock(&sdev->mutex);
> +
> +exit:
> +	return rval;
> +}
> +
> +static int si4713_set_stereo_enabled(struct si4713_device *sdev, u8 enabled)
> +{
> +	int rval = 0;
> +	u16 p;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE);
> +		if (rval < 0)
> +			goto unlock;
> +
> +		p = rval;
> +		if (enabled)
> +			p = enable_stereo(p);
> +		else
> +			p = disable_stereo(p);
> +
> +		rval = si4713_write_property(sdev, SI4713_TX_COMPONENT_ENABLE,
> +				p);
> +
> +		if (rval < 0)
> +			goto unlock;
> +	}
> +
> +	sdev->stereo = enabled & 0x01;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_set_pilot_enabled(struct si4713_device *sdev, u8 enabled)
> +{
> +	int rval = 0;
> +	u16 p;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE);
> +		if (rval < 0)
> +			goto unlock;
> +
> +		p = rval;
> +		if (enabled)
> +			p = enable_pilot(p);
> +		else
> +			p = disable_pilot(p);
> +
> +		rval = si4713_write_property(sdev, SI4713_TX_COMPONENT_ENABLE,
> +				p);
> +
> +		if (rval < 0)
> +			goto unlock;
> +	}
> +
> +	sdev->pilot_info.enabled = enabled & 0x01;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_set_pilot_deviation(struct si4713_device *sdev,
> +					unsigned long deviation)
> +{
> +	int rval = 0;
> +
> +	/* Device receives in 10Hz units */
> +	deviation /= 10;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state)
> +		rval = si4713_write_property(sdev, SI4713_TX_PILOT_DEVIATION,
> +						deviation);
> +
> +	/* Device returns in 10Hz units */
> +	if (rval >= 0)
> +		sdev->pilot_info.deviation = deviation * 10;
> +
> +	mutex_unlock(&sdev->mutex);
> +
> +	return rval;
> +}
> +
> +static int si4713_set_pilot_frequency(struct si4713_device *sdev, u16 freq)
> +{
> +	int rval = 0;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state)
> +		rval = si4713_write_property(sdev, SI4713_TX_PILOT_FREQUENCY,
> +						freq);
> +
> +	if (rval >= 0)
> +		sdev->pilot_info.frequency = freq;
> +
> +	mutex_unlock(&sdev->mutex);
> +
> +	return rval;
> +}
> +
> +static int si4713_set_acomp_enabled(struct si4713_device *sdev, u8 enabled)
> +{
> +	int rval = 0;
> +	u16 p;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state) {
> +		rval = si4713_read_property(sdev, SI4713_TX_ACOMP_ENABLE);
> +		if (rval < 0)
> +			goto unlock;
> +
> +		p = rval;
> +		if (enabled)
> +			p = enable_acomp(p);
> +		else
> +			p = disable_acomp(p);
> +
> +		rval = si4713_write_property(sdev, SI4713_TX_ACOMP_ENABLE, p);
> +
> +		if (rval < 0)
> +			goto unlock;
> +	}
> +
> +	sdev->acomp_info.enabled = enabled & 0x01;
> +
> +unlock:
> +	mutex_unlock(&sdev->mutex);
> +	return rval;
> +}
> +
> +static int si4713_set_acomp_gain(struct si4713_device *sdev, u8 gain)
> +{
> +	int rval = 0;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state)
> +		rval = si4713_write_property(sdev, SI4713_TX_ACOMP_GAIN, gain);
> +
> +	if (rval >= 0)
> +		sdev->acomp_info.gain = gain;
> +
> +	mutex_unlock(&sdev->mutex);
> +
> +	return rval;
> +}
> +
> +static int si4713_set_acomp_threshold(struct si4713_device *sdev, s8 threshold)
> +{
> +	int rval = 0;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state)
> +		rval = si4713_write_property(sdev, SI4713_TX_ACOMP_THRESHOLD,
> +						threshold);
> +
> +	if (rval >= 0)
> +		sdev->acomp_info.threshold = threshold;
> +
> +	mutex_unlock(&sdev->mutex);
> +
> +	return rval;
> +}
> +
> +static int si4713_set_acomp_release_time(struct si4713_device *sdev,
> +					unsigned long rtime)
> +{
> +	int rval;
> +
> +	rval = usecs_to_dev(rtime, acomp_rtimes, ARRAY_SIZE(acomp_rtimes));
> +	if (rval < 0)
> +		goto exit;
> +
> +	rtime = rval;
> +	rval = 0;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state)
> +		rval = si4713_write_property(sdev,
> +				SI4713_TX_ACOMP_RELEASE_TIME, rtime);
> +
> +	if (rval >= 0)
> +		sdev->acomp_info.release_time = dev_to_usecs(rtime,
> +						acomp_rtimes,
> +						ARRAY_SIZE(acomp_rtimes));
> +
> +	mutex_unlock(&sdev->mutex);
> +
> +exit:
> +	return rval;
> +}
> +
> +static int si4713_set_acomp_attack_time(struct si4713_device *sdev, u16 atime)
> +{
> +	int rval = 0;
> +
> +	/* Device receives in 0.5 ms units */
> +	atime /= ATTACK_TIME_UNIT;
> +
> +	mutex_lock(&sdev->mutex);
> +
> +	if (sdev->power_state)
> +		rval = si4713_write_property(sdev,
> +				SI4713_TX_ACOMP_ATTACK_TIME, atime);
> +
> +	if (rval >= 0)
> +		sdev->acomp_info.attack_time = atime * ATTACK_TIME_UNIT;
> +
> +	mutex_unlock(&sdev->mutex);
> +
> +	return rval;
> +}
> +
> +static int si4713_set_tune_measure(struct si4713_device *sdev, u32 frequency)
> +{
> +	int rval = -ENODEV;
> +
> +	mutex_lock(&sdev->mutex);
> +	if (sdev->power_state)
> +		rval = si4713_tx_tune_measure(sdev, frequency / 10, 0);
> +	mutex_unlock(&sdev->mutex);
> +
> +	return rval;
> +}
> +
> +/*
> + * si4713_init - Sets the device up with default configuration.
> + * @sdev: si4713_device structure for the device we are communicating
> + */
> +static int si4713_init(struct si4713_device *sdev)
> +{
> +	int rval;
> +
> +	rval = si4713_set_rds_pi(sdev, DEFAULT_RDS_PI);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_rds_pty(sdev, DEFAULT_RDS_PTY);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_rds_ps_name(sdev, DEFAULT_RDS_PS_NAME);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_rds_radio_text(sdev, DEFAULT_RDS_RADIO_TEXT);

Just for my understanding: is RADIO_TEXT something that is always on? What do
you do if you have no radio text? Just use the PS_NAME? An empty string?

This is something that needs to be explained in the v4l2 spec as well.

Currently DEFAULT_RDS_RADIO_TEXT is the same as DEFAULT_RDS_PS_NAME, but I
wonder if it shouldn't be an empty string instead (if that's supported).

> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_rds_enabled(sdev, 1);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_limiter_release_time(sdev, DEFAULT_LIMITER_RTIME);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_limiter_deviation(sdev, DEFAULT_LIMITER_DEV);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_limiter_enabled(sdev, 1);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_pilot_frequency(sdev, DEFAULT_PILOT_FREQUENCY);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_pilot_deviation(sdev, DEFAULT_PILOT_DEVIATION);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_pilot_enabled(sdev, 1);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_stereo_enabled(sdev, 1);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_acomp_attack_time(sdev, DEFAULT_ACOMP_ATIME);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_acomp_release_time(sdev, DEFAULT_ACOMP_RTIME);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_acomp_gain(sdev, DEFAULT_ACOMP_GAIN);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_acomp_threshold(sdev, DEFAULT_ACOMP_THRESHOLD);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_acomp_enabled(sdev, 1);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_mute(sdev, DEFAULT_MUTE);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_power_level(sdev, DEFAULT_POWER_LEVEL);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_preemphasis(sdev, V4L2_FM_TX_PREEMPHASIS_50_uS);
> +	if (rval < 0)
> +		goto exit;
> +
> +exit:
> +	return rval;
> +}
> +
> +/*
> + * si4713_setup - Sets the device up with current configuration.
> + * @sdev: si4713_device structure for the device we are communicating
> + */
> +static int si4713_setup(struct si4713_device *sdev)
> +{
> +	struct si4713_device *tmp;
> +	int rval;
> +
> +	tmp = kmalloc(sizeof(*tmp), GFP_KERNEL);
> +	if (!tmp)
> +		return -ENOMEM;
> +
> +	/* Get a local copy to avoid race */
> +	mutex_lock(&sdev->mutex);
> +	memcpy(tmp, sdev, sizeof(*sdev));
> +	mutex_unlock(&sdev->mutex);
> +
> +	rval = si4713_set_rds_pi(sdev, tmp->rds_info.pi);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_rds_pty(sdev, tmp->rds_info.pty);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_rds_ps_name(sdev, tmp->rds_info.ps_name);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_rds_radio_text(sdev, tmp->rds_info.radio_text);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_rds_enabled(sdev, tmp->rds_info.enabled);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_limiter_release_time(sdev,
> +				tmp->limiter_info.release_time);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_limiter_deviation(sdev, tmp->limiter_info.deviation);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_limiter_enabled(sdev, tmp->limiter_info.enabled);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_pilot_frequency(sdev, tmp->pilot_info.frequency);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_pilot_deviation(sdev, tmp->pilot_info.deviation);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_pilot_enabled(sdev, tmp->pilot_info.enabled);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_stereo_enabled(sdev, tmp->stereo);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_acomp_attack_time(sdev, tmp->acomp_info.attack_time);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_acomp_release_time(sdev,
> +						tmp->acomp_info.release_time);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_acomp_gain(sdev, tmp->acomp_info.gain);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_acomp_threshold(sdev, tmp->acomp_info.threshold);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_acomp_enabled(sdev, tmp->acomp_info.enabled);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_mute(sdev, tmp->mute);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_preemphasis(sdev, tmp->preemphasis);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_frequency(sdev, tmp->frequency ? tmp->frequency :
> +					DEFAULT_FREQUENCY);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_power_level(sdev, tmp->power_level ?
> +					tmp->power_level :
> +					DEFAULT_POWER_LEVEL);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_antenna_capacitor(sdev, tmp->antenna_capacitor);
> +
> +exit:
> +	kfree(tmp);
> +	return rval;
> +}
> +
> +static int si4713_probe(struct si4713_device *sdev)
> +{
> +	int rval;
> +
> +	rval = si4713_set_power_state(sdev, POWER_ON);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_checkrev(sdev);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_set_power_state(sdev, POWER_OFF);
> +	if (rval < 0)
> +		goto exit;
> +
> +	rval = si4713_init(sdev);
> +
> +exit:
> +	return rval;
> +}
> +
> +static int si4713_write_econtrol(struct si4713_device *sdev,
> +					struct v4l2_ext_control *control)
> +{
> +	char ps_name[MAX_RDS_PS_NAME + 1];
> +	char radio_text[MAX_RDS_RADIO_TEXT + 1];
> +	int size;
> +	s32 rval = 0;
> +
> +	switch (control->id) {
> +	/* User class controls */
> +	case V4L2_CID_AUDIO_MUTE:
> +		rval = si4713_set_mute(sdev, control->value);
> +		break;
> +	/* FM_TX 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;
> +	case V4L2_CID_RDS_PS_NAME:
> +		size = control->length > MAX_RDS_PS_NAME ? MAX_RDS_PS_NAME :
> +								control->length;
> +		rval = copy_from_user(ps_name, control->string, size + 1);
> +		if (rval < 0)
> +			goto exit;
> +		rval = si4713_set_rds_ps_name(sdev, ps_name);
> +		goto exit;
> +	case V4L2_CID_RDS_RADIO_TEXT:
> +		size = control->length > MAX_RDS_RADIO_TEXT ?
> +					MAX_RDS_RADIO_TEXT : control->length;
> +		rval = copy_from_user(radio_text, control->string, size + 1);

No, control->length is the total size of the memory block so you should
probably set size to 'control->length - 1' and check against
'control->length > MAX_RDS_RADIO_TEXT + 1'.

The same issue is true for the PS_NAME control above.

> +		if (rval < 0)
> +			goto exit;
> +		rval = si4713_set_rds_radio_text(sdev, radio_text);
> +		goto exit;
> +
> +	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_PREEMPHASIS:
> +		rval = si4713_set_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;
> +	}
> +
> +exit:
> +	return rval;
> +}
> +
> +static int si4713_read_econtrol(struct si4713_device *sdev,
> +				struct v4l2_ext_control *control)
> +{
> +	s32 rval = 0;
> +	s8 val = 0;
> +	char ps_name[MAX_RDS_PS_NAME + 1];
> +	char radio_text[MAX_RDS_RADIO_TEXT + 1];
> +
> +	switch (control->id) {
> +	/* User class controls */
> +	case V4L2_CID_AUDIO_MUTE:
> +		rval = si4713_get_mute(sdev);
> +		break;
> +	/* FM_TX 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;
> +
> +	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)
> +			control->value = val;
> +		/* We can have negative value, so return earlier */
> +		goto exit;
> +	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_PREEMPHASIS:
> +		rval = si4713_get_preemphasis(sdev);
> +		break;
> +
> +	/* here we do not use read property */
> +	case V4L2_CID_RDS_PS_NAME:
> +		rval = si4713_get_rds_ps_name(sdev, ps_name);
> +		if (rval < 0)
> +			goto exit;
> +		rval = copy_to_user(control->string, ps_name,
> +							strlen(ps_name) + 1);
> +		control->length = strlen(ps_name);

No, this isn't right either. The caller allocates the memory and sets up the
control->length. So you have to check whether the result fits in the available
space and return an error if it doesn't. And control->length is the total size
of the allocated memory, including terminating zeroes.

Currently my string control implementation doesn't say anything about how to
detect the right length, that's something I need to think about. As I mentioned
earlier the string control support was put together rather quickly and needs
more time.

> +		goto exit;
> +	case V4L2_CID_RDS_RADIO_TEXT:
> +		rval = si4713_get_rds_radio_text(sdev, radio_text);
> +		if (rval < 0)
> +			goto exit;
> +		rval = copy_to_user(control->string, radio_text,
> +							strlen(radio_text) + 1);
> +		control->length = strlen(radio_text);
> +		goto exit;
> +
> +	/* here we use tx tune status */
> +	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;
> +	};
> +
> +	if (rval >= 0) {
> +		control->value = rval;
> +		rval = 0;
> +	}
> +
> +exit:
> +	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_FM_TX)
> +		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_FM_TX)
> +		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 */
> +	case V4L2_CID_AUDIO_MUTE:
> +		rval = v4l2_ctrl_query_fill(qc, 0, 1, 1, DEFAULT_MUTE);
> +		break;
> +	/* FM_TX 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_PREEMPHASIS:
> +		rval = v4l2_ctrl_query_fill(qc, V4L2_FM_TX_PREEMPHASIS_DISABLED,
> +						V4L2_FM_TX_PREEMPHASIS_75_uS, 1,
> +						V4L2_FM_TX_PREEMPHASIS_50_uS);
> +		break;
> +	case V4L2_CID_TUNE_POWER_LEVEL:
> +		rval = v4l2_ctrl_query_fill(qc, 0, 120, 1, DEFAULT_POWER_LEVEL);
> +		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;
> +			rval = 0;
> +		}
> +		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 = {
> +	.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,
> +};
> +
> +/*
> + * si4713_g_modulator - get modulator attributes
> + */
> +static int si4713_g_modulator(struct v4l2_subdev *sd, struct v4l2_modulator *vm)
> +{
> +	struct si4713_device *sdev = to_si4713_device(sd);
> +	int rval;
> +
> +	if (!sdev) {
> +		rval = -ENODEV;
> +		goto exit;
> +	}
> +
> +	if (vm->index > 0) {
> +		rval = -EINVAL;
> +		goto exit;
> +	}
> +
> +	strncpy(vm->name, "FM Modulator", 32);
> +	vm->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LOW;
> +
> +	/* Report current frequency range limits */
> +	vm->rangelow = si4713_to_v4l2(7600);
> +	vm->rangehigh = si4713_to_v4l2(10800);
> +
> +	/* Report current audio mode: mono or stereo */
> +	vm->txsubchans = V4L2_TUNER_SUB_MONO;
> +	rval = si4713_get_stereo_enabled(sdev);
> +	if (rval < 0)
> +		goto exit;
> +	if (rval)
> +		vm->txsubchans |= V4L2_TUNER_SUB_STEREO;

This isn't right. It should be either SUB_MONO or SUB_STEREO. It tells the
application the current modulation.

> +
> +	/* TODO: Report current signal length */
> +
> +	rval = 0;
> +exit:
> +	return rval;
> +}
> +
> +/*
> + * si4713_s_modulator - set modulator attributes
> + */
> +static int si4713_s_modulator(struct v4l2_subdev *sd, struct v4l2_modulator *vm)
> +{
> +	struct si4713_device *sdev = to_si4713_device(sd);
> +	int rval;
> +
> +	if (!sdev) {
> +		rval = -ENODEV;
> +		goto exit;
> +	}
> +
> +	if (vm->index > 0) {
> +		rval = -EINVAL;
> +		goto exit;
> +	}
> +
> +	/* Set audio mode: mono or stereo */
> +	rval = si4713_set_stereo_enabled(sdev,
> +				!!(vm->txsubchans & V4L2_TUNER_SUB_STEREO));

There are only two valid txsubchans values: SUB_MONO or SUB_STEREO. I suggest
that you check explicitly for these values and return an -EINVAL error if
you get something else.

> +	if (rval < 0)
> +		goto exit;
> +
> +	/* TODO: How to set frequency to measure current signal length */

Huh? I don't understand this TODO.

> +
> +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 = si4713_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;
> +
> +	rval = si4713_set_frequency(sdev, v4l2_to_si4713(f->frequency));
> +	if (rval > 0) {
> +		f->frequency = si4713_to_v4l2(rval);
> +		rval = 0;
> +	}
> +
> +	return rval;
> +}
> +
> +static const struct v4l2_subdev_tuner_ops si4713_subdev_tuner_ops = {
> +	.g_frequency	= si4713_g_frequency,
> +	.s_frequency	= si4713_s_frequency,
> +	.g_modulator	= si4713_g_modulator,
> +	.s_modulator	= si4713_s_modulator,
> +};
> +
> +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)

Misnomer: just call this si4713_probe. This isn't driver initialization,
this probes for a si4713 on an i2c adapter.

> +{
> +	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);

When the subdev was found, then the driver should print this message:

        v4l2_info(&sdev->sd, "chip found @ 0x%02x (%s)\n",
                        client->addr << 1, client->adapter->name);

Since this shows up in the kernel log it is very useful for debugging as it
tells you which i2c devices were found. All v4l i2c drivers do this.

> +
> +	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");

typo: configure -> configured

> +	}
> +
> +	rval = si4713_probe(sdev);
> +	if (rval < 0) {
> +		dev_err(&client->dev, "Failed to probe device information.\n");
> +		goto free_irq;
> +	}
> +
> +	return 0;
> +
> +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)

Also a misnomer: si4713_remove is the correct name. You can't use __exit
here since this doesn't exit the driver, it is just called when the adapter
is removed.

> +{
> +	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;

This can never happen. 

> +	if (sdev) {

sdev is never NULL.

> +		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 i2c_driver si4713_i2c_driver = {
> +	.driver		= {
> +		.name	= "si4713",
> +	},
> +	.probe		= si4713_i2c_driver_probe,
> +	.remove         = __exit_p(si4713_i2c_driver_remove),

Remove __exit_p.

> +	.id_table       = si4713_id,
> +};
> +
> +/*
> + * Module Interface
> + */
> +static int __init si4713_module_init(void)
> +{
> +	return i2c_add_driver(&si4713_i2c_driver);
> +}
> +
> +static void __exit si4713_module_exit(void)
> +{
> +	i2c_del_driver(&si4713_i2c_driver);
> +}
> +
> +module_init(si4713_module_init);
> +module_exit(si4713_module_exit);
> +
> +MODULE_LICENSE("GPL");
> +MODULE_AUTHOR("Eduardo Valentin <eduardo.valentin@nokia.com>");
> +MODULE_DESCRIPTION("I2C driver for Si4713 FM Radio Transmitter");
> +MODULE_VERSION("0.0.1");

I recommend moving these MODULE macros to the top of the source. This is
top-level information so it is good to see this immediately when you open
the source code for the first time.

> +
> diff --git a/linux/drivers/media/radio/si4713-i2c.h b/linux/drivers/media/radio/si4713-i2c.h
> new file mode 100644
> index 0000000..d3c9259
> --- /dev/null
> +++ b/linux/drivers/media/radio/si4713-i2c.h
> @@ -0,0 +1,226 @@
> +/*
> + * drivers/media/radio/si4713-i2c.h
> + *
> + * Property and commands definitions for Si4713 radio transmitter chip.
> + *
> + * Copyright (c) 2008 Instituto Nokia de Tecnologia - INdT
> + * Contact: Eduardo Valentin <eduardo.valentin@nokia.com>
> + *
> + * This file is licensed under the terms of the GNU General Public License
> + * version 2. This program is licensed "as is" without any warranty of any
> + * kind, whether express or implied.
> + *
> + */
> +
> +#ifndef SI4713_I2C_H
> +#define SI4713_I2C_H
> +
> +#include <media/v4l2-subdev.h>
> +#include <media/si4713.h>
> +
> +#define SI4713_PRODUCT_NUMBER		0x0D
> +
> +/* Command Timeouts */
> +#define DEFAULT_TIMEOUT			500
> +#define TIMEOUT_SET_PROPERTY		20
> +#define TIMEOUT_TX_TUNE_POWER		30000
> +#define TIMEOUT_TX_TUNE			110000
> +#define TIMEOUT_POWER_UP		200000
> +
> +/*
> + * Command and its arguments definitions
> + */
> +#define SI4713_PWUP_CTSIEN		(1<<7)
> +#define SI4713_PWUP_GPO2OEN		(1<<6)
> +#define SI4713_PWUP_PATCH		(1<<5)
> +#define SI4713_PWUP_XOSCEN		(1<<4)
> +#define SI4713_PWUP_FUNC_TX		0x02
> +#define SI4713_PWUP_FUNC_PATCH		0x0F
> +#define SI4713_PWUP_OPMOD_ANALOG	0x50
> +#define SI4713_PWUP_OPMOD_DIGITAL	0x0F
> +#define SI4713_PWUP_NARGS		2
> +#define SI4713_PWUP_NRESP		1
> +#define SI4713_CMD_POWER_UP		0x01
> +
> +#define SI4713_GETREV_NRESP		9
> +#define SI4713_CMD_GET_REV		0x10
> +
> +#define SI4713_PWDN_NRESP		1
> +#define SI4713_CMD_POWER_DOWN		0x11
> +
> +#define SI4713_SET_PROP_NARGS		5
> +#define SI4713_SET_PROP_NRESP		1
> +#define SI4713_CMD_SET_PROPERTY		0x12
> +
> +#define SI4713_GET_PROP_NARGS		3
> +#define SI4713_GET_PROP_NRESP		4
> +#define SI4713_CMD_GET_PROPERTY		0x13
> +
> +#define SI4713_GET_STATUS_NRESP		1
> +#define SI4713_CMD_GET_INT_STATUS	0x14
> +
> +#define SI4713_CMD_PATCH_ARGS		0x15
> +#define SI4713_CMD_PATCH_DATA		0x16
> +
> +#define SI4713_MAX_FREQ			10800
> +#define SI4713_MIN_FREQ			7600
> +#define SI4713_TXFREQ_NARGS		3
> +#define SI4713_TXFREQ_NRESP		1
> +#define SI4713_CMD_TX_TUNE_FREQ		0x30
> +
> +#define SI4713_MAX_POWER		120
> +#define SI4713_MIN_POWER		88
> +#define SI4713_MAX_ANTCAP		191
> +#define SI4713_MIN_ANTCAP		0
> +#define SI4713_TXPWR_NARGS		4
> +#define SI4713_TXPWR_NRESP		1
> +#define SI4713_CMD_TX_TUNE_POWER	0x31
> +
> +#define SI4713_TXMEA_NARGS		4
> +#define SI4713_TXMEA_NRESP		1
> +#define SI4713_CMD_TX_TUNE_MEASURE	0x32
> +
> +#define SI4713_INTACK_MASK		0x01
> +#define SI4713_TXSTATUS_NARGS		1
> +#define SI4713_TXSTATUS_NRESP		8
> +#define SI4713_CMD_TX_TUNE_STATUS	0x33
> +
> +#define SI4713_OVERMOD_BIT		(1 << 2)
> +#define SI4713_IALH_BIT			(1 << 1)
> +#define SI4713_IALL_BIT			(1 << 0)
> +#define SI4713_ASQSTATUS_NARGS		1
> +#define SI4713_ASQSTATUS_NRESP		5
> +#define SI4713_CMD_TX_ASQ_STATUS	0x34
> +
> +#define SI4713_RDSBUFF_MODE_MASK	0x87
> +#define SI4713_RDSBUFF_NARGS		7
> +#define SI4713_RDSBUFF_NRESP		6
> +#define SI4713_CMD_TX_RDS_BUFF		0x35
> +
> +#define SI4713_RDSPS_PSID_MASK		0x1F
> +#define SI4713_RDSPS_NARGS		5
> +#define SI4713_RDSPS_NRESP		1
> +#define SI4713_CMD_TX_RDS_PS		0x36
> +
> +#define SI4713_CMD_GPO_CTL		0x80
> +#define SI4713_CMD_GPO_SET		0x81
> +
> +/*
> + * Bits from status response
> + */
> +#define SI4713_CTS			(1<<7)
> +#define SI4713_ERR			(1<<6)
> +#define SI4713_RDS_INT			(1<<2)
> +#define SI4713_ASQ_INT			(1<<1)
> +#define SI4713_STC_INT			(1<<0)
> +
> +/*
> + * Property definitions
> + */
> +#define SI4713_GPO_IEN			0x0001
> +#define SI4713_DIG_INPUT_FORMAT		0x0101
> +#define SI4713_DIG_INPUT_SAMPLE_RATE	0x0103
> +#define SI4713_REFCLK_FREQ		0x0201
> +#define SI4713_REFCLK_PRESCALE		0x0202
> +#define SI4713_TX_COMPONENT_ENABLE	0x2100
> +#define SI4713_TX_AUDIO_DEVIATION	0x2101
> +#define SI4713_TX_PILOT_DEVIATION	0x2102
> +#define SI4713_TX_RDS_DEVIATION		0x2103
> +#define SI4713_TX_LINE_INPUT_LEVEL	0x2104
> +#define SI4713_TX_LINE_INPUT_MUTE	0x2105
> +#define SI4713_TX_PREEMPHASIS		0x2106
> +#define SI4713_TX_PILOT_FREQUENCY	0x2107
> +#define SI4713_TX_ACOMP_ENABLE		0x2200
> +#define SI4713_TX_ACOMP_THRESHOLD	0x2201
> +#define SI4713_TX_ACOMP_ATTACK_TIME	0x2202
> +#define SI4713_TX_ACOMP_RELEASE_TIME	0x2203
> +#define SI4713_TX_ACOMP_GAIN		0x2204
> +#define SI4713_TX_LIMITER_RELEASE_TIME	0x2205
> +#define SI4713_TX_ASQ_INTERRUPT_SOURCE	0x2300
> +#define SI4713_TX_ASQ_LEVEL_LOW		0x2301
> +#define SI4713_TX_ASQ_DURATION_LOW	0x2302
> +#define SI4713_TX_ASQ_LEVEL_HIGH	0x2303
> +#define SI4713_TX_ASQ_DURATION_HIGH	0x2304
> +#define SI4713_TX_RDS_INTERRUPT_SOURCE	0x2C00
> +#define SI4713_TX_RDS_PI		0x2C01
> +#define SI4713_TX_RDS_PS_MIX		0x2C02
> +#define SI4713_TX_RDS_PS_MISC		0x2C03
> +#define SI4713_TX_RDS_PS_REPEAT_COUNT	0x2C04
> +#define SI4713_TX_RDS_PS_MESSAGE_COUNT	0x2C05
> +#define SI4713_TX_RDS_PS_AF		0x2C06
> +#define SI4713_TX_RDS_FIFO_SIZE		0x2C07
> +
> +#define PREEMPHASIS_USA			75
> +#define PREEMPHASIS_EU			50
> +#define PREEMPHASIS_DISABLED		0
> +#define FMPE_USA			0x00
> +#define FMPE_EU				0x01
> +#define FMPE_DISABLED			0x02
> +
> +#define POWER_UP			0x01
> +#define POWER_DOWN			0x00
> +
> +struct rds_info {
> +	u16 pi;
> +#define MAX_RDS_PTY			31
> +	u8 pty;
> +#define MAX_RDS_PS_NAME			96
> +	u8 ps_name[MAX_RDS_PS_NAME + 1];
> +#define MAX_RDS_RADIO_TEXT		384
> +	u8 radio_text[MAX_RDS_RADIO_TEXT + 1];
> +	u8 enabled;
> +};
> +
> +struct limiter_info {
> +#define MAX_LIMITER_RELEASE_TIME	102390
> +	unsigned long release_time;
> +#define MAX_LIMITER_DEVIATION		90000
> +	unsigned long deviation;
> +	u8 enabled;
> +};
> +
> +struct pilot_info {
> +#define MAX_PILOT_DEVIATION		90000
> +	unsigned long deviation;
> +#define MAX_PILOT_FREQUENCY		19000
> +	u16 frequency;
> +	u8 enabled;
> +};
> +
> +struct acomp_info {
> +#define MAX_ACOMP_RELEASE_TIME		1000000
> +	unsigned long release_time;
> +#define MAX_ACOMP_ATTACK_TIME		5000
> +	u16 attack_time;
> +#define MAX_ACOMP_THRESHOLD		0
> +#define MIN_ACOMP_THRESHOLD		(-40)
> +	s8 threshold;
> +#define MAX_ACOMP_GAIN			20
> +	u8 gain;
> +	u8 enabled;
> +};
> +
> +/*
> + * si4713_device - private data
> + */
> +struct si4713_device {
> +	/* v4l2_subdev and i2c reference (v4l2_subdev priv data) */
> +	struct v4l2_subdev sd;
> +	/* private data structures */
> +	struct mutex mutex;
> +	struct completion work;
> +	struct si4713_platform_data *platform_data;
> +	struct rds_info rds_info;
> +	struct limiter_info limiter_info;
> +	struct pilot_info pilot_info;
> +	struct acomp_info acomp_info;
> +	u16 frequency;
> +	u8 preemphasis;
> +	u8 mute;
> +	u8 power_level;
> +	u8 power_state;
> +	u8 antenna_capacitor;
> +	u8 stereo;
> +	u8 tune_rssi;
> +};
> +#endif /* ifndef SI4713_I2C_H */

Regards,

	Hans

-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 2/9] v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX controls
  2009-06-14 10:50       ` Eduardo Valentin
@ 2009-06-14 16:23         ` Trent Piepho
  2009-06-14 16:59           ` Hans Verkuil
  0 siblings, 1 reply; 33+ messages in thread
From: Trent Piepho @ 2009-06-14 16:23 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Hans Verkuil, Eduardo Valentin, ext Mauro Carvalho Chehab,
	Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: TEXT/PLAIN; charset=X-UNKNOWN, Size: 1800 bytes --]

On Sun, 14 Jun 2009, Eduardo Valentin wrote:
> >> +/* FM Modulator class control IDs */
> >> +#define V4L2_CID_FM_TX_CLASS_BASE      (V4L2_CTRL_CLASS_FM_TX | 0x900)
> >> +#define V4L2_CID_FM_TX_CLASS                 (V4L2_CTRL_CLASS_FM_TX | 1)
> >> +
> >> +#define V4L2_CID_RDS_ENABLED                 (V4L2_CID_FM_TX_CLASS_BASE + 1)
> >> +#define V4L2_CID_RDS_PI                              (V4L2_CID_FM_TX_CLASS_BASE + 2)
> >> +#define V4L2_CID_RDS_PTY                     (V4L2_CID_FM_TX_CLASS_BASE + 3)
> >> +#define V4L2_CID_RDS_PS_NAME                 (V4L2_CID_FM_TX_CLASS_BASE + 4)
> >> +#define V4L2_CID_RDS_RADIO_TEXT                      (V4L2_CID_FM_TX_CLASS_BASE + 5)
> >
> > I think these RDS controls should be renamed to V4L2_CID_RDS_TX_. This makes
> > it clear that these controls relate to the RDS transmitter instead of a
> > receiver. I would not be surprised to see similar controls appear for an RDS
> > receiver in the future.

So there should there be different controls to set the same thing, one set
for tx and another for rx?

> >> +#define V4L2_CID_PREEMPHASIS                 (V4L2_CID_FM_TX_CLASS_BASE + 17)
> >> +enum v4l2_fm_tx_preemphasis {
> >> +     V4L2_FM_TX_PREEMPHASIS_DISABLED         = 0,
> >> +     V4L2_FM_TX_PREEMPHASIS_50_uS            = 1,
> >> +     V4L2_FM_TX_PREEMPHASIS_75_uS            = 2,
> >> +};
> >
> > I suggest renaming this to V4L2_CID_FM_TX_PREEMPHASIS. There is already a
> > similar V4L2_CID_MPEG_EMPHASIS control and others might well appear in the
> > future, so I think this name should be more specific to the FM_TX API.

The cx88 driver could get support for setting the fm preemphasis via a
control.  I added support via a module option, but a control would be
better.  You're saying it shouldn't use this fm preemphasis control?

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 2/9] v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX  controls
  2009-06-14 16:23         ` Trent Piepho
@ 2009-06-14 16:59           ` Hans Verkuil
  2009-06-16 10:52             ` Eduardo Valentin
  0 siblings, 1 reply; 33+ messages in thread
From: Hans Verkuil @ 2009-06-14 16:59 UTC (permalink / raw)
  To: Trent Piepho
  Cc: Eduardo Valentin, Eduardo Valentin, ext Mauro Carvalho Chehab,
	Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

On Sunday 14 June 2009 18:23:41 Trent Piepho wrote:
> On Sun, 14 Jun 2009, Eduardo Valentin wrote:
> > >> +/* FM Modulator class control IDs */
> > >> +#define V4L2_CID_FM_TX_CLASS_BASE      (V4L2_CTRL_CLASS_FM_TX | 0x900)
> > >> +#define V4L2_CID_FM_TX_CLASS                 (V4L2_CTRL_CLASS_FM_TX | 1)
> > >> +
> > >> +#define V4L2_CID_RDS_ENABLED                 (V4L2_CID_FM_TX_CLASS_BASE + 1)
> > >> +#define V4L2_CID_RDS_PI                              (V4L2_CID_FM_TX_CLASS_BASE + 2)
> > >> +#define V4L2_CID_RDS_PTY                     (V4L2_CID_FM_TX_CLASS_BASE + 3)
> > >> +#define V4L2_CID_RDS_PS_NAME                 (V4L2_CID_FM_TX_CLASS_BASE + 4)
> > >> +#define V4L2_CID_RDS_RADIO_TEXT                      (V4L2_CID_FM_TX_CLASS_BASE + 5)
> > >
> > > I think these RDS controls should be renamed to V4L2_CID_RDS_TX_. This makes
> > > it clear that these controls relate to the RDS transmitter instead of a
> > > receiver. I would not be surprised to see similar controls appear for an RDS
> > > receiver in the future.
> 
> So there should there be different controls to set the same thing, one set
> for tx and another for rx?

Sure. Say some RDS decoder stores the PI in a register. I can imagine that
we add a V4L2_CID_RDS_RX_PI control for that. Whereas a V4L2_CID_RDS_TX_PI
control will return the PI sent out by the encoder.

Currently no such controls exist (or are needed) for an RDS decoder, but I
wouldn't be surprised at all if we need them at some point in the future.

> 
> > >> +#define V4L2_CID_PREEMPHASIS                 (V4L2_CID_FM_TX_CLASS_BASE + 17)
> > >> +enum v4l2_fm_tx_preemphasis {
> > >> +     V4L2_FM_TX_PREEMPHASIS_DISABLED         = 0,
> > >> +     V4L2_FM_TX_PREEMPHASIS_50_uS            = 1,
> > >> +     V4L2_FM_TX_PREEMPHASIS_75_uS            = 2,
> > >> +};
> > >
> > > I suggest renaming this to V4L2_CID_FM_TX_PREEMPHASIS. There is already a
> > > similar V4L2_CID_MPEG_EMPHASIS control and others might well appear in the
> > > future, so I think this name should be more specific to the FM_TX API.
> 
> The cx88 driver could get support for setting the fm preemphasis via a
> control.  I added support via a module option, but a control would be
> better.  You're saying it shouldn't use this fm preemphasis control?

Correct. This set the pre-emphasis when transmitting. For receiving you want
a separate control. Although the enum should be made generic. So FM_TX can be
removed from the enum.

Why should we have one rx and one tx control for this? Because you can have
both receivers and transmitters in one device and you want independent control
of the two.

It is my believe that the other fm_tx controls are unambiguously transmitter
related, so I don't think they need a TX prefix. It doesn't hurt if someone
can double check that, though.

Regards,

	Hans

-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 0/9] FM Transmitter (si4713) and another changes
  2009-06-14 11:37 ` [PATCHv7 0/9] FM Transmitter (si4713) and another changes Hans Verkuil
@ 2009-06-16 10:47   ` Eduardo Valentin
  2009-06-16 11:01     ` Hans Verkuil
  0 siblings, 1 reply; 33+ messages in thread
From: Eduardo Valentin @ 2009-06-16 10:47 UTC (permalink / raw)
  To: ext Hans Verkuil
  Cc: Valentin Eduardo (Nokia-D/Helsinki),
	ext Mauro Carvalho Chehab, Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

Hi Hans,

On Sun, Jun 14, 2009 at 01:37:20PM +0200, ext Hans Verkuil wrote:
> On Friday 12 June 2009 19:30:31 Eduardo Valentin wrote:
> > Hello all,
> > 
> >   I'm resending the FM transmitter driver and the proposed changes in
> > v4l2 api files in order to cover the fmtx extended controls class.
> > 
> >   Difference from version #6 is that now I've added added lots of comments
> > made by Hans. Here is a list of changes:
> > - Reduce card type string
> > - Remove unused ext controls
> > - Remove s/g_audio and add s/g_audout and enumaudout
> > - remove g/s_input
> > - remove s/g_tuner and add s/g_modulator on subdev and platform driver
> > - reduce function names
> > - Update documentation
> > - remove a few unused and empty lines
> > - remove sysfs interface
> > - rename dev_to_v4l2 to si4713_to_v4l2 (and vice-versa) macros
> > - Remove disabled controls
> > - Add string support
> > - remove v4l2_i2c_driver_data
> > - Join si4713.c with si4713-subdev.c
> > - move platform data to include/media
> > - update documentation
> > 
> > And now this series is based on two of Hans' trees:
> > http://www.linuxtv.org/hg/~hverkuil/v4l-dvb-subdev2.
> > http://www.linuxtv.org/hg/~hverkuil/v4l-dvb-str.
> > 
> > The first tree has refactoring of v4l2 i2c helper functions. The second
> > one has string support for extended controls, which is used in this driver.
> > 
> >   So, now the series includes changes to add the new v4l2
> > FMTX extended controls (and its documetation) and si4713 i2c and platform
> > drivers (and its documentation as well). Besides that, there is also
> > a patch to add g_modulator to v4l2-subdev and a patch to add support
> > for fm tx class in v4l2-ctl util.
> > 
> >   In the TODO list there are two things:
> > i. the signal level measurement property is missing.
> > ii. Re-factor the driver so all that get/set internal functions are removed.
> > 
> >   I believe those TODO's can be done later on, if there is still time to get
> > this driver merged into this window. But of course, this is my opinion,
> > I will understand also if you ask to do them before merge it.
> 
> I think the refactoring should be done first. I don't believe it is that much
> work and experience shows that it is better to do this right away while you are
> still motivated :-)

hehehe.. Yes, that's what I was expecting :-). No problem. I've started it.
I will resend the series once I've completed the re-factoring and
I 've made some testing after that. I hope tomorrow or so.

> 
> The string control support should not go into 2.6.31. I would like to do that
> only in the v4l-dvb tree (so it will appear in 2.6.32) since I want to give that
> a bit more time to mature. I implemented it very quickly and I do not feel
> comfortable queueing this for 2.6.31.
> 

Right. Yes, better to test the stuff a bit more.

> In addition it is still unclear if Mauro will merge my v4l-dvb-subdev2 tree for
> 2.6.31. I hope so, since otherwise it will hamper the development of this and
> other embedded platforms.

Ok.

> 
> I also need to add a new V4L2_CAP_MODULATOR (which needs a review as well).
> 
> And finally I realized that we need to add some v4l2_modulator capabilities
> for the RDS encoder similar to the upcoming v4l2_tuner RDS capabilities as
> is described in this RFC:
> 
> http://www.mail-archive.com/linux-media%40vger.kernel.org/msg02498.html
> 
> I haven't had time to implement this RFC and I know that is not going to make
> 2.6.31. It's now almost at the top of my TODO list, so it should go in soon
> (pending unforeseen circumstances).

Ok. I'll take a look at it.

> 
> As a result of rereading this RFC I also started to wonder about whether
> the si4713 supports the MMBS functionality. Do you know anything about that?

No. Not that I know. Can you point some link?

> 
> Taken all together I think that 2.6.31 is probably not feasible. If it was
> another two weeks until the merge window, then it would. But the merge window
> is already open, and there are just too many little TODOs for this driver. And
> it's also a new API, so we need to be more careful than usual.

Yes. Sure.

> 
> Regards,
> 
> 	Hans
> 
> > 
> >   With these series, the driver is now functional through the v4l2 extended
> > controls changes. Here is an output of v4l2-ctl:
> >  # v4l2-ctl -d /dev/radio0 -l --all
> > Driver Info:
> >         Driver name   : radio-si4713
> >         Card type     : Silicon Labs Si4713 Modulator
> >         Bus info      : 
> >         Driver version: 0
> >         Capabilities  : 0x00080000
> >                 Modulator
> > Audio output: 0 (FM Modulator Audio Out)
> > Frequency: 1552000 (97000.000000 MHz)
> > Video Standard = 0x00000000
> > Modulator:
> >         Name                 : FM Modulator
> >         Capabilities         : 62.5 Hz stereo 
> >         Frequency range      : 76.0 MHz - 108.0 MHz
> >         Available subchannels: mono stereo 
> > 
> > User Controls
> > 
> >                            mute (bool) : default=1 value=0
> > 
> > FM Radio Modulator Controls
> > 
> >             rds_feature_enabled (bool) : default=1 value=1
> >                  rds_program_id (int)  : min=0 max=65535 step=1 default=0 value=0
> >                rds_program_type (int)  : min=0 max=31 step=1 default=0 value=0
> >                     rds_ps_name (str)  : value='Si4713  ' len=8
> > ' len=9          rds_radio_text (str)  : value='Si4713  
> >   audio_limiter_feature_enabled (bool) : default=1 value=1
> >      audio_limiter_release_time (int)  : min=250 max=102390 step=50 default=5010 value=5010 flags=slider
> >         audio_limiter_deviation (int)  : min=0 max=90000 step=10 default=66250 value=66250 flags=slider
> > audio_compression_feature_enabl (bool) : default=1 value=1
> >          audio_compression_gain (int)  : min=0 max=20 step=1 default=15 value=15 flags=slider
> >     audio_compression_threshold (int)  : min=-40 max=0 step=1 default=-40 value=-40 flags=slider
> >   audio_compression_attack_time (int)  : min=0 max=5000 step=500 default=0 value=2000 flags=slider
> >  audio_compression_release_time (int)  : min=100000 max=1000000 step=100000 default=1000000 value=1000000 flags=slider
> >      pilot_tone_feature_enabled (bool) : default=1 value=1
> >            pilot_tone_deviation (int)  : min=0 max=90000 step=10 default=6750 value=6750 flags=slider
> >            pilot_tone_frequency (int)  : min=0 max=19000 step=1 default=19000 value=19000 flags=slider
> >           pre_emphasis_settings (menu) : min=0 max=2 default=1 value=1
> >                tune_power_level (int)  : min=0 max=120 step=1 default=88 value=120 flags=slider
> >          tune_antenna_capacitor (int)  : min=0 max=191 step=1 default=0 value=68 flags=slider
> > 
> > 
> >   Again, comments are welcome.
> > 
> > BR,
> > 
> > Eduardo Valentin (9):
> >   v4l2-subdev.h: Add g_modulator callbacks to subdev api
> >   v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX controls
> >   v4l2: video device: Add FM_TX controls default configurations
> >   v4l2-ctl: Add support for FM TX controls
> >   v4l2-spec: Add documentation description for FM TX extended control
> >     class
> >   FMTx: si4713: Add files to add radio interface for si4713
> >   FMTx: si4713: Add files to handle si4713 i2c device
> >   FMTx: si4713: Add Kconfig and Makefile entries
> >   FMTx: si4713: Add document file
> > 
> >  linux/Documentation/video4linux/si4713.txt |  137 ++
> >  linux/drivers/media/radio/Kconfig          |   22 +
> >  linux/drivers/media/radio/Makefile         |    2 +
> >  linux/drivers/media/radio/radio-si4713.c   |  325 ++++
> >  linux/drivers/media/radio/si4713-i2c.c     | 2813 ++++++++++++++++++++++++++++
> >  linux/drivers/media/radio/si4713-i2c.h     |  226 +++
> >  linux/drivers/media/video/v4l2-common.c    |   50 +
> >  linux/include/linux/videodev2.h            |   34 +
> >  linux/include/media/si4713.h               |   40 +
> >  linux/include/media/v4l2-subdev.h          |    2 +
> >  v4l2-apps/util/v4l2-ctl.cpp                |   36 +
> >  v4l2-spec/Makefile                         |    1 +
> >  v4l2-spec/biblio.sgml                      |   10 +
> >  v4l2-spec/controls.sgml                    |  205 ++
> >  14 files changed, 3903 insertions(+), 0 deletions(-)
> >  create mode 100644 linux/Documentation/video4linux/si4713.txt
> >  create mode 100644 linux/drivers/media/radio/radio-si4713.c
> >  create mode 100644 linux/drivers/media/radio/si4713-i2c.c
> >  create mode 100644 linux/drivers/media/radio/si4713-i2c.h
> >  create mode 100644 linux/include/media/si4713.h
> > 
> > 
> > 
> 
> 
> 
> -- 
> Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom

-- 
Eduardo Valentin

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 2/9] v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX controls
  2009-06-14 16:59           ` Hans Verkuil
@ 2009-06-16 10:52             ` Eduardo Valentin
  2009-06-16 11:18               ` Hans Verkuil
  2009-06-16 18:06               ` Trent Piepho
  0 siblings, 2 replies; 33+ messages in thread
From: Eduardo Valentin @ 2009-06-16 10:52 UTC (permalink / raw)
  To: ext Hans Verkuil
  Cc: Trent Piepho, Eduardo Valentin,
	Valentin Eduardo (Nokia-D/Helsinki),
	ext Mauro Carvalho Chehab, Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

On Sun, Jun 14, 2009 at 06:59:13PM +0200, ext Hans Verkuil wrote:
> On Sunday 14 June 2009 18:23:41 Trent Piepho wrote:
> > On Sun, 14 Jun 2009, Eduardo Valentin wrote:
> > > >> +/* FM Modulator class control IDs */
> > > >> +#define V4L2_CID_FM_TX_CLASS_BASE      (V4L2_CTRL_CLASS_FM_TX | 0x900)
> > > >> +#define V4L2_CID_FM_TX_CLASS                 (V4L2_CTRL_CLASS_FM_TX | 1)
> > > >> +
> > > >> +#define V4L2_CID_RDS_ENABLED                 (V4L2_CID_FM_TX_CLASS_BASE + 1)
> > > >> +#define V4L2_CID_RDS_PI                              (V4L2_CID_FM_TX_CLASS_BASE + 2)
> > > >> +#define V4L2_CID_RDS_PTY                     (V4L2_CID_FM_TX_CLASS_BASE + 3)
> > > >> +#define V4L2_CID_RDS_PS_NAME                 (V4L2_CID_FM_TX_CLASS_BASE + 4)
> > > >> +#define V4L2_CID_RDS_RADIO_TEXT                      (V4L2_CID_FM_TX_CLASS_BASE + 5)
> > > >
> > > > I think these RDS controls should be renamed to V4L2_CID_RDS_TX_. This makes
> > > > it clear that these controls relate to the RDS transmitter instead of a
> > > > receiver. I would not be surprised to see similar controls appear for an RDS
> > > > receiver in the future.
> > 
> > So there should there be different controls to set the same thing, one set
> > for tx and another for rx?
> 
> Sure. Say some RDS decoder stores the PI in a register. I can imagine that
> we add a V4L2_CID_RDS_RX_PI control for that. Whereas a V4L2_CID_RDS_TX_PI
> control will return the PI sent out by the encoder.
> 
> Currently no such controls exist (or are needed) for an RDS decoder, but I
> wouldn't be surprised at all if we need them at some point in the future.
> 
> > 
> > > >> +#define V4L2_CID_PREEMPHASIS                 (V4L2_CID_FM_TX_CLASS_BASE + 17)
> > > >> +enum v4l2_fm_tx_preemphasis {
> > > >> +     V4L2_FM_TX_PREEMPHASIS_DISABLED         = 0,
> > > >> +     V4L2_FM_TX_PREEMPHASIS_50_uS            = 1,
> > > >> +     V4L2_FM_TX_PREEMPHASIS_75_uS            = 2,
> > > >> +};
> > > >
> > > > I suggest renaming this to V4L2_CID_FM_TX_PREEMPHASIS. There is already a
> > > > similar V4L2_CID_MPEG_EMPHASIS control and others might well appear in the
> > > > future, so I think this name should be more specific to the FM_TX API.
> > 
> > The cx88 driver could get support for setting the fm preemphasis via a
> > control.  I added support via a module option, but a control would be
> > better.  You're saying it shouldn't use this fm preemphasis control?
> 
> Correct. This set the pre-emphasis when transmitting. For receiving you want
> a separate control. Although the enum should be made generic. So FM_TX can be
> removed from the enum.
> 
> Why should we have one rx and one tx control for this? Because you can have
> both receivers and transmitters in one device and you want independent control
> of the two.

Yes, agreed here. There is the possibility to have receiver and transmitter
both in the same device. So, I think it is better to have separated controls.

> 
> It is my believe that the other fm_tx controls are unambiguously transmitter
> related, so I don't think they need a TX prefix. It doesn't hurt if someone
> can double check that, though.

hmm.. I see no problem removing the fmtx prefix of the preemphasis
enum. But, if it is becoming a generic enum, better to check if its
meaning is the same of existing emphasis enum for mpeg.

> 
> Regards,
> 
> 	Hans
> 
> -- 
> Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Eduardo Valentin

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 0/9] FM Transmitter (si4713) and another changes
  2009-06-16 10:47   ` Eduardo Valentin
@ 2009-06-16 11:01     ` Hans Verkuil
  2009-06-16 11:07       ` Eduardo Valentin
  0 siblings, 1 reply; 33+ messages in thread
From: Hans Verkuil @ 2009-06-16 11:01 UTC (permalink / raw)
  To: eduardo.valentin
  Cc: ext Mauro Carvalho Chehab, Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

On Tuesday 16 June 2009 12:47:14 Eduardo Valentin wrote:
> Hi Hans,
>
> On Sun, Jun 14, 2009 at 01:37:20PM +0200, ext Hans Verkuil wrote:

<snip>

> > I think the refactoring should be done first. I don't believe it is
> > that much work and experience shows that it is better to do this right
> > away while you are still motivated :-)
>
> hehehe.. Yes, that's what I was expecting :-). No problem. I've started
> it. I will resend the series once I've completed the re-factoring and I
> 've made some testing after that. I hope tomorrow or so.
>
> > The string control support should not go into 2.6.31. I would like to
> > do that only in the v4l-dvb tree (so it will appear in 2.6.32) since I
> > want to give that a bit more time to mature. I implemented it very
> > quickly and I do not feel comfortable queueing this for 2.6.31.
>
> Right. Yes, better to test the stuff a bit more.
>
> > In addition it is still unclear if Mauro will merge my v4l-dvb-subdev2
> > tree for 2.6.31. I hope so, since otherwise it will hamper the
> > development of this and other embedded platforms.
>
> Ok.
>
> > I also need to add a new V4L2_CAP_MODULATOR (which needs a review as
> > well).
> >
> > And finally I realized that we need to add some v4l2_modulator
> > capabilities for the RDS encoder similar to the upcoming v4l2_tuner RDS
> > capabilities as is described in this RFC:
> >
> > http://www.mail-archive.com/linux-media%40vger.kernel.org/msg02498.html
> >
> > I haven't had time to implement this RFC and I know that is not going
> > to make 2.6.31. It's now almost at the top of my TODO list, so it
> > should go in soon (pending unforeseen circumstances).
>
> Ok. I'll take a look at it.

I've worked on this yesterday. You can take a look at my v4l-dvb-rds tree. 
Both the API and the documentation of it in the v4l2-spec is in there. I 
started work on updating the few RDS decoders that we have, but that is not 
yet in that tree.

> > As a result of rereading this RFC I also started to wonder about
> > whether the si4713 supports the MMBS functionality. Do you know
> > anything about that?
>
> No. Not that I know. Can you point some link?

http://www.rds.org.uk/rdsfrdsrbds.html

But I've just read here:

http://www.rds.org.uk/rds98/pdf/rdsForum_standards_090414_8.pdf

that MMBS is discontinued. I'll need to investigate this further, but if 
this is indeed true then this can be removed completely from our RDS 
decoder and encoder APIs.

Regards,

	Hans



-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 7/9] FMTx: si4713: Add files to handle si4713 i2c device
  2009-06-14 12:31               ` [PATCHv7 7/9] FMTx: si4713: Add files to handle si4713 i2c device Hans Verkuil
@ 2009-06-16 11:06                 ` Eduardo Valentin
  2009-06-16 11:22                   ` Hans Verkuil
  0 siblings, 1 reply; 33+ messages in thread
From: Eduardo Valentin @ 2009-06-16 11:06 UTC (permalink / raw)
  To: ext Hans Verkuil
  Cc: Valentin Eduardo (Nokia-D/Helsinki),
	ext Mauro Carvalho Chehab, Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

On Sun, Jun 14, 2009 at 02:31:55PM +0200, ext Hans Verkuil wrote:
> On Friday 12 June 2009 19:30:38 Eduardo Valentin wrote:
> > This 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.
> >
> > Signed-off-by: Eduardo Valentin <eduardo.valentin@nokia.com>
> > ---
> >  linux/drivers/media/radio/si4713-i2c.c | 2813 ++++++++++++++++++++++++++++++++
> >  linux/drivers/media/radio/si4713-i2c.h |  226 +++
> >  2 files changed, 3039 insertions(+), 0 deletions(-)
> >  create mode 100644 linux/drivers/media/radio/si4713-i2c.c
> >  create mode 100644 linux/drivers/media/radio/si4713-i2c.h
> >
> > diff --git a/linux/drivers/media/radio/si4713-i2c.c b/linux/drivers/media/radio/si4713-i2c.c
> > new file mode 100644
> > index 0000000..f640d33
> > --- /dev/null
> > +++ b/linux/drivers/media/radio/si4713-i2c.c
> > @@ -0,0 +1,2813 @@
> > +/*
> > + * drivers/media/radio/si4713-i2c.c
> > + *
> > + * Silicon Labs Si4713 FM Radio Transmitter I2C commands.
> > + *
> > + * Copyright (c) 2009 Nokia Corporation
> > + * Contact: Eduardo Valentin <eduardo.valentin@nokia.com>
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License as published by
> > + * the Free Software Foundation; either version 2 of the License, or
> > + * (at your option) any later version.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU General Public License
> > + * along with this program; if not, write to the Free Software
> > + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> > + */
> > +
> > +#include <linux/mutex.h>
> > +#include <linux/completion.h>
> > +#include <linux/delay.h>
> > +#include <linux/interrupt.h>
> > +#include <linux/i2c.h>
> > +#include <media/v4l2-device.h>
> > +#include <media/v4l2-ioctl.h>
> > +
> > +#include "si4713-i2c.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_MUTE                 0x01
> > +#define DEFAULT_POWER_LEVEL          88
> > +#define DEFAULT_FREQUENCY            8800
> > +#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 si4713_to_v4l2(f)    ((f * FREQDEV_UNIT) / FREQV4L2_MULTI)
> > +#define v4l2_to_si4713(f)    ((f * FREQV4L2_MULTI) / FREQDEV_UNIT)
> > +
> > +#define MAX_ARGS 7
> > +
> > +#define RDS_BLOCK                    8
> > +#define RDS_BLOCK_CLEAR                      0x03
> > +#define RDS_BLOCK_LOAD                       0x04
> > +#define RDS_RADIOTEXT_2A             0x20
> > +#define RDS_RADIOTEXT_BLK_SIZE               4
> > +#define RDS_RADIOTEXT_INDEX_MAX              0x0F
> > +#define RDS_CARRIAGE_RETURN          0x0D
> > +
> > +#define rds_ps_nblocks(len)  ((len / RDS_BLOCK) + (len % RDS_BLOCK ? 1 : 0))
> > +#define enable_rds(p)                (p | (1 << 2))
> > +#define disable_rds(p)               (p & ~(1 << 2))
> > +#define get_rds_status(p)    ((p >> 2) & 0x01)
> > +
> > +#define enable_stereo(p)     (p | (1 << 1))
> > +#define disable_stereo(p)    (p & ~(1 << 1))
> > +#define get_stereo_status(p) ((p >> 1) & 0x01)
> > +
> > +#define enable_limiter(p)    (p | (1 << 1))
> > +#define disable_limiter(p)   (p & ~(1 << 1))
> > +#define get_limiter_status(p)        ((p >> 1) & 0x01)
> > +
> > +#define enable_pilot(p)              (p | (1 << 0))
> > +#define disable_pilot(p)     (p & ~(1 << 0))
> > +#define get_pilot_status(p)  ((p >> 0) & 0x01)
> > +
> > +#define enable_acomp(p)              (p | (1 << 0))
> > +#define disable_acomp(p)     (p & ~(1 << 0))
> > +#define get_acomp_status(p)  ((p >> 0) & 0x01)
> > +#define ATTACK_TIME_UNIT     500
> > +
> > +#define POWER_OFF                    0x00
> > +#define POWER_ON                     0x01
> > +
> > +#define msb(x)                  ((u8)((u16) x >> 8))
> > +#define lsb(x)                  ((u8)((u16) x &  0x00FF))
> > +#define compose_u16(msb, lsb)        (((u16)msb << 8) | lsb)
> > +#define check_command_failed(status) (!(status & SI4713_CTS) || \
> > +                                     (status & SI4713_ERR))
> > +/* mute definition */
> > +#define set_mute(p)  ((p & 1) | ((p & 1) << 1));
> > +#define get_mute(p)  (p & 0x01)
> > +#define set_pty(v, pty)      ((v & 0xFC1F) | (pty << 5))
> > +#define get_pty(v)   ((v >> 5) & 0x1F)
> > +
> > +#ifdef DEBUG
> > +#define DBG_BUFFER(device, message, buffer, size)                    \
> > +     {                                                               \
> > +             int i;                                                  \
> > +             char str[(size)*5];                                     \
> > +             for (i = 0; i < size; i++)                              \
> > +                     sprintf(str + i * 5, " 0x%02x", buffer[i]);     \
> > +             dev_dbg(device, "%s:%s\n", message, str);               \
> > +     }
> > +#else
> > +#define DBG_BUFFER(device, message, buffer, size)
> > +#endif
> > +
> > +
> > +/*
> > + * Values for limiter release time
> > + *   device  release
> > + *   value   time (us)
> > + */
> > +static unsigned long const limiter_times[] = {
> > +     2000,   250,
> > +     1000,   500,
> > +     510,    1000,
> > +     255,    2000,
> > +     170,    3000,
> > +     127,    4020,
> > +     102,    5010,
> > +     85,     6020,
> > +     73,     7010,
> > +     64,     7990,
> > +     57,     8970,
> > +     51,     10030,
> > +     25,     20470,
> > +     17,     30110,
> > +     13,     39380,
> > +     10,     51190,
> > +     8,      63690,
> > +     7,      73140,
> > +     6,      85330,
> > +     5,      102390,
> > +};
> > +
> > +/*
> > + * Values for audio compression release time
> > + *   device  release
> > + *   value   time (us)
> > + */
> > +static unsigned long const acomp_rtimes[] = {
> > +     0,      100000,
> > +     1,      200000,
> > +     2,      350000,
> > +     3,      525000,
> > +     4,      1000000,
> > +};
> > +
> > +static int usecs_to_dev(unsigned long usecs, unsigned long const array[],
> > +                     int size)
> > +{
> > +     int i;
> > +     int rval = -EINVAL;
> > +
> > +     for (i = 0; i < size / 2; i++)
> > +             if (array[(i * 2) + 1] >= usecs) {
> > +                     rval = array[i * 2];
> > +                     break;
> > +             }
> > +
> > +     return rval;
> > +}
> > +
> > +static unsigned long dev_to_usecs(int value, unsigned long const array[],
> > +                     int size)
> > +{
> > +     int i;
> > +     int rval = -EINVAL;
> > +
> > +     for (i = 0; i < size / 2; i++)
> > +             if (array[i * 2] == value) {
> > +                     rval = array[(i * 2) + 1];
> > +                     break;
> > +             }
> > +
> > +     return rval;
> > +}
> > +
> > +/* si4713_handler: IRQ handler, just complete work */
> > +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;
> > +}
> > +
> > +/*
> > + * si4713_send_command - sends a command to si4713 and waits its response
> > + * @sdev: si4713_device structure for the device we are communicating
> > + * @command: command id
> > + * @args: command arguments we are sending (up to 7)
> > + * @argn: actual size of @args
> > + * @response: buffer to place the expected response from the device (up to 15)
> > + * @respn: actual size of @response
> > + * @usecs: amount of time to wait before reading the response (in usecs)
> > + */
> > +static int si4713_send_command(struct si4713_device *sdev, const u8 command,
> > +                             const u8 args[], const int argn,
> > +                             u8 response[], const int respn, const int usecs)
> > +{
> > +     struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> > +     u8 data1[MAX_ARGS + 1];
> > +     int err;
> > +
> > +     if (!client->adapter)
> > +             return -ENODEV;
> > +
> > +     /* First send the command and its arguments */
> > +     data1[0] = command;
> > +     memcpy(data1 + 1, args, argn);
> > +     DBG_BUFFER(&client->dev, "Parameters", data1, argn + 1);
> > +
> > +     err = i2c_master_send(client, data1, argn + 1);
> > +     if (err != argn + 1) {
> > +             dev_err(&client->dev, "Error while sending command 0x%02x\n",
> > +                     command);
> > +             return (err > 0) ? -EIO : err;
> > +     }
> > +
> > +     /* Wait response from interrupt */
> > +     if (!wait_for_completion_timeout(&sdev->work,
> > +                             usecs_to_jiffies(usecs) + 1))
> > +             dev_dbg(&client->dev, "Device took too much time.\n");
> 
> Shouldn't this be a warning or error rather than a debug message?

yes, a warn.

> 
> > +
> > +     /* Then get the response */
> > +     err = i2c_master_recv(client, response, respn);
> > +     if (err != respn) {
> > +             dev_err(&client->dev,
> 
> For i2c drivers I recommend using v4l2_err and friends. These are used by all
> other v4l2 i2c drivers as well and they format the prefix a bit better than
> dev_err (these give a rather long prefix). It also ensures consistency over
> the various v4l2 i2c drivers.
> 
> The v4l2_dbg macro also is a bit more efficient when debugging is turned off.

Right, I'll rewrite the logging commands with v4l2_* family.

> 
> > +                     "Error while reading response for command 0x%02x\n",
> > +                     command);
> > +             return (err > 0) ? -EIO : err;
> > +     }
> > +
> > +     DBG_BUFFER(&client->dev, "Response", response, respn);
> > +     if (check_command_failed(response[0]))
> > +             return -EBUSY;
> > +
> > +     return 0;
> > +}
> > +
> > +/*
> > + * si4713_read_property - reads a si4713 property
> > + * @sdev: si4713_device structure for the device we are communicating
> > + * @prop: property identification number
> > + */
> > +static int si4713_read_property(struct si4713_device *sdev, u16 prop)
> > +{
> > +     struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> > +     int err;
> > +     u8 val[SI4713_GET_PROP_NRESP];
> > +     /*
> > +      * REVISIT: From Programming Manual
> > +      *      .First byte = 0
> > +      *      .Second byte = property's MSB
> > +      *      .Third byte = property's LSB
> > +      */
> > +     const u8 args[SI4713_GET_PROP_NARGS] = {
> > +             0x00,
> > +             msb(prop),
> > +             lsb(prop),
> > +     };
> > +
> > +     err = si4713_send_command(sdev, SI4713_CMD_GET_PROPERTY,
> > +                               args, ARRAY_SIZE(args), val,
> > +                               ARRAY_SIZE(val), DEFAULT_TIMEOUT);
> > +
> > +     if (err < 0)
> > +             return err;
> > +
> > +     dev_dbg(&client->dev, "Status from read prop: 0x%02x\n", val[0]);
> > +
> > +     return compose_u16(val[2], val[3]);
> > +}
> > +
> > +/*
> > + * si4713_write_property - modifies a si4713 property
> > + * @sdev: si4713_device structure for the device we are communicating
> > + * @prop: property identification number
> > + * @val: new value for that property
> > + */
> > +static int si4713_write_property(struct si4713_device *sdev, u16 prop, u16 val)
> > +{
> > +     struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> > +     int rval;
> > +     u8 resp[SI4713_SET_PROP_NRESP];
> > +     /*
> > +      * REVISIT: From Programming Manual
> > +      *      .First byte = 0
> > +      *      .Second byte = property's MSB
> > +      *      .Third byte = property's LSB
> > +      *      .Fourth byte = value's MSB
> > +      *      .Fifth byte = value's LSB
> > +      */
> > +     const u8 args[SI4713_SET_PROP_NARGS] = {
> > +             0x00,
> > +             msb(prop),
> > +             lsb(prop),
> > +             msb(val),
> > +             lsb(val),
> > +     };
> > +
> > +     rval = si4713_send_command(sdev, SI4713_CMD_SET_PROPERTY,
> > +                                     args, ARRAY_SIZE(args),
> > +                                     resp, ARRAY_SIZE(resp),
> > +                                     DEFAULT_TIMEOUT);
> > +
> > +     if (rval < 0)
> > +             return rval;
> > +
> > +     dev_dbg(&client->dev, "Status from write prop: 0x%02x\n",
> > +             resp[0]);
> > +
> > +     /*
> > +      * As there is no command response for SET_PROPERTY,
> > +      * wait Tcomp time to finish before proceed, in order
> > +      * to have property properly set.
> > +      */
> > +     msleep(TIMEOUT_SET_PROPERTY);
> > +
> > +     return rval;
> > +}
> > +
> > +/*
> > + * si4713_powerup - Powers the device up
> > + * @sdev: si4713_device structure for the device we are communicating
> > + */
> > +static int si4713_powerup(struct si4713_device *sdev)
> > +{
> > +     struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> > +     int err;
> > +     u8 resp[SI4713_PWUP_NRESP];
> > +     /*
> > +      * REVISIT: From Programming Manual
> > +      *      .First byte = Enabled interrupts and boot function
> > +      *      .Second byte = Input operation mode
> > +      */
> > +     const u8 args[SI4713_PWUP_NARGS] = {
> > +             SI4713_PWUP_CTSIEN | SI4713_PWUP_GPO2OEN | SI4713_PWUP_FUNC_TX,
> > +             SI4713_PWUP_OPMOD_ANALOG,
> > +     };
> > +
> > +     if (sdev->power_state)
> > +             return 0;
> > +
> > +     sdev->platform_data->set_power(1);
> > +     err = si4713_send_command(sdev, SI4713_CMD_POWER_UP,
> > +                                     args, ARRAY_SIZE(args),
> > +                                     resp, ARRAY_SIZE(resp),
> > +                                     TIMEOUT_POWER_UP);
> > +
> > +     if (!err) {
> > +             dev_dbg(&client->dev, "Powerup response: 0x%02x\n",
> > +                     resp[0]);
> > +             dev_dbg(&client->dev, "Device in power up mode\n");
> > +             sdev->power_state = POWER_ON;
> > +
> > +             err = si4713_write_property(sdev, SI4713_GPO_IEN,
> > +                                             SI4713_STC_INT | SI4713_CTS);
> > +     } else {
> > +             sdev->platform_data->set_power(0);
> > +     }
> > +
> > +     return err;
> > +}
> > +
> > +/*
> > + * si4713_powerdown - Powers the device down
> > + * @sdev: si4713_device structure for the device we are communicating
> > + */
> > +static int si4713_powerdown(struct si4713_device *sdev)
> > +{
> > +     struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> > +     int err;
> > +     u8 resp[SI4713_PWDN_NRESP];
> > +
> > +     if (!sdev->power_state)
> > +             return 0;
> > +
> > +     err = si4713_send_command(sdev, SI4713_CMD_POWER_DOWN,
> > +                                     NULL, 0,
> > +                                     resp, ARRAY_SIZE(resp),
> > +                                     DEFAULT_TIMEOUT);
> > +
> > +     if (!err) {
> > +             dev_dbg(&client->dev, "Power down response: 0x%02x\n",
> > +                     resp[0]);
> > +             dev_dbg(&client->dev, "Device in reset mode\n");
> > +             sdev->platform_data->set_power(0);
> > +             sdev->power_state = POWER_OFF;
> > +     }
> > +
> > +     return err;
> > +}
> > +
> > +/*
> > + * si4713_checkrev - Checks if we are treating a device with the correct rev.
> > + * @sdev: si4713_device structure for the device we are communicating
> > + */
> > +#define pr_revision(devicep, buffer)                                 \
> > +     dev_info(devicep, "Detected %s (0x%02x) Firmware: %d.%d"        \
> > +                       " Patch ID: %02x:%02x Component: %d.%d"       \
> > +                       " Chip Rev.: %s\n",                           \
> > +                     buffer[1] == SI4713_PRODUCT_NUMBER ? "Si4713" : "",\
> > +                     buffer[1],                                      \
> > +                     buffer[2] & 0xF, buffer[3] & 0xF,               \
> > +                     buffer[4], buffer[5],                           \
> > +                     buffer[6] & 0xF, buffer[7] & 0xF,               \
> > +                     buffer[8] == 0x41 ? "revA" : "unknown")
> 
> Turn this into a static inline function.

This is just info to report when device is probed. I will replace
it with the standard v4l2 message (that one you pointed bellow)

> 
> > +static int si4713_checkrev(struct si4713_device *sdev)
> > +{
> > +     struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> > +     int rval;
> > +     u8 resp[SI4713_GETREV_NRESP];
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     rval = si4713_send_command(sdev, SI4713_CMD_GET_REV,
> > +                                     NULL, 0,
> > +                                     resp, ARRAY_SIZE(resp),
> > +                                     DEFAULT_TIMEOUT);
> > +
> > +     if (rval < 0)
> > +             goto unlock;
> > +
> > +     if (resp[1] == SI4713_PRODUCT_NUMBER) {
> > +             pr_revision(&client->dev, resp);
> > +     } else {
> > +             dev_err(&client->dev, "Invalid product number\n");
> > +             rval = -EINVAL;
> > +     }
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +/*
> > + * si4713_wait_stc - Waits STC interrupt and clears status bits. Usefull
> > + *                for TX_TUNE_POWER, TX_TUNE_FREQ and TX_TUNE_MEAS
> > + * @sdev: si4713_device structure for the device we are communicating
> > + * @usecs: timeout to wait for STC interrupt signal
> > + */
> > +static int si4713_wait_stc(struct si4713_device *sdev, const int usecs)
> > +{
> > +     struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> > +     int err;
> > +     u8 resp[SI4713_GET_STATUS_NRESP];
> > +
> > +     /* Wait response from STC interrupt */
> > +     if (!wait_for_completion_timeout(&sdev->work,
> > +                     usecs_to_jiffies(TIMEOUT_TX_TUNE) + 1))
> > +             dev_dbg(&client->dev, "Device took too much time.\n");
> > +
> > +     /* Clear status bits */
> > +     err = si4713_send_command(sdev, SI4713_CMD_GET_INT_STATUS,
> > +                                     NULL, 0,
> > +                                     resp, ARRAY_SIZE(resp),
> > +                                     DEFAULT_TIMEOUT);
> > +
> > +     if (err < 0)
> > +             goto exit;
> > +
> > +     dev_dbg(&client->dev, "Status bits: 0x%02x\n", resp[0]);
> > +
> > +     if (!(resp[0] & SI4713_STC_INT))
> > +             err = -EIO;
> > +
> > +exit:
> > +     return err;
> > +}
> > +
> > +/*
> > + * si4713_tx_tune_freq - Sets the state of the RF carrier and sets the tuning
> > + *                   frequency between 76 and 108 MHz in 10 kHz units and
> > + *                   steps of 50 kHz.
> > + * @sdev: si4713_device structure for the device we are communicating
> > + * @frequency: desired frequency (76 - 108 MHz, unit 10 KHz, step 50 kHz)
> > + */
> > +static int si4713_tx_tune_freq(struct si4713_device *sdev, u16 frequency)
> > +{
> > +     struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> > +     int err;
> > +     u8 val[SI4713_TXFREQ_NRESP];
> > +     /*
> > +      * REVISIT: From Programming Manual
> 
> Revisit what? I'm not sure what you mean with REVISIT. If this just recaps
> the manual, then I would suggest just removing the REVISIT: prefix.

Right. This is just a comment which was left behind since early stage
of driver development. I'll remove it.

> 
> > +      *      .First byte = 0
> > +      *      .Second byte = frequency's MSB
> > +      *      .Third byte = frequency's LSB
> > +      */
> > +     const u8 args[SI4713_TXFREQ_NARGS] = {
> > +             0x00,
> > +             msb(frequency),
> > +             lsb(frequency),
> > +     };
> > +
> > +     err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_FREQ,
> > +                               args, ARRAY_SIZE(args), val,
> > +                               ARRAY_SIZE(val), DEFAULT_TIMEOUT);
> > +
> > +     if (err < 0)
> > +             return err;
> > +
> > +     dev_dbg(&client->dev, "Status from tx tune freq: 0x%02x\n",
> > +             val[0]);
> > +
> > +     err = si4713_wait_stc(sdev, TIMEOUT_TX_TUNE);
> > +     if (err < 0)
> > +             return err;
> > +
> > +     return compose_u16(args[1], args[2]);
> > +}
> > +
> > +/*
> > + * si4713_tx_tune_power - Sets the RF voltage level between 88 and 115 dBuV in
> > + *                   1 dB units. A value of 0x00 indicates off. The command
> > + *                   also sets the antenna tuning capacitance. A value of 0
> > + *                   indicates autotuning, and a value of 1 - 191 indicates
> > + *                   a manual override, which results in a tuning
> > + *                   capacitance of 0.25 pF x @antcap.
> > + * @sdev: si4713_device structure for the device we are communicating
> > + * @power: tuning power (88 - 115 dBuV, unit/step 1 dB)
> > + * @antcap: value of antenna tuning capacitor (0 - 191)
> > + */
> > +static int si4713_tx_tune_power(struct si4713_device *sdev, u8 power,
> > +                             u8 antcap)
> > +{
> > +     struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> > +     int err;
> > +     u8 val[SI4713_TXPWR_NRESP];
> > +     /*
> > +      * REVISIT: From Programming Manual
> > +      *      .First byte = 0
> > +      *      .Second byte = 0
> > +      *      .Third byte = power
> > +      *      .Fourth byte = antcap
> > +      */
> > +     const u8 args[SI4713_TXPWR_NARGS] = {
> > +             0x00,
> > +             0x00,
> > +             power,
> > +             antcap,
> > +     };
> > +
> > +     if (((power > 0) && (power < SI4713_MIN_POWER)) ||
> > +             power > SI4713_MAX_POWER || antcap > SI4713_MAX_ANTCAP)
> > +             return -EDOM;
> > +
> > +     err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_POWER,
> > +                               args, ARRAY_SIZE(args), val,
> > +                               ARRAY_SIZE(val), DEFAULT_TIMEOUT);
> > +
> > +     if (err < 0)
> > +             return err;
> > +
> > +     dev_dbg(&client->dev, "Status from tx tune power: 0x%02x\n",
> > +             val[0]);
> > +
> > +     return si4713_wait_stc(sdev, TIMEOUT_TX_TUNE_POWER);
> > +}
> > +
> > +/*
> > + * si4713_tx_tune_measure - Enters receive mode and measures the received noise
> > + *                   level in units of dBuV on the selected frequency.
> > + *                   The Frequency must be between 76 and 108 MHz in 10 kHz
> > + *                   units and steps of 50 kHz. The command also sets the
> > + *                   antenna tuning capacitance. A value of 0 means
> > + *                   autotuning, and a value of 1 to 191 indicates manual
> > + *                   override.
> > + * @sdev: si4713_device structure for the device we are communicating
> > + * @frequency: desired frequency (76 - 108 MHz, unit 10 KHz, step 50 kHz)
> > + * @antcap: value of antenna tuning capacitor (0 - 191)
> > + */
> > +static int si4713_tx_tune_measure(struct si4713_device *sdev, u16 frequency,
> > +                                     u8 antcap)
> > +{
> > +     struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> > +     int err;
> > +     u8 val[SI4713_TXMEA_NRESP];
> > +     /*
> > +      * REVISIT: From Programming Manual
> > +      *      .First byte = 0
> > +      *      .Second byte = frequency's MSB
> > +      *      .Third byte = frequency's LSB
> > +      *      .Fourth byte = antcap
> > +      */
> > +     const u8 args[SI4713_TXMEA_NARGS] = {
> > +             0x00,
> > +             msb(frequency),
> > +             lsb(frequency),
> > +             antcap,
> > +     };
> > +
> > +     sdev->tune_rssi = DEFAULT_TUNE_RSSI;
> > +
> > +     if (antcap > SI4713_MAX_ANTCAP)
> > +             return -EDOM;
> > +
> > +     err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_MEASURE,
> > +                               args, ARRAY_SIZE(args), val,
> > +                               ARRAY_SIZE(val), DEFAULT_TIMEOUT);
> > +
> > +     if (err < 0)
> > +             return err;
> > +
> > +     dev_dbg(&client->dev, "Status from tx tune measure: 0x%02x\n",
> > +             val[0]);
> > +
> > +     return si4713_wait_stc(sdev, TIMEOUT_TX_TUNE);
> > +}
> > +
> > +/*
> > + * si4713_tx_tune_status- Returns the status of the tx_tune_freq, tx_tune_mea or
> > + *                   tx_tune_power commands. This command return the current
> > + *                   frequency, output voltage in dBuV, the antenna tunning
> > + *                   capacitance value and the received noise level. The
> > + *                   command also clears the stcint interrupt bit when the
> > + *                   first bit of its arguments is high.
> > + * @sdev: si4713_device structure for the device we are communicating
> > + * @intack: 0x01 to clear the seek/tune complete interrupt status indicator.
> > + * @frequency: returned frequency
> > + * @power: returned power
> > + * @antcap: returned antenna capacitance
> > + * @noise: returned noise level
> > + */
> > +static int si4713_tx_tune_status(struct si4713_device *sdev, u8 intack,
> > +                                     u16 *frequency, u8 *power,
> > +                                     u8 *antcap, u8 *noise)
> > +{
> > +     struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> > +     int err;
> > +     u8 val[SI4713_TXSTATUS_NRESP];
> > +     /*
> > +      * REVISIT: From Programming Manual
> > +      *      .First byte = intack bit
> > +      */
> > +     const u8 args[SI4713_TXSTATUS_NARGS] = {
> > +             intack & SI4713_INTACK_MASK,
> > +     };
> > +
> > +     err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_STATUS,
> > +                               args, ARRAY_SIZE(args), val,
> > +                               ARRAY_SIZE(val), DEFAULT_TIMEOUT);
> > +
> > +     if (!err) {
> > +             dev_dbg(&client->dev,
> > +                     "Status from tx tune status: 0x%02x\n", val[0]);
> > +             *frequency = compose_u16(val[2], val[3]);
> > +             sdev->frequency = *frequency;
> > +             *power = val[5];
> > +             *antcap = val[6];
> > +             *noise = val[7];
> > +             dev_dbg(&client->dev, "Tune status: %d x 10 kHz "
> > +                             "(power %d, antcap %d, rnl %d)\n",
> > +                             *frequency, *power, *antcap, *noise);
> > +     }
> > +
> > +     return err;
> > +}
> > +
> > +/*
> > + * si4713_tx_rds_buff - Loads the RDS group buffer FIFO or circular buffer.
> > + * @sdev: si4713_device structure for the device we are communicating
> > + * @mode: the buffer operation mode.
> > + * @rdsb: RDS Block B
> > + * @rdsc: RDS Block C
> > + * @rdsd: RDS Block D
> > + * @intstatus: returns current interrupt status
> > + * @cbavail: returns the number of available circular buffer blocks.
> > + * @cbused: returns the number of used circular buffer blocks.
> > + * @fifoavail: returns the number of available fifo buffer blocks.
> > + * @fifoused: returns the number of used fifo buffer blocks.
> > + */
> > +static int si4713_tx_rds_buff(struct si4713_device *sdev, u8 mode, u16 rdsb,
> > +                             u16 rdsc, u16 rdsd, u8 *intstatus, u8 *cbavail,
> > +                             u8 *cbused, u8 *fifoavail, u8 *fifoused)
> > +{
> > +     struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> > +     int err;
> > +     u8 val[SI4713_RDSBUFF_NRESP];
> > +
> > +     const u8 args[SI4713_RDSBUFF_NARGS] = {
> > +             mode & SI4713_RDSBUFF_MODE_MASK,
> > +             msb(rdsb),
> > +             lsb(rdsb),
> > +             msb(rdsc),
> > +             lsb(rdsc),
> > +             msb(rdsd),
> > +             lsb(rdsd),
> > +     };
> > +
> > +     err = si4713_send_command(sdev, SI4713_CMD_TX_RDS_BUFF,
> > +                               args, ARRAY_SIZE(args), val,
> > +                               ARRAY_SIZE(val), DEFAULT_TIMEOUT);
> > +
> > +     if (!err) {
> > +             dev_dbg(&client->dev,
> > +                     "Status from tx rds buff: 0x%02x\n", val[0]);
> > +             *intstatus = val[1];
> > +             *cbavail = val[2];
> > +             *cbused = val[3];
> > +             *fifoavail = val[4];
> > +             *fifoused = val[5];
> > +             dev_dbg(&client->dev, "rds buffer status: interrupts"
> > +                             " 0x%02x cb avail: %d cb used %d fifo avail"
> > +                             " %d fifo used %d\n", *intstatus, *cbavail,
> > +                             *cbused, *fifoavail, *fifoused);
> > +     }
> > +
> > +     return err;
> > +}
> > +
> > +/*
> > + * si4713_tx_rds_ps - Loads the program service buffer.
> > + * @sdev: si4713_device structure for the device we are communicating
> > + * @psid: program service id to be loaded.
> > + * @pschar: assumed 4 size char array to be loaded into the program service
> > + */
> > +static int si4713_tx_rds_ps(struct si4713_device *sdev, u8 psid,
> > +                             unsigned char *pschar)
> > +{
> > +     struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
> > +     int err;
> > +     u8 val[SI4713_RDSPS_NRESP];
> > +
> > +     const u8 args[SI4713_RDSPS_NARGS] = {
> > +             psid & SI4713_RDSPS_PSID_MASK,
> > +             pschar[0],
> > +             pschar[1],
> > +             pschar[2],
> > +             pschar[3],
> > +     };
> > +
> > +     err = si4713_send_command(sdev, SI4713_CMD_TX_RDS_PS,
> > +                               args, ARRAY_SIZE(args), val,
> > +                               ARRAY_SIZE(val), DEFAULT_TIMEOUT);
> > +
> > +     if (err < 0)
> > +             return err;
> > +
> > +     dev_dbg(&client->dev, "Status from tx rds ps: 0x%02x\n",
> > +             val[0]);
> > +
> > +     return err;
> > +}
> > +
> > +/* TODO: Remove getters and setters functions and simplify driver code */
> > +
> > +/* getters */
> > +/* tx_tune_status */
> > +static int si4713_get_power_level(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +     u16 f = 0;
> > +     u8 p, a, n;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_tx_tune_status(sdev, 0x00, &f, &p, &a, &n);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             sdev->power_level = p;
> > +     }
> > +
> > +     rval = sdev->power_level;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_get_antenna_capacitor(struct si4713_device *sdev)
> > +{
> > +     int rval = 0;
> > +     u16 f = 0;
> > +     u8 p, a, n;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_tx_tune_status(sdev, 0x00, &f, &p, &a, &n);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             sdev->antenna_capacitor = a;
> > +     }
> > +
> > +     rval = sdev->antenna_capacitor;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_get_tune_measure(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +     u16 f = 0;
> > +     u8 p, a, n;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_tx_tune_status(sdev, 0x00, &f, &p, &a, &n);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             sdev->tune_rssi = n;
> > +     }
> > +
> > +     rval = sdev->tune_rssi;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_get_frequency(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +     u16 f = 0;
> > +     u8 p, a, n;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_tx_tune_status(sdev, 0x00, &f, &p, &a, &n);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             sdev->frequency = f;
> > +     }
> > +
> > +     rval = sdev->frequency;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +/* read_property */
> > +static int si4713_get_mute(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_LINE_INPUT_MUTE);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             sdev->mute = rval;
> > +     }
> > +
> > +     rval = get_mute(sdev->mute);
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_get_rds_pi(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_RDS_PI);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             sdev->rds_info.pi = rval;
> > +     }
> > +
> > +     rval = sdev->rds_info.pi;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_get_rds_pty(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_RDS_PS_MISC);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             sdev->rds_info.pty = get_pty(rval);
> > +     }
> > +
> > +     rval = sdev->rds_info.pty;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +
> > +static int si4713_get_rds_enabled(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE);
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             sdev->rds_info.enabled = get_rds_status(rval);
> > +     }
> > +
> > +     rval = sdev->rds_info.enabled;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_get_preemphasis(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_PREEMPHASIS);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             switch (rval) {
> > +             case FMPE_USA:
> > +                     sdev->preemphasis = V4L2_FM_TX_PREEMPHASIS_75_uS;
> > +                     break;
> > +             case FMPE_EU:
> > +                     sdev->preemphasis = V4L2_FM_TX_PREEMPHASIS_50_uS;
> > +                     break;
> > +             case FMPE_DISABLED:
> > +                     sdev->preemphasis = V4L2_FM_TX_PREEMPHASIS_DISABLED;
> > +                     break;
> > +             default:
> > +                     rval = -EINVAL;
> > +                     goto unlock;
> > +             }
> > +     }
> > +
> > +     rval = sdev->preemphasis;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_get_limiter_enabled(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_ACOMP_ENABLE);
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             sdev->limiter_info.enabled = get_limiter_status(rval);
> > +     }
> > +
> > +     rval = sdev->limiter_info.enabled;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static long si4713_get_limiter_deviation(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_AUDIO_DEVIATION);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             /* Device returns in 10Hz units */
> > +             sdev->limiter_info.deviation = rval * 10;
> > +     }
> > +
> > +     rval = sdev->limiter_info.deviation;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static long si4713_get_limiter_release_time(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev,
> > +                             SI4713_TX_LIMITER_RELEASE_TIME);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             sdev->limiter_info.release_time = dev_to_usecs(rval,
> > +                                             limiter_times,
> > +                                             ARRAY_SIZE(limiter_times));
> > +     }
> > +
> > +     rval = sdev->limiter_info.release_time;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_get_stereo_enabled(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE);
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             sdev->stereo = get_stereo_status(rval);
> > +     }
> > +
> > +     rval = sdev->stereo;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_get_pilot_enabled(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE);
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             sdev->pilot_info.enabled = get_pilot_status(rval);
> > +     }
> > +
> > +     rval = sdev->pilot_info.enabled;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static long si4713_get_pilot_deviation(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_PILOT_DEVIATION);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             /* Device returns in 10Hz units */
> > +             sdev->pilot_info.deviation = rval * 10;
> > +     }
> > +
> > +     rval = sdev->pilot_info.deviation;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_get_pilot_frequency(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_PILOT_FREQUENCY);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             sdev->pilot_info.frequency = rval;
> > +     }
> > +
> > +     rval = sdev->pilot_info.frequency;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_get_acomp_enabled(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_ACOMP_ENABLE);
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             sdev->acomp_info.enabled = get_acomp_status(rval);
> > +     }
> > +
> > +     rval = sdev->acomp_info.enabled;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_get_acomp_gain(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_ACOMP_GAIN);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             sdev->acomp_info.gain = rval;
> > +     }
> > +
> > +     rval = sdev->acomp_info.gain;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_get_acomp_threshold(struct si4713_device *sdev, s8 *threshold)
> > +{
> > +     int rval;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_ACOMP_THRESHOLD);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             sdev->acomp_info.threshold = rval;
> > +     }
> > +
> > +     *threshold = sdev->acomp_info.threshold;
> > +     rval = 0;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static long si4713_get_acomp_release_time(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev,
> > +                             SI4713_TX_ACOMP_RELEASE_TIME);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             sdev->acomp_info.release_time = dev_to_usecs(rval,
> > +                                             acomp_rtimes,
> > +                                             ARRAY_SIZE(acomp_rtimes));
> > +     }
> > +
> > +     rval = sdev->acomp_info.release_time;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +
> > +static int si4713_get_acomp_attack_time(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev,
> > +                             SI4713_TX_ACOMP_RELEASE_TIME);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             sdev->acomp_info.attack_time = rval * ATTACK_TIME_UNIT;
> > +     }
> > +
> > +     rval = sdev->acomp_info.attack_time;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +/* not read property */
> > +static int si4713_get_rds_ps_name(struct si4713_device *sdev, char *ps_name)
> > +{
> > +     mutex_lock(&sdev->mutex);
> > +     strncpy(ps_name, sdev->rds_info.ps_name, MAX_RDS_PS_NAME);
> > +     mutex_unlock(&sdev->mutex);
> > +
> > +     return 0;
> > +}
> > +
> > +static int si4713_get_rds_radio_text(struct si4713_device *sdev,
> > +                                                     char *radio_text)
> > +{
> > +     mutex_lock(&sdev->mutex);
> > +     strncpy(radio_text, sdev->rds_info.radio_text, MAX_RDS_RADIO_TEXT);
> > +     mutex_unlock(&sdev->mutex);
> > +
> > +     return 0;
> > +}
> > +
> > +/* setters */
> > +static int si4713_set_power_level(struct si4713_device *sdev, u8 power_level)
> > +{
> > +     int rval;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_tx_tune_power(sdev, power_level,
> > +                                             sdev->antenna_capacitor);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +     }
> > +
> > +     sdev->power_level = power_level;
> > +     rval = 0;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_antenna_capacitor(struct si4713_device *sdev, u8 value)
> > +{
> > +     int rval = 0;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state)
> > +             rval = si4713_tx_tune_power(sdev, sdev->power_level, value);
> > +
> > +     if (!rval)
> > +             sdev->antenna_capacitor = value;
> > +
> > +     mutex_unlock(&sdev->mutex);
> > +
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_power_state(struct si4713_device *sdev, u8 value)
> > +{
> > +     int rval;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (value)
> > +             rval = si4713_powerup(sdev);
> > +     else
> > +             rval = si4713_powerdown(sdev);
> > +
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_frequency(struct si4713_device *sdev, u16 frequency)
> > +{
> > +     int rval = 0;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_tx_tune_freq(sdev, frequency);
> > +             if (rval < 0)
> > +                     goto unlock;
> > +             frequency = rval;
> > +     }
> > +     sdev->frequency = frequency;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_mute(struct si4713_device *sdev, u16 mute)
> > +{
> > +     int rval = 0;
> > +
> > +     mute = set_mute(mute);
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state)
> > +             rval = si4713_write_property(sdev,
> > +                             SI4713_TX_LINE_INPUT_MUTE, mute);
> > +
> > +     if (rval >= 0)
> > +             sdev->mute = get_mute(mute);
> > +
> > +     mutex_unlock(&sdev->mutex);
> > +
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_rds_pi(struct si4713_device *sdev, u16 pi)
> > +{
> > +     int rval = 0;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state)
> > +             rval = si4713_write_property(sdev, SI4713_TX_RDS_PI, pi);
> > +
> > +     if (rval >= 0)
> > +             sdev->rds_info.pi = pi;
> > +
> > +     mutex_unlock(&sdev->mutex);
> > +
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_rds_pty(struct si4713_device *sdev, u8 pty)
> > +{
> > +     int rval = 0;
> > +     u16 p;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_RDS_PS_MISC);
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             p = set_pty(rval, pty);
> > +
> > +             rval = si4713_write_property(sdev, SI4713_TX_RDS_PS_MISC, p);
> > +             if (rval < 0)
> > +                     goto unlock;
> > +     }
> > +
> > +     sdev->rds_info.pty = pty;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_rds_ps_name(struct si4713_device *sdev, char *ps_name)
> > +{
> > +     int rval = 0, i;
> > +     u8 len = 0;
> > +     u8 *tmp;
> > +
> > +     if (!strlen(ps_name))
> > +             return -EINVAL;
> > +
> > +     tmp = kzalloc(MAX_RDS_PS_NAME + 1, GFP_KERNEL);
> > +     if (!tmp)
> > +             return -ENOMEM;
> > +
> > +     strncpy(tmp, ps_name, MAX_RDS_PS_NAME);
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             /* Write the new ps name and clear the padding */
> > +             for (i = 0; i < MAX_RDS_PS_NAME; i += (RDS_BLOCK / 2)) {
> > +                     rval = si4713_tx_rds_ps(sdev, (i / (RDS_BLOCK / 2)),
> > +                                             tmp + i);
> > +                     if (rval < 0)
> > +                             goto unlock;
> > +             }
> > +
> > +             /* Setup the size to be sent */
> > +             len = strlen(tmp) - 1;
> > +
> > +             rval = si4713_write_property(sdev,
> > +                             SI4713_TX_RDS_PS_MESSAGE_COUNT,
> > +                             rds_ps_nblocks(len));
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             rval = si4713_write_property(sdev,
> > +                             SI4713_TX_RDS_PS_REPEAT_COUNT,
> > +                             DEFAULT_RDS_PS_REPEAT_COUNT * 2);
> > +             if (rval < 0)
> > +                     goto unlock;
> > +     }
> > +
> > +     strncpy(sdev->rds_info.ps_name, tmp, MAX_RDS_PS_NAME);
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     kfree(tmp);
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_rds_radio_text(struct si4713_device *sdev,
> > +                                                     char *radio_text)
> > +{
> > +     int rval = 0, i;
> > +     u16 t_index = 0;
> > +     u8 s, a, u, fa, fu, b_index = 0, cr_inserted = 0;
> > +     u8 *tmp;
> > +
> > +     if (!strlen(radio_text))
> > +             return -EINVAL;
> > +
> > +     tmp = kzalloc(MAX_RDS_RADIO_TEXT + 1, GFP_KERNEL);
> > +     if (!tmp)
> > +             return -ENOMEM;
> > +
> > +     strncpy(tmp, radio_text, MAX_RDS_RADIO_TEXT);
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_tx_rds_buff(sdev, RDS_BLOCK_CLEAR, 0, 0, 0,
> > +                                             &s, &a, &u, &fa, &fu);
> > +             if (rval < 0)
> > +                     goto unlock;
> > +             do {
> > +                     /* RDS spec says that if the last block isn't used,
> > +                      * then apply a carriage return
> > +                      */
> > +                     if (t_index < (RDS_RADIOTEXT_INDEX_MAX * \
> > +                             RDS_RADIOTEXT_BLK_SIZE)) {
> > +                             for (i = 0; i < RDS_RADIOTEXT_BLK_SIZE; i++) {
> > +                                     if (!tmp[t_index + i] ||
> > +                                             tmp[t_index + i] == \
> > +                                             RDS_CARRIAGE_RETURN) {
> > +                                             tmp[t_index + i] =
> > +                                                     RDS_CARRIAGE_RETURN;
> > +                                             cr_inserted = 1;
> > +                                             break;
> > +                                     }
> > +                             }
> > +                     }
> > +
> > +                     rval = si4713_tx_rds_buff(sdev, RDS_BLOCK_LOAD,
> > +                                     compose_u16(RDS_RADIOTEXT_2A,
> > +                                             b_index++),
> > +                                     compose_u16(tmp[t_index],
> > +                                             tmp[t_index + 1]),
> > +                                     compose_u16(tmp[t_index + 2],
> > +                                             tmp[t_index + 3]),
> > +                                     &s, &a, &u, &fa, &fu);
> > +                     if (rval < 0)
> > +                             goto unlock;
> > +
> > +                     t_index += RDS_RADIOTEXT_BLK_SIZE;
> > +
> > +                     if (cr_inserted)
> > +                             break;
> > +             } while (u < a);
> > +     }
> > +
> > +     strncpy(sdev->rds_info.radio_text, tmp, MAX_RDS_RADIO_TEXT);
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     kfree(tmp);
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_rds_enabled(struct si4713_device *sdev, u8 enabled)
> > +{
> > +     int rval = 0;
> > +     u16 p;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE);
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             p = rval;
> > +             if (enabled)
> > +                     p = enable_rds(p);
> > +             else
> > +                     p = disable_rds(p);
> > +
> > +             rval = si4713_write_property(sdev, SI4713_TX_COMPONENT_ENABLE,
> > +                             p);
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             if (enabled) {
> > +                     rval = si4713_write_property(sdev,
> > +                             SI4713_TX_RDS_DEVIATION,
> > +                             DEFAULT_RDS_DEVIATION);
> > +                     if (rval < 0)
> > +                             goto unlock;
> > +             }
> > +     }
> > +
> > +     sdev->rds_info.enabled = enabled & 0x01;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_preemphasis(struct si4713_device *sdev, u8 preemphasis)
> > +{
> > +     int rval = 0;
> > +     u8 val;
> > +
> > +     switch (preemphasis) {
> > +     case V4L2_FM_TX_PREEMPHASIS_75_uS:
> > +             val = FMPE_USA;
> > +             break;
> > +     case V4L2_FM_TX_PREEMPHASIS_50_uS:
> > +             val = FMPE_EU;
> > +             break;
> > +     case V4L2_FM_TX_PREEMPHASIS_DISABLED:
> > +             val = FMPE_DISABLED;
> > +             break;
> > +     default:
> > +             return -EINVAL;
> > +     }
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state)
> > +             rval = si4713_write_property(sdev, SI4713_TX_PREEMPHASIS, val);
> > +
> > +     if (rval >= 0)
> > +             sdev->preemphasis = preemphasis;
> > +
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_limiter_enabled(struct si4713_device *sdev, u8 enabled)
> > +{
> > +     int rval = 0;
> > +     u16 p;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_ACOMP_ENABLE);
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             p = rval;
> > +             if (enabled)
> > +                     p = enable_limiter(p);
> > +             else
> > +                     p = disable_limiter(p);
> > +
> > +             rval = si4713_write_property(sdev, SI4713_TX_ACOMP_ENABLE,
> > +                             p);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +     }
> > +
> > +     sdev->limiter_info.enabled = enabled & 0x01;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_limiter_deviation(struct si4713_device *sdev,
> > +                                     unsigned long deviation)
> > +{
> > +     int rval = 0;
> > +
> > +     /* Device receives in 10Hz units */
> > +     deviation /= 10;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state)
> > +             rval = si4713_write_property(sdev, SI4713_TX_AUDIO_DEVIATION,
> > +                                             deviation);
> > +
> > +     /* Device returns in 10Hz units */
> > +     if (rval >= 0)
> > +             sdev->limiter_info.deviation = deviation * 10;
> > +
> > +     mutex_unlock(&sdev->mutex);
> > +
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_limiter_release_time(struct si4713_device *sdev,
> > +                                     unsigned long rtime)
> > +{
> > +     int rval;
> > +
> > +     rval = usecs_to_dev(rtime, limiter_times, ARRAY_SIZE(limiter_times));
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rtime = rval;
> > +     rval = 0;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state)
> > +             rval = si4713_write_property(sdev,
> > +                             SI4713_TX_LIMITER_RELEASE_TIME, rtime);
> > +
> > +     if (rval >= 0)
> > +             sdev->limiter_info.release_time = dev_to_usecs(rtime,
> > +                                             limiter_times,
> > +                                             ARRAY_SIZE(limiter_times));
> > +
> > +     mutex_unlock(&sdev->mutex);
> > +
> > +exit:
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_stereo_enabled(struct si4713_device *sdev, u8 enabled)
> > +{
> > +     int rval = 0;
> > +     u16 p;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE);
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             p = rval;
> > +             if (enabled)
> > +                     p = enable_stereo(p);
> > +             else
> > +                     p = disable_stereo(p);
> > +
> > +             rval = si4713_write_property(sdev, SI4713_TX_COMPONENT_ENABLE,
> > +                             p);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +     }
> > +
> > +     sdev->stereo = enabled & 0x01;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_pilot_enabled(struct si4713_device *sdev, u8 enabled)
> > +{
> > +     int rval = 0;
> > +     u16 p;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE);
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             p = rval;
> > +             if (enabled)
> > +                     p = enable_pilot(p);
> > +             else
> > +                     p = disable_pilot(p);
> > +
> > +             rval = si4713_write_property(sdev, SI4713_TX_COMPONENT_ENABLE,
> > +                             p);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +     }
> > +
> > +     sdev->pilot_info.enabled = enabled & 0x01;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_pilot_deviation(struct si4713_device *sdev,
> > +                                     unsigned long deviation)
> > +{
> > +     int rval = 0;
> > +
> > +     /* Device receives in 10Hz units */
> > +     deviation /= 10;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state)
> > +             rval = si4713_write_property(sdev, SI4713_TX_PILOT_DEVIATION,
> > +                                             deviation);
> > +
> > +     /* Device returns in 10Hz units */
> > +     if (rval >= 0)
> > +             sdev->pilot_info.deviation = deviation * 10;
> > +
> > +     mutex_unlock(&sdev->mutex);
> > +
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_pilot_frequency(struct si4713_device *sdev, u16 freq)
> > +{
> > +     int rval = 0;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state)
> > +             rval = si4713_write_property(sdev, SI4713_TX_PILOT_FREQUENCY,
> > +                                             freq);
> > +
> > +     if (rval >= 0)
> > +             sdev->pilot_info.frequency = freq;
> > +
> > +     mutex_unlock(&sdev->mutex);
> > +
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_acomp_enabled(struct si4713_device *sdev, u8 enabled)
> > +{
> > +     int rval = 0;
> > +     u16 p;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state) {
> > +             rval = si4713_read_property(sdev, SI4713_TX_ACOMP_ENABLE);
> > +             if (rval < 0)
> > +                     goto unlock;
> > +
> > +             p = rval;
> > +             if (enabled)
> > +                     p = enable_acomp(p);
> > +             else
> > +                     p = disable_acomp(p);
> > +
> > +             rval = si4713_write_property(sdev, SI4713_TX_ACOMP_ENABLE, p);
> > +
> > +             if (rval < 0)
> > +                     goto unlock;
> > +     }
> > +
> > +     sdev->acomp_info.enabled = enabled & 0x01;
> > +
> > +unlock:
> > +     mutex_unlock(&sdev->mutex);
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_acomp_gain(struct si4713_device *sdev, u8 gain)
> > +{
> > +     int rval = 0;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state)
> > +             rval = si4713_write_property(sdev, SI4713_TX_ACOMP_GAIN, gain);
> > +
> > +     if (rval >= 0)
> > +             sdev->acomp_info.gain = gain;
> > +
> > +     mutex_unlock(&sdev->mutex);
> > +
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_acomp_threshold(struct si4713_device *sdev, s8 threshold)
> > +{
> > +     int rval = 0;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state)
> > +             rval = si4713_write_property(sdev, SI4713_TX_ACOMP_THRESHOLD,
> > +                                             threshold);
> > +
> > +     if (rval >= 0)
> > +             sdev->acomp_info.threshold = threshold;
> > +
> > +     mutex_unlock(&sdev->mutex);
> > +
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_acomp_release_time(struct si4713_device *sdev,
> > +                                     unsigned long rtime)
> > +{
> > +     int rval;
> > +
> > +     rval = usecs_to_dev(rtime, acomp_rtimes, ARRAY_SIZE(acomp_rtimes));
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rtime = rval;
> > +     rval = 0;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state)
> > +             rval = si4713_write_property(sdev,
> > +                             SI4713_TX_ACOMP_RELEASE_TIME, rtime);
> > +
> > +     if (rval >= 0)
> > +             sdev->acomp_info.release_time = dev_to_usecs(rtime,
> > +                                             acomp_rtimes,
> > +                                             ARRAY_SIZE(acomp_rtimes));
> > +
> > +     mutex_unlock(&sdev->mutex);
> > +
> > +exit:
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_acomp_attack_time(struct si4713_device *sdev, u16 atime)
> > +{
> > +     int rval = 0;
> > +
> > +     /* Device receives in 0.5 ms units */
> > +     atime /= ATTACK_TIME_UNIT;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +
> > +     if (sdev->power_state)
> > +             rval = si4713_write_property(sdev,
> > +                             SI4713_TX_ACOMP_ATTACK_TIME, atime);
> > +
> > +     if (rval >= 0)
> > +             sdev->acomp_info.attack_time = atime * ATTACK_TIME_UNIT;
> > +
> > +     mutex_unlock(&sdev->mutex);
> > +
> > +     return rval;
> > +}
> > +
> > +static int si4713_set_tune_measure(struct si4713_device *sdev, u32 frequency)
> > +{
> > +     int rval = -ENODEV;
> > +
> > +     mutex_lock(&sdev->mutex);
> > +     if (sdev->power_state)
> > +             rval = si4713_tx_tune_measure(sdev, frequency / 10, 0);
> > +     mutex_unlock(&sdev->mutex);
> > +
> > +     return rval;
> > +}
> > +
> > +/*
> > + * si4713_init - Sets the device up with default configuration.
> > + * @sdev: si4713_device structure for the device we are communicating
> > + */
> > +static int si4713_init(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +
> > +     rval = si4713_set_rds_pi(sdev, DEFAULT_RDS_PI);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_rds_pty(sdev, DEFAULT_RDS_PTY);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_rds_ps_name(sdev, DEFAULT_RDS_PS_NAME);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_rds_radio_text(sdev, DEFAULT_RDS_RADIO_TEXT);
> 
> Just for my understanding: is RADIO_TEXT something that is always on? What do
> you do if you have no radio text? Just use the PS_NAME? An empty string?
> 
> This is something that needs to be explained in the v4l2 spec as well.
> 
> Currently DEFAULT_RDS_RADIO_TEXT is the same as DEFAULT_RDS_PS_NAME, but I
> wonder if it shouldn't be an empty string instead (if that's supported).


hmm need to double check. But I think we can disable it by clearing the
rds blocks which is configured into si4713.

> 
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_rds_enabled(sdev, 1);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_limiter_release_time(sdev, DEFAULT_LIMITER_RTIME);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_limiter_deviation(sdev, DEFAULT_LIMITER_DEV);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_limiter_enabled(sdev, 1);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_pilot_frequency(sdev, DEFAULT_PILOT_FREQUENCY);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_pilot_deviation(sdev, DEFAULT_PILOT_DEVIATION);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_pilot_enabled(sdev, 1);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_stereo_enabled(sdev, 1);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_acomp_attack_time(sdev, DEFAULT_ACOMP_ATIME);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_acomp_release_time(sdev, DEFAULT_ACOMP_RTIME);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_acomp_gain(sdev, DEFAULT_ACOMP_GAIN);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_acomp_threshold(sdev, DEFAULT_ACOMP_THRESHOLD);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_acomp_enabled(sdev, 1);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_mute(sdev, DEFAULT_MUTE);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_power_level(sdev, DEFAULT_POWER_LEVEL);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_preemphasis(sdev, V4L2_FM_TX_PREEMPHASIS_50_uS);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +exit:
> > +     return rval;
> > +}
> > +
> > +/*
> > + * si4713_setup - Sets the device up with current configuration.
> > + * @sdev: si4713_device structure for the device we are communicating
> > + */
> > +static int si4713_setup(struct si4713_device *sdev)
> > +{
> > +     struct si4713_device *tmp;
> > +     int rval;
> > +
> > +     tmp = kmalloc(sizeof(*tmp), GFP_KERNEL);
> > +     if (!tmp)
> > +             return -ENOMEM;
> > +
> > +     /* Get a local copy to avoid race */
> > +     mutex_lock(&sdev->mutex);
> > +     memcpy(tmp, sdev, sizeof(*sdev));
> > +     mutex_unlock(&sdev->mutex);
> > +
> > +     rval = si4713_set_rds_pi(sdev, tmp->rds_info.pi);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_rds_pty(sdev, tmp->rds_info.pty);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_rds_ps_name(sdev, tmp->rds_info.ps_name);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_rds_radio_text(sdev, tmp->rds_info.radio_text);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_rds_enabled(sdev, tmp->rds_info.enabled);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_limiter_release_time(sdev,
> > +                             tmp->limiter_info.release_time);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_limiter_deviation(sdev, tmp->limiter_info.deviation);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_limiter_enabled(sdev, tmp->limiter_info.enabled);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_pilot_frequency(sdev, tmp->pilot_info.frequency);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_pilot_deviation(sdev, tmp->pilot_info.deviation);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_pilot_enabled(sdev, tmp->pilot_info.enabled);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_stereo_enabled(sdev, tmp->stereo);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_acomp_attack_time(sdev, tmp->acomp_info.attack_time);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_acomp_release_time(sdev,
> > +                                             tmp->acomp_info.release_time);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_acomp_gain(sdev, tmp->acomp_info.gain);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_acomp_threshold(sdev, tmp->acomp_info.threshold);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_acomp_enabled(sdev, tmp->acomp_info.enabled);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_mute(sdev, tmp->mute);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_preemphasis(sdev, tmp->preemphasis);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_frequency(sdev, tmp->frequency ? tmp->frequency :
> > +                                     DEFAULT_FREQUENCY);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_power_level(sdev, tmp->power_level ?
> > +                                     tmp->power_level :
> > +                                     DEFAULT_POWER_LEVEL);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_antenna_capacitor(sdev, tmp->antenna_capacitor);
> > +
> > +exit:
> > +     kfree(tmp);
> > +     return rval;
> > +}
> > +
> > +static int si4713_probe(struct si4713_device *sdev)
> > +{
> > +     int rval;
> > +
> > +     rval = si4713_set_power_state(sdev, POWER_ON);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_checkrev(sdev);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_set_power_state(sdev, POWER_OFF);
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     rval = si4713_init(sdev);
> > +
> > +exit:
> > +     return rval;
> > +}
> > +
> > +static int si4713_write_econtrol(struct si4713_device *sdev,
> > +                                     struct v4l2_ext_control *control)
> > +{
> > +     char ps_name[MAX_RDS_PS_NAME + 1];
> > +     char radio_text[MAX_RDS_RADIO_TEXT + 1];
> > +     int size;
> > +     s32 rval = 0;
> > +
> > +     switch (control->id) {
> > +     /* User class controls */
> > +     case V4L2_CID_AUDIO_MUTE:
> > +             rval = si4713_set_mute(sdev, control->value);
> > +             break;
> > +     /* FM_TX 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;
> > +     case V4L2_CID_RDS_PS_NAME:
> > +             size = control->length > MAX_RDS_PS_NAME ? MAX_RDS_PS_NAME :
> > +                                                             control->length;
> > +             rval = copy_from_user(ps_name, control->string, size + 1);
> > +             if (rval < 0)
> > +                     goto exit;
> > +             rval = si4713_set_rds_ps_name(sdev, ps_name);
> > +             goto exit;
> > +     case V4L2_CID_RDS_RADIO_TEXT:
> > +             size = control->length > MAX_RDS_RADIO_TEXT ?
> > +                                     MAX_RDS_RADIO_TEXT : control->length;
> > +             rval = copy_from_user(radio_text, control->string, size + 1);
> 
> No, control->length is the total size of the memory block so you should
> probably set size to 'control->length - 1' and check against
> 'control->length > MAX_RDS_RADIO_TEXT + 1'.
> 
> The same issue is true for the PS_NAME control above.

Yeah, I've messed thing here.

> 
> > +             if (rval < 0)
> > +                     goto exit;
> > +             rval = si4713_set_rds_radio_text(sdev, radio_text);
> > +             goto exit;
> > +
> > +     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_PREEMPHASIS:
> > +             rval = si4713_set_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;
> > +     }
> > +
> > +exit:
> > +     return rval;
> > +}
> > +
> > +static int si4713_read_econtrol(struct si4713_device *sdev,
> > +                             struct v4l2_ext_control *control)
> > +{
> > +     s32 rval = 0;
> > +     s8 val = 0;
> > +     char ps_name[MAX_RDS_PS_NAME + 1];
> > +     char radio_text[MAX_RDS_RADIO_TEXT + 1];
> > +
> > +     switch (control->id) {
> > +     /* User class controls */
> > +     case V4L2_CID_AUDIO_MUTE:
> > +             rval = si4713_get_mute(sdev);
> > +             break;
> > +     /* FM_TX 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;
> > +
> > +     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)
> > +                     control->value = val;
> > +             /* We can have negative value, so return earlier */
> > +             goto exit;
> > +     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_PREEMPHASIS:
> > +             rval = si4713_get_preemphasis(sdev);
> > +             break;
> > +
> > +     /* here we do not use read property */
> > +     case V4L2_CID_RDS_PS_NAME:
> > +             rval = si4713_get_rds_ps_name(sdev, ps_name);
> > +             if (rval < 0)
> > +                     goto exit;
> > +             rval = copy_to_user(control->string, ps_name,
> > +                                                     strlen(ps_name) + 1);
> > +             control->length = strlen(ps_name);
> 
> No, this isn't right either. The caller allocates the memory and sets up the
> control->length. So you have to check whether the result fits in the available
> space and return an error if it doesn't. And control->length is the total size
> of the allocated memory, including terminating zeroes.
> 
> Currently my string control implementation doesn't say anything about how to
> detect the right length, that's something I need to think about. As I mentioned
> earlier the string control support was put together rather quickly and needs
> more time.

here too.

> 
> > +             goto exit;
> > +     case V4L2_CID_RDS_RADIO_TEXT:
> > +             rval = si4713_get_rds_radio_text(sdev, radio_text);
> > +             if (rval < 0)
> > +                     goto exit;
> > +             rval = copy_to_user(control->string, radio_text,
> > +                                                     strlen(radio_text) + 1);
> > +             control->length = strlen(radio_text);
> > +             goto exit;
> > +
> > +     /* here we use tx tune status */
> > +     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;
> > +     };
> > +
> > +     if (rval >= 0) {
> > +             control->value = rval;
> > +             rval = 0;
> > +     }
> > +
> > +exit:
> > +     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_FM_TX)
> > +             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_FM_TX)
> > +             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 */
> > +     case V4L2_CID_AUDIO_MUTE:
> > +             rval = v4l2_ctrl_query_fill(qc, 0, 1, 1, DEFAULT_MUTE);
> > +             break;
> > +     /* FM_TX 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_PREEMPHASIS:
> > +             rval = v4l2_ctrl_query_fill(qc, V4L2_FM_TX_PREEMPHASIS_DISABLED,
> > +                                             V4L2_FM_TX_PREEMPHASIS_75_uS, 1,
> > +                                             V4L2_FM_TX_PREEMPHASIS_50_uS);
> > +             break;
> > +     case V4L2_CID_TUNE_POWER_LEVEL:
> > +             rval = v4l2_ctrl_query_fill(qc, 0, 120, 1, DEFAULT_POWER_LEVEL);
> > +             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;
> > +                     rval = 0;
> > +             }
> > +             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 = {
> > +     .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,
> > +};
> > +
> > +/*
> > + * si4713_g_modulator - get modulator attributes
> > + */
> > +static int si4713_g_modulator(struct v4l2_subdev *sd, struct v4l2_modulator *vm)
> > +{
> > +     struct si4713_device *sdev = to_si4713_device(sd);
> > +     int rval;
> > +
> > +     if (!sdev) {
> > +             rval = -ENODEV;
> > +             goto exit;
> > +     }
> > +
> > +     if (vm->index > 0) {
> > +             rval = -EINVAL;
> > +             goto exit;
> > +     }
> > +
> > +     strncpy(vm->name, "FM Modulator", 32);
> > +     vm->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LOW;
> > +
> > +     /* Report current frequency range limits */
> > +     vm->rangelow = si4713_to_v4l2(7600);
> > +     vm->rangehigh = si4713_to_v4l2(10800);
> > +
> > +     /* Report current audio mode: mono or stereo */
> > +     vm->txsubchans = V4L2_TUNER_SUB_MONO;
> > +     rval = si4713_get_stereo_enabled(sdev);
> > +     if (rval < 0)
> > +             goto exit;
> > +     if (rval)
> > +             vm->txsubchans |= V4L2_TUNER_SUB_STEREO;
> 
> This isn't right. It should be either SUB_MONO or SUB_STEREO. It tells the
> application the current modulation.

Ok. Will fix that.


> 
> > +
> > +     /* TODO: Report current signal length */
> > +
> > +     rval = 0;
> > +exit:
> > +     return rval;
> > +}
> > +
> > +/*
> > + * si4713_s_modulator - set modulator attributes
> > + */
> > +static int si4713_s_modulator(struct v4l2_subdev *sd, struct v4l2_modulator *vm)
> > +{
> > +     struct si4713_device *sdev = to_si4713_device(sd);
> > +     int rval;
> > +
> > +     if (!sdev) {
> > +             rval = -ENODEV;
> > +             goto exit;
> > +     }
> > +
> > +     if (vm->index > 0) {
> > +             rval = -EINVAL;
> > +             goto exit;
> > +     }
> > +
> > +     /* Set audio mode: mono or stereo */
> > +     rval = si4713_set_stereo_enabled(sdev,
> > +                             !!(vm->txsubchans & V4L2_TUNER_SUB_STEREO));
> 
> There are only two valid txsubchans values: SUB_MONO or SUB_STEREO. I suggest
> that you check explicitly for these values and return an -EINVAL error if
> you get something else.

yeah. wil fix it.

> 
> > +     if (rval < 0)
> > +             goto exit;
> > +
> > +     /* TODO: How to set frequency to measure current signal length */
> 
> Huh? I don't understand this TODO.

The todo is about the property this device had, to report signal length
of a freq. It used to work like: user echoes the freq on sysfs entry.
when reading the same entry, it reports the signal noise there.

This is something which I still don't know the proper place to put.

I thought in another ext control. But I don't know if this fix into
the fm tx controls. Maybe I should use a private one ?

> 
> > +
> > +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 = si4713_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;
> > +
> > +     rval = si4713_set_frequency(sdev, v4l2_to_si4713(f->frequency));
> > +     if (rval > 0) {
> > +             f->frequency = si4713_to_v4l2(rval);
> > +             rval = 0;
> > +     }
> > +
> > +     return rval;
> > +}
> > +
> > +static const struct v4l2_subdev_tuner_ops si4713_subdev_tuner_ops = {
> > +     .g_frequency    = si4713_g_frequency,
> > +     .s_frequency    = si4713_s_frequency,
> > +     .g_modulator    = si4713_g_modulator,
> > +     .s_modulator    = si4713_s_modulator,
> > +};
> > +
> > +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)
> 
> Misnomer: just call this si4713_probe. This isn't driver initialization,
> this probes for a si4713 on an i2c adapter.

right.

> 
> > +{
> > +     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);
> 
> When the subdev was found, then the driver should print this message:
> 
>         v4l2_info(&sdev->sd, "chip found @ 0x%02x (%s)\n",
>                         client->addr << 1, client->adapter->name);
> 
> Since this shows up in the kernel log it is very useful for debugging as it
> tells you which i2c devices were found. All v4l i2c drivers do this.

yes, will use this.

> 
> > +
> > +     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");
> 
> typo: configure -> configured

ok.

> 
> > +     }
> > +
> > +     rval = si4713_probe(sdev);
> > +     if (rval < 0) {
> > +             dev_err(&client->dev, "Failed to probe device information.\n");
> > +             goto free_irq;
> > +     }
> > +
> > +     return 0;
> > +
> > +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)
> 
> Also a misnomer: si4713_remove is the correct name. You can't use __exit
> here since this doesn't exit the driver, it is just called when the adapter
> is removed.

yes.

> 
> > +{
> > +     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;
> 
> This can never happen.
> 
> > +     if (sdev) {
> 
> sdev is never NULL.

true. removing.

> 
> > +             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 i2c_driver si4713_i2c_driver = {
> > +     .driver         = {
> > +             .name   = "si4713",
> > +     },
> > +     .probe          = si4713_i2c_driver_probe,
> > +     .remove         = __exit_p(si4713_i2c_driver_remove),
> 
> Remove __exit_p.

yup

> 
> > +     .id_table       = si4713_id,
> > +};
> > +
> > +/*
> > + * Module Interface
> > + */
> > +static int __init si4713_module_init(void)
> > +{
> > +     return i2c_add_driver(&si4713_i2c_driver);
> > +}
> > +
> > +static void __exit si4713_module_exit(void)
> > +{
> > +     i2c_del_driver(&si4713_i2c_driver);
> > +}
> > +
> > +module_init(si4713_module_init);
> > +module_exit(si4713_module_exit);
> > +
> > +MODULE_LICENSE("GPL");
> > +MODULE_AUTHOR("Eduardo Valentin <eduardo.valentin@nokia.com>");
> > +MODULE_DESCRIPTION("I2C driver for Si4713 FM Radio Transmitter");
> > +MODULE_VERSION("0.0.1");
> 
> I recommend moving these MODULE macros to the top of the source. This is
> top-level information so it is good to see this immediately when you open
> the source code for the first time.

Right. Will move this to top file. Will put on top the module parameter for
debug level as well.

> 
> > +
> > diff --git a/linux/drivers/media/radio/si4713-i2c.h b/linux/drivers/media/radio/si4713-i2c.h
> > new file mode 100644
> > index 0000000..d3c9259
> > --- /dev/null
> > +++ b/linux/drivers/media/radio/si4713-i2c.h
> > @@ -0,0 +1,226 @@
> > +/*
> > + * drivers/media/radio/si4713-i2c.h
> > + *
> > + * Property and commands definitions for Si4713 radio transmitter chip.
> > + *
> > + * Copyright (c) 2008 Instituto Nokia de Tecnologia - INdT
> > + * Contact: Eduardo Valentin <eduardo.valentin@nokia.com>
> > + *
> > + * This file is licensed under the terms of the GNU General Public License
> > + * version 2. This program is licensed "as is" without any warranty of any
> > + * kind, whether express or implied.
> > + *
> > + */
> > +
> > +#ifndef SI4713_I2C_H
> > +#define SI4713_I2C_H
> > +
> > +#include <media/v4l2-subdev.h>
> > +#include <media/si4713.h>
> > +
> > +#define SI4713_PRODUCT_NUMBER                0x0D
> > +
> > +/* Command Timeouts */
> > +#define DEFAULT_TIMEOUT                      500
> > +#define TIMEOUT_SET_PROPERTY         20
> > +#define TIMEOUT_TX_TUNE_POWER                30000
> > +#define TIMEOUT_TX_TUNE                      110000
> > +#define TIMEOUT_POWER_UP             200000
> > +
> > +/*
> > + * Command and its arguments definitions
> > + */
> > +#define SI4713_PWUP_CTSIEN           (1<<7)
> > +#define SI4713_PWUP_GPO2OEN          (1<<6)
> > +#define SI4713_PWUP_PATCH            (1<<5)
> > +#define SI4713_PWUP_XOSCEN           (1<<4)
> > +#define SI4713_PWUP_FUNC_TX          0x02
> > +#define SI4713_PWUP_FUNC_PATCH               0x0F
> > +#define SI4713_PWUP_OPMOD_ANALOG     0x50
> > +#define SI4713_PWUP_OPMOD_DIGITAL    0x0F
> > +#define SI4713_PWUP_NARGS            2
> > +#define SI4713_PWUP_NRESP            1
> > +#define SI4713_CMD_POWER_UP          0x01
> > +
> > +#define SI4713_GETREV_NRESP          9
> > +#define SI4713_CMD_GET_REV           0x10
> > +
> > +#define SI4713_PWDN_NRESP            1
> > +#define SI4713_CMD_POWER_DOWN                0x11
> > +
> > +#define SI4713_SET_PROP_NARGS                5
> > +#define SI4713_SET_PROP_NRESP                1
> > +#define SI4713_CMD_SET_PROPERTY              0x12
> > +
> > +#define SI4713_GET_PROP_NARGS                3
> > +#define SI4713_GET_PROP_NRESP                4
> > +#define SI4713_CMD_GET_PROPERTY              0x13
> > +
> > +#define SI4713_GET_STATUS_NRESP              1
> > +#define SI4713_CMD_GET_INT_STATUS    0x14
> > +
> > +#define SI4713_CMD_PATCH_ARGS                0x15
> > +#define SI4713_CMD_PATCH_DATA                0x16
> > +
> > +#define SI4713_MAX_FREQ                      10800
> > +#define SI4713_MIN_FREQ                      7600
> > +#define SI4713_TXFREQ_NARGS          3
> > +#define SI4713_TXFREQ_NRESP          1
> > +#define SI4713_CMD_TX_TUNE_FREQ              0x30
> > +
> > +#define SI4713_MAX_POWER             120
> > +#define SI4713_MIN_POWER             88
> > +#define SI4713_MAX_ANTCAP            191
> > +#define SI4713_MIN_ANTCAP            0
> > +#define SI4713_TXPWR_NARGS           4
> > +#define SI4713_TXPWR_NRESP           1
> > +#define SI4713_CMD_TX_TUNE_POWER     0x31
> > +
> > +#define SI4713_TXMEA_NARGS           4
> > +#define SI4713_TXMEA_NRESP           1
> > +#define SI4713_CMD_TX_TUNE_MEASURE   0x32
> > +
> > +#define SI4713_INTACK_MASK           0x01
> > +#define SI4713_TXSTATUS_NARGS                1
> > +#define SI4713_TXSTATUS_NRESP                8
> > +#define SI4713_CMD_TX_TUNE_STATUS    0x33
> > +
> > +#define SI4713_OVERMOD_BIT           (1 << 2)
> > +#define SI4713_IALH_BIT                      (1 << 1)
> > +#define SI4713_IALL_BIT                      (1 << 0)
> > +#define SI4713_ASQSTATUS_NARGS               1
> > +#define SI4713_ASQSTATUS_NRESP               5
> > +#define SI4713_CMD_TX_ASQ_STATUS     0x34
> > +
> > +#define SI4713_RDSBUFF_MODE_MASK     0x87
> > +#define SI4713_RDSBUFF_NARGS         7
> > +#define SI4713_RDSBUFF_NRESP         6
> > +#define SI4713_CMD_TX_RDS_BUFF               0x35
> > +
> > +#define SI4713_RDSPS_PSID_MASK               0x1F
> > +#define SI4713_RDSPS_NARGS           5
> > +#define SI4713_RDSPS_NRESP           1
> > +#define SI4713_CMD_TX_RDS_PS         0x36
> > +
> > +#define SI4713_CMD_GPO_CTL           0x80
> > +#define SI4713_CMD_GPO_SET           0x81
> > +
> > +/*
> > + * Bits from status response
> > + */
> > +#define SI4713_CTS                   (1<<7)
> > +#define SI4713_ERR                   (1<<6)
> > +#define SI4713_RDS_INT                       (1<<2)
> > +#define SI4713_ASQ_INT                       (1<<1)
> > +#define SI4713_STC_INT                       (1<<0)
> > +
> > +/*
> > + * Property definitions
> > + */
> > +#define SI4713_GPO_IEN                       0x0001
> > +#define SI4713_DIG_INPUT_FORMAT              0x0101
> > +#define SI4713_DIG_INPUT_SAMPLE_RATE 0x0103
> > +#define SI4713_REFCLK_FREQ           0x0201
> > +#define SI4713_REFCLK_PRESCALE               0x0202
> > +#define SI4713_TX_COMPONENT_ENABLE   0x2100
> > +#define SI4713_TX_AUDIO_DEVIATION    0x2101
> > +#define SI4713_TX_PILOT_DEVIATION    0x2102
> > +#define SI4713_TX_RDS_DEVIATION              0x2103
> > +#define SI4713_TX_LINE_INPUT_LEVEL   0x2104
> > +#define SI4713_TX_LINE_INPUT_MUTE    0x2105
> > +#define SI4713_TX_PREEMPHASIS                0x2106
> > +#define SI4713_TX_PILOT_FREQUENCY    0x2107
> > +#define SI4713_TX_ACOMP_ENABLE               0x2200
> > +#define SI4713_TX_ACOMP_THRESHOLD    0x2201
> > +#define SI4713_TX_ACOMP_ATTACK_TIME  0x2202
> > +#define SI4713_TX_ACOMP_RELEASE_TIME 0x2203
> > +#define SI4713_TX_ACOMP_GAIN         0x2204
> > +#define SI4713_TX_LIMITER_RELEASE_TIME       0x2205
> > +#define SI4713_TX_ASQ_INTERRUPT_SOURCE       0x2300
> > +#define SI4713_TX_ASQ_LEVEL_LOW              0x2301
> > +#define SI4713_TX_ASQ_DURATION_LOW   0x2302
> > +#define SI4713_TX_ASQ_LEVEL_HIGH     0x2303
> > +#define SI4713_TX_ASQ_DURATION_HIGH  0x2304
> > +#define SI4713_TX_RDS_INTERRUPT_SOURCE       0x2C00
> > +#define SI4713_TX_RDS_PI             0x2C01
> > +#define SI4713_TX_RDS_PS_MIX         0x2C02
> > +#define SI4713_TX_RDS_PS_MISC                0x2C03
> > +#define SI4713_TX_RDS_PS_REPEAT_COUNT        0x2C04
> > +#define SI4713_TX_RDS_PS_MESSAGE_COUNT       0x2C05
> > +#define SI4713_TX_RDS_PS_AF          0x2C06
> > +#define SI4713_TX_RDS_FIFO_SIZE              0x2C07
> > +
> > +#define PREEMPHASIS_USA                      75
> > +#define PREEMPHASIS_EU                       50
> > +#define PREEMPHASIS_DISABLED         0
> > +#define FMPE_USA                     0x00
> > +#define FMPE_EU                              0x01
> > +#define FMPE_DISABLED                        0x02
> > +
> > +#define POWER_UP                     0x01
> > +#define POWER_DOWN                   0x00
> > +
> > +struct rds_info {
> > +     u16 pi;
> > +#define MAX_RDS_PTY                  31
> > +     u8 pty;
> > +#define MAX_RDS_PS_NAME                      96
> > +     u8 ps_name[MAX_RDS_PS_NAME + 1];
> > +#define MAX_RDS_RADIO_TEXT           384
> > +     u8 radio_text[MAX_RDS_RADIO_TEXT + 1];
> > +     u8 enabled;
> > +};
> > +
> > +struct limiter_info {
> > +#define MAX_LIMITER_RELEASE_TIME     102390
> > +     unsigned long release_time;
> > +#define MAX_LIMITER_DEVIATION                90000
> > +     unsigned long deviation;
> > +     u8 enabled;
> > +};
> > +
> > +struct pilot_info {
> > +#define MAX_PILOT_DEVIATION          90000
> > +     unsigned long deviation;
> > +#define MAX_PILOT_FREQUENCY          19000
> > +     u16 frequency;
> > +     u8 enabled;
> > +};
> > +
> > +struct acomp_info {
> > +#define MAX_ACOMP_RELEASE_TIME               1000000
> > +     unsigned long release_time;
> > +#define MAX_ACOMP_ATTACK_TIME                5000
> > +     u16 attack_time;
> > +#define MAX_ACOMP_THRESHOLD          0
> > +#define MIN_ACOMP_THRESHOLD          (-40)
> > +     s8 threshold;
> > +#define MAX_ACOMP_GAIN                       20
> > +     u8 gain;
> > +     u8 enabled;
> > +};
> > +
> > +/*
> > + * si4713_device - private data
> > + */
> > +struct si4713_device {
> > +     /* v4l2_subdev and i2c reference (v4l2_subdev priv data) */
> > +     struct v4l2_subdev sd;
> > +     /* private data structures */
> > +     struct mutex mutex;
> > +     struct completion work;
> > +     struct si4713_platform_data *platform_data;
> > +     struct rds_info rds_info;
> > +     struct limiter_info limiter_info;
> > +     struct pilot_info pilot_info;
> > +     struct acomp_info acomp_info;
> > +     u16 frequency;
> > +     u8 preemphasis;
> > +     u8 mute;
> > +     u8 power_level;
> > +     u8 power_state;
> > +     u8 antenna_capacitor;
> > +     u8 stereo;
> > +     u8 tune_rssi;
> > +};
> > +#endif /* ifndef SI4713_I2C_H */
> 
> Regards,
> 
>         Hans
> 
> --
> Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom

-- 
Eduardo Valentin

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 0/9] FM Transmitter (si4713) and another changes
  2009-06-16 11:01     ` Hans Verkuil
@ 2009-06-16 11:07       ` Eduardo Valentin
  2009-06-18  6:34         ` Hans Verkuil
  0 siblings, 1 reply; 33+ messages in thread
From: Eduardo Valentin @ 2009-06-16 11:07 UTC (permalink / raw)
  To: ext Hans Verkuil
  Cc: Valentin Eduardo (Nokia-D/Helsinki),
	ext Mauro Carvalho Chehab, Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

On Tue, Jun 16, 2009 at 01:01:51PM +0200, ext Hans Verkuil wrote:
> On Tuesday 16 June 2009 12:47:14 Eduardo Valentin wrote:
> > Hi Hans,
> >
> > On Sun, Jun 14, 2009 at 01:37:20PM +0200, ext Hans Verkuil wrote:
> 
> <snip>
> 
> > > I think the refactoring should be done first. I don't believe it is
> > > that much work and experience shows that it is better to do this right
> > > away while you are still motivated :-)
> >
> > hehehe.. Yes, that's what I was expecting :-). No problem. I've started
> > it. I will resend the series once I've completed the re-factoring and I
> > 've made some testing after that. I hope tomorrow or so.
> >
> > > The string control support should not go into 2.6.31. I would like to
> > > do that only in the v4l-dvb tree (so it will appear in 2.6.32) since I
> > > want to give that a bit more time to mature. I implemented it very
> > > quickly and I do not feel comfortable queueing this for 2.6.31.
> >
> > Right. Yes, better to test the stuff a bit more.
> >
> > > In addition it is still unclear if Mauro will merge my v4l-dvb-subdev2
> > > tree for 2.6.31. I hope so, since otherwise it will hamper the
> > > development of this and other embedded platforms.
> >
> > Ok.
> >
> > > I also need to add a new V4L2_CAP_MODULATOR (which needs a review as
> > > well).
> > >
> > > And finally I realized that we need to add some v4l2_modulator
> > > capabilities for the RDS encoder similar to the upcoming v4l2_tuner RDS
> > > capabilities as is described in this RFC:
> > >
> > > http://www.mail-archive.com/linux-media%40vger.kernel.org/msg02498.html
> > >
> > > I haven't had time to implement this RFC and I know that is not going
> > > to make 2.6.31. It's now almost at the top of my TODO list, so it
> > > should go in soon (pending unforeseen circumstances).
> >
> > Ok. I'll take a look at it.
> 
> I've worked on this yesterday. You can take a look at my v4l-dvb-rds tree. 
> Both the API and the documentation of it in the v4l2-spec is in there. I 
> started work on updating the few RDS decoders that we have, but that is not 
> yet in that tree.
> 
> > > As a result of rereading this RFC I also started to wonder about
> > > whether the si4713 supports the MMBS functionality. Do you know
> > > anything about that?
> >
> > No. Not that I know. Can you point some link?
> 
> http://www.rds.org.uk/rdsfrdsrbds.html
> 
> But I've just read here:
> 
> http://www.rds.org.uk/rds98/pdf/rdsForum_standards_090414_8.pdf
> 
> that MMBS is discontinued. I'll need to investigate this further, but if 
> this is indeed true then this can be removed completely from our RDS 
> decoder and encoder APIs.

Yes, better to double check. At least with si4713, I haven't heard anything about this.

> 
> Regards,
> 
> 	Hans
> 
> 
> 
> -- 
> Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom

-- 
Eduardo Valentin

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 2/9] v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX controls
  2009-06-16 10:52             ` Eduardo Valentin
@ 2009-06-16 11:18               ` Hans Verkuil
  2009-06-16 11:51                 ` Eduardo Valentin
  2009-06-16 18:06               ` Trent Piepho
  1 sibling, 1 reply; 33+ messages in thread
From: Hans Verkuil @ 2009-06-16 11:18 UTC (permalink / raw)
  To: eduardo.valentin
  Cc: Trent Piepho, Eduardo Valentin, ext Mauro Carvalho Chehab,
	Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

On Tuesday 16 June 2009 12:52:34 Eduardo Valentin wrote:
> > It is my believe that the other fm_tx controls are unambiguously
> > transmitter related, so I don't think they need a TX prefix. It doesn't
> > hurt if someone can double check that, though.
>
> hmm.. I see no problem removing the fmtx prefix of the preemphasis
> enum. But, if it is becoming a generic enum, better to check if its
> meaning is the same of existing emphasis enum for mpeg.

It has the same meaning, but unfortunately the mpeg enum is already a public 
API and so cannot be changed. I never realized at the time that that enum 
is more generic than I thought.

But at least this enum can be made generic.

Regards,

	Hans

-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 7/9] FMTx: si4713: Add files to handle si4713 i2c device
  2009-06-16 11:06                 ` Eduardo Valentin
@ 2009-06-16 11:22                   ` Hans Verkuil
  2009-06-16 11:30                     ` Eero Nurkkala
  0 siblings, 1 reply; 33+ messages in thread
From: Hans Verkuil @ 2009-06-16 11:22 UTC (permalink / raw)
  To: eduardo.valentin
  Cc: ext Mauro Carvalho Chehab, Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

On Tuesday 16 June 2009 13:06:09 Eduardo Valentin wrote:
> On Sun, Jun 14, 2009 at 02:31:55PM +0200, ext Hans Verkuil wrote:
> > > +     if (rval < 0)
> > > +             goto exit;
> > > +
> > > +     /* TODO: How to set frequency to measure current signal length
> > > */
> >
> > Huh? I don't understand this TODO.
>
> The todo is about the property this device had, to report signal length

'signal length' or 'signal strength'? If it is the former, then I don't 
understand what you mean with that term.

> of a freq. It used to work like: user echoes the freq on sysfs entry.
> when reading the same entry, it reports the signal noise there.
>
> This is something which I still don't know the proper place to put.
>
> I thought in another ext control. But I don't know if this fix into
> the fm tx controls. Maybe I should use a private one ?

I need to understand this better first.

Regards,

	Hans

-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 7/9] FMTx: si4713: Add files to handle si4713 i2c device
  2009-06-16 11:22                   ` Hans Verkuil
@ 2009-06-16 11:30                     ` Eero Nurkkala
  2009-06-16 11:50                       ` Eduardo Valentin
  0 siblings, 1 reply; 33+ messages in thread
From: Eero Nurkkala @ 2009-06-16 11:30 UTC (permalink / raw)
  To: ext Hans Verkuil
  Cc: Valentin Eduardo (Nokia-D/Helsinki),
	ext Mauro Carvalho Chehab, Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

On Tue, 2009-06-16 at 13:22 +0200, ext Hans Verkuil wrote:
> On Tuesday 16 June 2009 13:06:09 Eduardo Valentin wrote:
> > On Sun, Jun 14, 2009 at 02:31:55PM +0200, ext Hans Verkuil wrote:
> > > > +     if (rval < 0)
> > > > +             goto exit;
> > > > +
> > > > +     /* TODO: How to set frequency to measure current signal length
> > > > */
> > >
> > > Huh? I don't understand this TODO.
> >
> > The todo is about the property this device had, to report signal length
> 
> 'signal length' or 'signal strength'? If it is the former, then I don't 
> understand what you mean with that term.
> 
> > of a freq. It used to work like: user echoes the freq on sysfs entry.
> > when reading the same entry, it reports the signal noise there.
> >
> > This is something which I still don't know the proper place to put.
> >
> > I thought in another ext control. But I don't know if this fix into
> > the fm tx controls. Maybe I should use a private one ?
> 
> I need to understand this better first.
> 
> Regards,
> 
> 	Hans
> 

Transmitter turns into a receiver and measures the RSSI level of
the frequency. If it's high (< -90 -100dB), it's probably not a good
idea to transmit any on such frequency as the interference is too great.

- Eero


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 7/9] FMTx: si4713: Add files to handle si4713 i2c device
  2009-06-16 11:30                     ` Eero Nurkkala
@ 2009-06-16 11:50                       ` Eduardo Valentin
  2009-06-16 12:05                         ` Eero Nurkkala
  0 siblings, 1 reply; 33+ messages in thread
From: Eduardo Valentin @ 2009-06-16 11:50 UTC (permalink / raw)
  To: Nurkkala Eero.An (EXT-Offcode/Oulu)
  Cc: ext Hans Verkuil, Valentin Eduardo (Nokia-D/Helsinki),
	ext Mauro Carvalho Chehab, Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

On Tue, Jun 16, 2009 at 01:30:08PM +0200, Nurkkala Eero.An (EXT-Offcode/Oulu) wrote:
> On Tue, 2009-06-16 at 13:22 +0200, ext Hans Verkuil wrote:
> > On Tuesday 16 June 2009 13:06:09 Eduardo Valentin wrote:
> > > On Sun, Jun 14, 2009 at 02:31:55PM +0200, ext Hans Verkuil wrote:
> > > > > +     if (rval < 0)
> > > > > +             goto exit;
> > > > > +
> > > > > +     /* TODO: How to set frequency to measure current signal length
> > > > > */
> > > >
> > > > Huh? I don't understand this TODO.
> > >
> > > The todo is about the property this device had, to report signal length
> > 
> > 'signal length' or 'signal strength'? If it is the former, then I don't 
> > understand what you mean with that term.
> > 
> > > of a freq. It used to work like: user echoes the freq on sysfs entry.
> > > when reading the same entry, it reports the signal noise there.
> > >
> > > This is something which I still don't know the proper place to put.
> > >
> > > I thought in another ext control. But I don't know if this fix into
> > > the fm tx controls. Maybe I should use a private one ?
> > 
> > I need to understand this better first.
> > 
> > Regards,
> > 
> > 	Hans
> > 
> 
> Transmitter turns into a receiver and measures the RSSI level of
> the frequency. If it's high (< -90 -100dB), it's probably not a good
> idea to transmit any on such frequency as the interference is too great.

Yes, sorry I've made some really bad phrasing. It is Strength. It is a
feature to measure Received Signal Strength Indication (RSSI). As mentioned
by Eero, it's not a good idea to transmit any on freq which the measurement is being done.

> 
> - Eero

-- 
Eduardo Valentin

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 2/9] v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX controls
  2009-06-16 11:18               ` Hans Verkuil
@ 2009-06-16 11:51                 ` Eduardo Valentin
  0 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2009-06-16 11:51 UTC (permalink / raw)
  To: ext Hans Verkuil
  Cc: Valentin Eduardo (Nokia-D/Helsinki),
	Trent Piepho, Eduardo Valentin, ext Mauro Carvalho Chehab,
	Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

On Tue, Jun 16, 2009 at 01:18:57PM +0200, ext Hans Verkuil wrote:
> On Tuesday 16 June 2009 12:52:34 Eduardo Valentin wrote:
> > > It is my believe that the other fm_tx controls are unambiguously
> > > transmitter related, so I don't think they need a TX prefix. It doesn't
> > > hurt if someone can double check that, though.
> >
> > hmm.. I see no problem removing the fmtx prefix of the preemphasis
> > enum. But, if it is becoming a generic enum, better to check if its
> > meaning is the same of existing emphasis enum for mpeg.
> 
> It has the same meaning, but unfortunately the mpeg enum is already a public 
> API and so cannot be changed. I never realized at the time that that enum 
> is more generic than I thought.
> 
> But at least this enum can be made generic.

Yes, sure.

> 
> Regards,
> 
> 	Hans
> 
> -- 
> Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Eduardo Valentin

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 7/9] FMTx: si4713: Add files to handle si4713 i2c device
  2009-06-16 11:50                       ` Eduardo Valentin
@ 2009-06-16 12:05                         ` Eero Nurkkala
  0 siblings, 0 replies; 33+ messages in thread
From: Eero Nurkkala @ 2009-06-16 12:05 UTC (permalink / raw)
  To: Valentin Eduardo (Nokia-D/Helsinki)
  Cc: ext Hans Verkuil, ext Mauro Carvalho Chehab,
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

On Tue, 2009-06-16 at 13:50 +0200, Valentin Eduardo (Nokia-D/Helsinki) wrote:

> 
> Yes, sorry I've made some really bad phrasing. It is Strength. It is a
> feature to measure Received Signal Strength Indication (RSSI). As mentioned
> by Eero, it's not a good idea to transmit any on freq which the measurement is being done.
> 

It can't transmit any while this measuring is taking place - it's not a
good idea to transmit any, if the measurement has been taking place and
it is discovered that there's already a strong radio signal (on freq x).
So it can be used to find out a channel that's good for transmission =)

- Eero


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 2/9] v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX controls
  2009-06-16 10:52             ` Eduardo Valentin
  2009-06-16 11:18               ` Hans Verkuil
@ 2009-06-16 18:06               ` Trent Piepho
  1 sibling, 0 replies; 33+ messages in thread
From: Trent Piepho @ 2009-06-16 18:06 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: ext Hans Verkuil, Eduardo Valentin, ext Mauro Carvalho Chehab,
	Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

On Tue, 16 Jun 2009, Eduardo Valentin wrote:
> On Sun, Jun 14, 2009 at 06:59:13PM +0200, ext Hans Verkuil wrote:
> > On Sunday 14 June 2009 18:23:41 Trent Piepho wrote:
> > > > > similar V4L2_CID_MPEG_EMPHASIS control and others might well appear in the
> > > > > future, so I think this name should be more specific to the FM_TX API.
> > >
> > > The cx88 driver could get support for setting the fm preemphasis via a
> > > control.  I added support via a module option, but a control would be
> > > better.  You're saying it shouldn't use this fm preemphasis control?
> >
> > Correct. This set the pre-emphasis when transmitting. For receiving you want
> > a separate control. Although the enum should be made generic. So FM_TX can be
> > removed from the enum.
> >
> > Why should we have one rx and one tx control for this? Because you can have
> > both receivers and transmitters in one device and you want independent control
> > of the two.
>
> Yes, agreed here. There is the possibility to have receiver and transmitter
> both in the same device. So, I think it is better to have separated controls.

Is both a receiver and transmitter in the same device different than having
two receivers or two transmitters?  In which case, since controls are not
assigned to a specific input, how does one handle that?

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCHv7 0/9] FM Transmitter (si4713) and another changes
  2009-06-16 11:07       ` Eduardo Valentin
@ 2009-06-18  6:34         ` Hans Verkuil
  0 siblings, 0 replies; 33+ messages in thread
From: Hans Verkuil @ 2009-06-18  6:34 UTC (permalink / raw)
  To: eduardo.valentin
  Cc: ext Mauro Carvalho Chehab, Nurkkala Eero.An (EXT-Offcode/Oulu),
	Aaltonen Matti.J (Nokia-D/Tampere),
	ext Douglas Schilling Landgraf, Linux-Media

On Tuesday 16 June 2009 13:07:55 Eduardo Valentin wrote:
> On Tue, Jun 16, 2009 at 01:01:51PM +0200, ext Hans Verkuil wrote:
> > On Tuesday 16 June 2009 12:47:14 Eduardo Valentin wrote:
> > > Hi Hans,
> > >
> > > On Sun, Jun 14, 2009 at 01:37:20PM +0200, ext Hans Verkuil wrote:
> >
> > <snip>
> >
> > > > I think the refactoring should be done first. I don't believe it is
> > > > that much work and experience shows that it is better to do this
> > > > right away while you are still motivated :-)
> > >
> > > hehehe.. Yes, that's what I was expecting :-). No problem. I've
> > > started it. I will resend the series once I've completed the
> > > re-factoring and I 've made some testing after that. I hope tomorrow
> > > or so.
> > >
> > > > The string control support should not go into 2.6.31. I would like
> > > > to do that only in the v4l-dvb tree (so it will appear in 2.6.32)
> > > > since I want to give that a bit more time to mature. I implemented
> > > > it very quickly and I do not feel comfortable queueing this for
> > > > 2.6.31.
> > >
> > > Right. Yes, better to test the stuff a bit more.
> > >
> > > > In addition it is still unclear if Mauro will merge my
> > > > v4l-dvb-subdev2 tree for 2.6.31. I hope so, since otherwise it will
> > > > hamper the development of this and other embedded platforms.
> > >
> > > Ok.
> > >
> > > > I also need to add a new V4L2_CAP_MODULATOR (which needs a review
> > > > as well).
> > > >
> > > > And finally I realized that we need to add some v4l2_modulator
> > > > capabilities for the RDS encoder similar to the upcoming v4l2_tuner
> > > > RDS capabilities as is described in this RFC:
> > > >
> > > > http://www.mail-archive.com/linux-media%40vger.kernel.org/msg02498.
> > > >html
> > > >
> > > > I haven't had time to implement this RFC and I know that is not
> > > > going to make 2.6.31. It's now almost at the top of my TODO list,
> > > > so it should go in soon (pending unforeseen circumstances).
> > >
> > > Ok. I'll take a look at it.
> >
> > I've worked on this yesterday. You can take a look at my v4l-dvb-rds
> > tree. Both the API and the documentation of it in the v4l2-spec is in
> > there. I started work on updating the few RDS decoders that we have,
> > but that is not yet in that tree.
> >
> > > > As a result of rereading this RFC I also started to wonder about
> > > > whether the si4713 supports the MMBS functionality. Do you know
> > > > anything about that?
> > >
> > > No. Not that I know. Can you point some link?
> >
> > http://www.rds.org.uk/rdsfrdsrbds.html
> >
> > But I've just read here:
> >
> > http://www.rds.org.uk/rds98/pdf/rdsForum_standards_090414_8.pdf
> >
> > that MMBS is discontinued. I'll need to investigate this further, but
> > if this is indeed true then this can be removed completely from our RDS
> > decoder and encoder APIs.
>
> Yes, better to double check. At least with si4713, I haven't heard
> anything about this.

MMBS does definitely not apply to this FM transmitter. In order to transmit 
MMBS you would need to have a license to do so since it seems to be a 
proprietary format.

I have not been able to confirm that it is indeed discontinued, but since it 
is a proprietary predecessor format of RDS it is very very likely indeed 
that this is true. I'm going to remove the MMBS support from my RDS API and 
I'll just add a note to the spec that if anyone needs this, then they 
should contact the list.

I am glad I found this in time before the final RDS decoding API is in the 
kernel.

Regards,

	Hans

-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2009-06-18  6:34 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-12 17:30 [PATCHv7 0/9] FM Transmitter (si4713) and another changes Eduardo Valentin
2009-06-12 17:30 ` [PATCHv7 1/9] v4l2-subdev.h: Add g_modulator callbacks to subdev api Eduardo Valentin
2009-06-12 17:30   ` [PATCHv7 2/9] v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX controls Eduardo Valentin
2009-06-12 17:30     ` [PATCHv7 3/9] v4l2: video device: Add FM_TX controls default configurations Eduardo Valentin
2009-06-12 17:30       ` [PATCHv7 4/9] v4l2-ctl: Add support for FM TX controls Eduardo Valentin
2009-06-12 17:30         ` [PATCHv7 5/9] v4l2-spec: Add documentation description for FM TX extended control class Eduardo Valentin
2009-06-12 17:30           ` [PATCHv7 6/9] FMTx: si4713: Add files to add radio interface for si4713 Eduardo Valentin
2009-06-12 17:30             ` [PATCHv7 7/9] FMTx: si4713: Add files to handle si4713 i2c device Eduardo Valentin
2009-06-12 17:30               ` [PATCHv7 8/9] FMTx: si4713: Add Kconfig and Makefile entries Eduardo Valentin
2009-06-12 17:30                 ` [PATCHv7 9/9] FMTx: si4713: Add document file Eduardo Valentin
2009-06-14 12:31               ` [PATCHv7 7/9] FMTx: si4713: Add files to handle si4713 i2c device Hans Verkuil
2009-06-16 11:06                 ` Eduardo Valentin
2009-06-16 11:22                   ` Hans Verkuil
2009-06-16 11:30                     ` Eero Nurkkala
2009-06-16 11:50                       ` Eduardo Valentin
2009-06-16 12:05                         ` Eero Nurkkala
2009-06-14 11:14             ` [PATCHv7 6/9] FMTx: si4713: Add files to add radio interface for si4713 Hans Verkuil
2009-06-14 11:22               ` Eduardo Valentin
2009-06-14 10:41           ` [PATCHv7 5/9] v4l2-spec: Add documentation description for FM TX extended control class Hans Verkuil
2009-06-14 10:46             ` Eduardo Valentin
2009-06-14 10:46     ` [PATCHv7 2/9] v4l2: video device: Add V4L2_CTRL_CLASS_FM_TX controls Hans Verkuil
2009-06-14 10:50       ` Eduardo Valentin
2009-06-14 16:23         ` Trent Piepho
2009-06-14 16:59           ` Hans Verkuil
2009-06-16 10:52             ` Eduardo Valentin
2009-06-16 11:18               ` Hans Verkuil
2009-06-16 11:51                 ` Eduardo Valentin
2009-06-16 18:06               ` Trent Piepho
2009-06-14 11:37 ` [PATCHv7 0/9] FM Transmitter (si4713) and another changes Hans Verkuil
2009-06-16 10:47   ` Eduardo Valentin
2009-06-16 11:01     ` Hans Verkuil
2009-06-16 11:07       ` Eduardo Valentin
2009-06-18  6:34         ` Hans Verkuil

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.