[PATCH] wl12xx: Fix for overflow while getting irq status

2012-07-16 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

-dlen is 8 bit long and so while memcpy there is a chance
that fmdev-irq_info.flag will overflow.

So this patch removes memcpy and instead copies the 16bit flag
register value from skb-data to fmdev-irq_info.flag directly.

Change-Id: I37604b91b2777ed9e56a7e1c1ecefe32e9024170
Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_common.c |8 +++-
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index bf867a6..54c549b 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -584,18 +584,16 @@ static void fm_irq_send_flag_getcmd(struct fmdev *fmdev)
 static void fm_irq_handle_flag_getcmd_resp(struct fmdev *fmdev)
 {
struct sk_buff *skb;
-   struct fm_event_msg_hdr *fm_evt_hdr;
 
if (check_cmdresp_status(fmdev, skb))
return;
 
-   fm_evt_hdr = (void *)skb-data;
-
/* Skip header info and copy only response data */
skb_pull(skb, sizeof(struct fm_event_msg_hdr));
-   memcpy(fmdev-irq_info.flag, skb-data, fm_evt_hdr-dlen);
 
-   fmdev-irq_info.flag = be16_to_cpu(fmdev-irq_info.flag);
+   /* Copy 16 bit flag register value from skb-data */
+   fmdev-irq_info.flag = (u16) ((skb-data[0]  8) | skb-data[1]);
+
fmdbg(irq: flag register(0x%x)\n, fmdev-irq_info.flag);
 
/* Continue next function in interrupt handler table */
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V7 0/5] [Media] Radio: Fixes and New features for FM

2012-05-21 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

Mauro and the list,

This version 7 of patchset resolves the comments received from
Han's on patchset v6. Also removed the frequency band handling
from this patch set.

This patchset creates new control class 'V4L2_CTRL_CLASS_FM_RX' for FM RX,
introduces 2 new CID's for FM RX and and 1 new CID for FM TX. Also adds 1
field in struct v4l2_hw_freq_seek.

This patch adds few new features to TI's FM driver features
are listed below,

1) FM TX RDS Support (RT, PS, AF, PI, PTY)  
2) FM RX Russian band support
3) FM RX AF set/get
4) FM RX De-emphasis mode set/get

Along with new features this patch also fixes few issues in the driver
like default rssi level for seek, unnecessory logs etc.

Manjunatha Halli (5):
  WL128x: Add support for FM TX RDS
  New control class and features for FM RX
  Add new CID for FM TX RDS Alternate Frequency
  Media: Update docs for V4L2 FM new features
  WL12xx: Add support for FM new features

 Documentation/DocBook/media/v4l/compat.xml |3 +
 Documentation/DocBook/media/v4l/controls.xml   |   77 
 Documentation/DocBook/media/v4l/dev-rds.xml|5 +-
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   |7 ++
 drivers/media/radio/wl128x/fmdrv.h |2 +-
 drivers/media/radio/wl128x/fmdrv_common.c  |   30 +---
 drivers/media/radio/wl128x/fmdrv_common.h  |   25 +--
 drivers/media/radio/wl128x/fmdrv_rx.c  |   13 +++-
 drivers/media/radio/wl128x/fmdrv_tx.c  |   41 +--
 drivers/media/radio/wl128x/fmdrv_tx.h  |3 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c|   74 +++
 drivers/media/video/v4l2-ctrls.c   |   18 -
 include/linux/videodev2.h  |   10 +++
 13 files changed, 255 insertions(+), 53 deletions(-)

-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V7 1/5] WL128x: Add support for FM TX RDS

2012-05-21 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch adds support for following FM TX RDS features,
 1. Radio Text
 2. PS Name
 3. PI Code
 4. PTY Code.

Along with above this patch fixes few other minor issues(like
fm tx get frequency, unnecessary error messages etc).

Acked-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_common.c |   17 +++---
 drivers/media/radio/wl128x/fmdrv_common.h |   17 +++
 drivers/media/radio/wl128x/fmdrv_rx.c |2 +-
 drivers/media/radio/wl128x/fmdrv_tx.c |   41 ++---
 drivers/media/radio/wl128x/fmdrv_tx.h |3 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |   47 +
 6 files changed, 90 insertions(+), 37 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index bf867a6..fcce61a 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -354,7 +354,7 @@ static void send_tasklet(unsigned long arg)
 
/* Check, is there any timeout happened to last transmitted packet */
if ((jiffies - fmdev-last_tx_jiffies)  FM_DRV_TX_TIMEOUT) {
-   fmerr(TX timeout occurred\n);
+   fmdbg(TX timeout occurred\n);
atomic_set(fmdev-tx_cnt, 1);
}
 
@@ -615,7 +615,11 @@ static void fm_irq_handle_rds_start(struct fmdev *fmdev)
 {
if (fmdev-irq_info.flag  FM_RDS_EVENT  fmdev-irq_info.mask) {
fmdbg(irq: rds threshold reached\n);
-   fmdev-irq_info.stage = FM_RDS_SEND_RDS_GETCMD_IDX;
+   /* If RSSI reached below threshold then dont get RDS data */
+   if (fmdev-irq_info.flag  FM_LEV_EVENT)
+   fmdev-irq_info.stage = FM_HW_TUNE_OP_ENDED_IDX;
+   else
+   fmdev-irq_info.stage = FM_RDS_SEND_RDS_GETCMD_IDX;
} else {
/* Continue next function in interrupt handler table */
fmdev-irq_info.stage = FM_HW_TUNE_OP_ENDED_IDX;
@@ -1129,8 +1133,9 @@ int fmc_set_freq(struct fmdev *fmdev, u32 freq_to_set)
 
 int fmc_get_freq(struct fmdev *fmdev, u32 *cur_tuned_frq)
 {
-   if (fmdev-rx.freq == FM_UNDEFINED_FREQ) {
-   fmerr(RX frequency is not set\n);
+   if (fmdev-rx.freq == FM_UNDEFINED_FREQ 
+   fmdev-tx_data.tx_frq == FM_UNDEFINED_FREQ) {
+   fmerr(RX/TX frequency is not set\n);
return -EPERM;
}
if (cur_tuned_frq == NULL) {
@@ -1144,7 +1149,7 @@ int fmc_get_freq(struct fmdev *fmdev, u32 *cur_tuned_frq)
return 0;
 
case FM_MODE_TX:
-   *cur_tuned_frq = 0; /* TODO : Change this later */
+   *cur_tuned_frq = fmdev-tx_data.tx_frq;
return 0;
 
default:
@@ -1574,6 +1579,8 @@ int fmc_prepare(struct fmdev *fmdev)
fmdev-rx.af_mode = FM_RX_RDS_AF_SWITCH_MODE_OFF;
fmdev-irq_info.retry = 0;
 
+   fmdev-tx_data.tx_frq = FM_UNDEFINED_FREQ;
+
fm_rx_reset_rds_cache(fmdev);
init_waitqueue_head(fmdev-rx.rds.read_queue);
 
diff --git a/drivers/media/radio/wl128x/fmdrv_common.h 
b/drivers/media/radio/wl128x/fmdrv_common.h
index d9b9c6c..196ff7d 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.h
+++ b/drivers/media/radio/wl128x/fmdrv_common.h
@@ -48,8 +48,8 @@ struct fm_reg_table {
 #define SEARCH_LVL_SET   15
 #define BAND_SET 16
 #define MUTE_STATUS_SET  17
-#define RDS_PAUSE_LVL_SET18
-#define RDS_PAUSE_DUR_SET19
+#define AUD_PAUSE_LVL_SET18
+#define AUD_PAUSE_DUR_SET19
 #define RDS_MEM_SET  20
 #define RDS_BLK_B_SET21
 #define RDS_MSK_B_SET22
@@ -84,11 +84,12 @@ struct fm_reg_table {
 
 #define FM_POWER_MODE254
 #define FM_INTERRUPT 255
+#define STATION_VALID   123
 
 /* Transmitter API */
 
 #define CHANL_SET55
-#define CHANL_BW_SET   56
+#define SCAN_SPACING_SET 56
 #define REF_SET  57
 #define POWER_ENB_SET90
 #define POWER_ATT_SET58
@@ -103,7 +104,8 @@ struct fm_reg_table {
 #define MONO_SET 66
 #define MUTE 92
 #define MPX_LMT_ENABLE   67
-#define PI_SET   93
+#define REF_ERR_SET 93
+#define PI_SET   68
 #define ECC_SET  69
 #define PTY  70
 #define AF   71
@@ -120,6 +122,10 @@ struct fm_reg_table {
 #define TX_AUDIO_LEVEL_TEST  96
 #define TX_AUDIO_LEVEL_TEST_THRESHOLD73
 #define TX_AUDIO_INPUT_LEVEL_RANGE_SET   54
+#define TX_AUDIO_LEVEL_GET  7
+#define READ_FMANT_TUNE_VALUE104
+
+/* New FM APIs (Rx and Tx) */
 #define RX_ANTENNA_SELECT87
 #define I2C_DEV_ADDR_SET

[PATCH V7 4/5] Media: Update docs for V4L2 FM new features

2012-05-21 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

The list of new features -
1) New control class for FM RX
2) New FM RX CID's - De-Emphasis filter mode and RDS AF switch
3) New FM TX CID - RDS Alternate frequency set.

Acked-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 Documentation/DocBook/media/v4l/compat.xml |3 +
 Documentation/DocBook/media/v4l/controls.xml   |   77 
 Documentation/DocBook/media/v4l/dev-rds.xml|5 +-
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   |7 ++
 4 files changed, 90 insertions(+), 2 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/compat.xml 
b/Documentation/DocBook/media/v4l/compat.xml
index bce97c5..df1f345 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2311,6 +2311,9 @@ more information./para
  paraAdded FM Modulator (FM TX) Extended Control Class: 
constantV4L2_CTRL_CLASS_FM_TX/constant and their Control IDs./para
/listitem
listitem
+   paraAdded FM Receiver (FM RX) Extended Control Class: 
constantV4L2_CTRL_CLASS_FM_RX/constant and their Control IDs./para
+   /listitem
+   listitem
  paraAdded Remote Controller chapter, describing the default Remote 
Controller mapping for media devices./para
/listitem
   /orderedlist
diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index b84f25e..ced2bee 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3018,6 +3018,12 @@ to find receivers which can scroll strings sized as 32 x 
N or 64 x N characters.
 with steps of 32 or 64 characters. The result is it must always contain a 
string with size multiple of 32 or 64. /entry
  /row
  row
+ entry 
spanname=idconstantV4L2_CID_RDS_TX_AF_FREQ/constantnbsp;/entry
+ entryinteger/entry
+ /row
+ rowentry spanname=descrSets the RDS Alternate Frequency value 
which allows a receiver to re-tune to a different frequency providing the same 
station when the first signal becomes too weak (e.g., when moving out of 
range). /entry
+ /row
+ row
entry 
spanname=idconstantV4L2_CID_AUDIO_LIMITER_ENABLED/constantnbsp;/entry
entryboolean/entry
  /row
@@ -3146,6 +3152,77 @@ manually or automatically if set to zero. Unit, range 
and step are driver-specif
 xref linkend=en50067 / document, from CENELEC./para
 /section
 
+section id=fm-rx-controls
+  titleFM Receiver Control Reference/title
+
+  paraThe FM Receiver (FM_RX) class includes controls for common 
features of
+FM Reception capable devices./para
+
+  table pgwide=1 frame=none id=fm-rx-control-id
+  titleFM_RX 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=leftID/entry
+entry align=leftType/entry
+  /rowrow rowsep=1entry spanname=descr 
align=leftDescription/entry
+  /row
+/thead
+tbody valign=top
+  rowentry/entry/row
+  row
+entry 
spanname=idconstantV4L2_CID_FM_RX_CLASS/constantnbsp;/entry
+entryclass/entry
+  /rowrowentry spanname=descrThe FM_RX class
+descriptor. Calling VIDIOC-QUERYCTRL; for this control will return a
+description of this control class./entry
+  /row
+  row
+entry 
spanname=idconstantV4L2_CID_RDS_AF_SWITCH/constantnbsp;/entry
+entryboolean/entry
+  /row
+  rowentry spanname=descrEnable or Disable the RDS Alternate 
frequency feature. When enabled the driver will decode the RDS AF field and 
tries to switch to this AF frequency once the current frequency RSSI (Received 
signal strength indication) level goes below the threshold. If the frequency is 
switched, then VIDIOC-G-FREQUENCY; will return the new frequency./entry
+  /row
+  row
+   entry 
spanname=idconstantV4L2_CID_TUNE_DEEMPHASIS/constantnbsp;/entry
+   entryinteger/entry
+ /row
+ row id=v4l2-deemphasisentry spanname=descrConfigures the 
de-emphasis value for reception.
+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 enumnbsp;v4l2_preemphasis
+defines possible values for pre-emphasis. Here they are:/entry
+   /rowrow
+   entrytbl spanname=descr cols=2
+ tbody valign=top
+   row
+ 

[PATCH V7 5/5] WL12xx: Add support for FM new features

2012-05-21 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch adds below features to TI's V4l2 FM driver for Wilink
chipsets,

1) FM RX RDS AF turn ON/OFF
2) FM RX De-Emphasis mode set/get
3) FM TX Alternate Frequency set/get

Also this patch fixes below issues

1) FM audio volume gain setting
2) Default rssi level is set to 8 instead of 20
3) Enable FM RX AF support in driver
4) In wrap_around seek mode try for once

Acked-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/radio/wl128x/fmdrv.h|2 +-
 drivers/media/radio/wl128x/fmdrv_common.c |   13 +++--
 drivers/media/radio/wl128x/fmdrv_common.h |   10 +++---
 drivers/media/radio/wl128x/fmdrv_rx.c |   11 +--
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |   27 +++
 5 files changed, 51 insertions(+), 12 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv.h 
b/drivers/media/radio/wl128x/fmdrv.h
index d84ad9d..e1a3c78 100644
--- a/drivers/media/radio/wl128x/fmdrv.h
+++ b/drivers/media/radio/wl128x/fmdrv.h
@@ -203,7 +203,7 @@ struct fmtx_data {
 struct fmdev {
struct video_device *radio_dev; /* V4L2 video device pointer */
struct snd_card *card;  /* Card which holds FM mixer controls */
-   u16 asci_id;
+   u16 asic_id;
spinlock_t rds_buff_lock; /* To protect access to RDS buffer */
spinlock_t resp_skb_lock; /* To protect access to received SKB */
 
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index fcce61a..9ab7a63 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -596,7 +596,6 @@ static void fm_irq_handle_flag_getcmd_resp(struct fmdev 
*fmdev)
memcpy(fmdev-irq_info.flag, skb-data, fm_evt_hdr-dlen);
 
fmdev-irq_info.flag = be16_to_cpu(fmdev-irq_info.flag);
-   fmdbg(irq: flag register(0x%x)\n, fmdev-irq_info.flag);
 
/* Continue next function in interrupt handler table */
fm_irq_call_stage(fmdev, FM_HW_MAL_FUNC_IDX);
@@ -702,7 +701,7 @@ static void fm_rdsparse_swapbytes(struct fmdev *fmdev,
 * in Dolphin they are in big endian, the parsing of the RDS data
 * is chip dependent
 */
-   if (fmdev-asci_id != 0x6350) {
+   if (fmdev-asic_id != 0x6350) {
rds_buff = rds_format-data.groupdatabuff.buff[0];
while (index + 1  FM_RX_RDS_INFO_FIELD_MAX) {
byte1 = rds_buff[index];
@@ -1353,11 +1352,13 @@ static int fm_power_up(struct fmdev *fmdev, u8 mode)
sizeof(asic_ver), asic_ver, resp_len))
goto rel;
 
+   fmdev-asic_id = be16_to_cpu(asic_id);
+
fmdbg(ASIC ID: 0x%x , ASIC Version: %d\n,
-   be16_to_cpu(asic_id), be16_to_cpu(asic_ver));
+   fmdev-asic_id, be16_to_cpu(asic_ver));
 
sprintf(fw_name, %s_%x.%d.bts, FM_FMC_FW_FILE_START,
-   be16_to_cpu(asic_id), be16_to_cpu(asic_ver));
+   fmdev-asic_id, be16_to_cpu(asic_ver));
 
ret = fm_download_firmware(fmdev, fw_name);
if (ret  0) {
@@ -1366,7 +1367,7 @@ static int fm_power_up(struct fmdev *fmdev, u8 mode)
}
sprintf(fw_name, %s_%x.%d.bts, (mode == FM_MODE_RX) ?
FM_RX_FW_FILE_START : FM_TX_FW_FILE_START,
-   be16_to_cpu(asic_id), be16_to_cpu(asic_ver));
+   fmdev-asic_id, be16_to_cpu(asic_ver));
 
ret = fm_download_firmware(fmdev, fw_name);
if (ret  0) {
@@ -1576,7 +1577,7 @@ int fmc_prepare(struct fmdev *fmdev)
fmdev-rx.rds.flag = FM_RDS_DISABLE;
fmdev-rx.freq = FM_UNDEFINED_FREQ;
fmdev-rx.rds_mode = FM_RDS_SYSTEM_RDS;
-   fmdev-rx.af_mode = FM_RX_RDS_AF_SWITCH_MODE_OFF;
+   fmdev-rx.af_mode = FM_RX_RDS_AF_SWITCH_MODE_ON;
fmdev-irq_info.retry = 0;
 
fmdev-tx_data.tx_frq = FM_UNDEFINED_FREQ;
diff --git a/drivers/media/radio/wl128x/fmdrv_common.h 
b/drivers/media/radio/wl128x/fmdrv_common.h
index 196ff7d..a57c662 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.h
+++ b/drivers/media/radio/wl128x/fmdrv_common.h
@@ -201,8 +201,8 @@ struct fm_event_msg_hdr {
 #define FM_UNDEFINED_FREQ 0x
 
 /* Band types */
-#define FM_BAND_EUROPE_US  0
-#define FM_BAND_JAPAN  1
+#define FM_BAND_EUROPE_US  0
+#define FM_BAND_JAPAN  1
 
 /* Seek directions */
 #define FM_SEARCH_DIRECTION_DOWN   0
@@ -213,6 +213,10 @@ struct fm_event_msg_hdr {
 #define FM_TUNER_PRESET_MODE   1
 #define FM_TUNER_AUTONOMOUS_SEARCH_MODE2
 #define FM_TUNER_AF_JUMP_MODE  3
+#define FM_TUNER_PI_MATCH_MODE 4
+#define FM_TUNER_BULK_SEARCH_MODE  5
+#define FM_TUNER_WRAP_SEARCH_MODE  6
+#define FM_TUNER_WEATHER_MODE  7
 
 /* Min and Max volume */
 #define 

[PATCH V7 2/5] New control class and features for FM RX

2012-05-21 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch creates new ctrl class for FM RX and adds new CID's for
below FM features,
  1) De-Emphasis filter mode
  2) RDS Alternate Frequency switch

Acked-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/video/v4l2-ctrls.c |   17 ++---
 include/linux/videodev2.h|9 +
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 18015c0..9d7608e 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -243,8 +243,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
Vivid,
NULL
};
-   static const char * const tune_preemphasis[] = {
-   No Preemphasis,
+   static const char * const tune_emphasis[] = {
+   None,
50 Microseconds,
75 Microseconds,
NULL,
@@ -413,7 +413,9 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
case V4L2_CID_COLORFX:
return colorfx;
case V4L2_CID_TUNE_PREEMPHASIS:
-   return tune_preemphasis;
+   return tune_emphasis;
+   case V4L2_CID_TUNE_DEEMPHASIS:
+   return tune_emphasis;
case V4L2_CID_FLASH_LED_MODE:
return flash_led_mode;
case V4L2_CID_FLASH_STROBE_SOURCE:
@@ -644,6 +646,12 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_JPEG_COMPRESSION_QUALITY: return Compression Quality;
case V4L2_CID_JPEG_ACTIVE_MARKER:   return Active Markers;
 
+   /* FM Radio Receiver control */
+   /* Keep the order of the 'case's the same as in videodev2.h! */
+   case V4L2_CID_FM_RX_CLASS:  return FM Radio Receiver 
Controls;
+   case V4L2_CID_RDS_AF_SWITCH:return RDS Alternate Frequency 
Switch;
+   case V4L2_CID_TUNE_DEEMPHASIS:  return De-Emphasis;
+
default:
return NULL;
}
@@ -688,6 +696,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM:
case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE:
case V4L2_CID_MPEG_VIDEO_MPEG4_QPEL:
+   case V4L2_CID_RDS_AF_SWITCH:
*type = V4L2_CTRL_TYPE_BOOLEAN;
*min = 0;
*max = *step = 1;
@@ -733,6 +742,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL:
case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE:
case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
+   case V4L2_CID_TUNE_DEEMPHASIS:
*type = V4L2_CTRL_TYPE_MENU;
break;
case V4L2_CID_RDS_TX_PS_NAME:
@@ -745,6 +755,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_FM_TX_CLASS:
case V4L2_CID_FLASH_CLASS:
case V4L2_CID_JPEG_CLASS:
+   case V4L2_CID_FM_RX_CLASS:
*type = V4L2_CTRL_TYPE_CTRL_CLASS;
/* You can neither read not write these */
*flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index c9c9a46..eb2da58 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1137,6 +1137,7 @@ struct v4l2_ext_controls {
 #define V4L2_CTRL_CLASS_FM_TX 0x009b   /* FM Modulator control class */
 #define V4L2_CTRL_CLASS_FLASH 0x009c   /* Camera flash controls */
 #define V4L2_CTRL_CLASS_JPEG 0x009d/* JPEG-compression 
controls */
+#define V4L2_CTRL_CLASS_FM_RX 0x009e   /* FM Receiver control class */
 
 #define V4L2_CTRL_ID_MASK(0x0fff)
 #define V4L2_CTRL_ID2CLASS(id)((id)  0x0fffUL)
@@ -1782,6 +1783,13 @@ enum v4l2_jpeg_chroma_subsampling {
 #defineV4L2_JPEG_ACTIVE_MARKER_DQT (1  17)
 #defineV4L2_JPEG_ACTIVE_MARKER_DHT (1  18)
 
+/* FM Receiver class control IDs */
+#define V4L2_CID_FM_RX_CLASS_BASE  (V4L2_CTRL_CLASS_FM_RX | 0x900)
+#define V4L2_CID_FM_RX_CLASS   (V4L2_CTRL_CLASS_FM_RX | 1)
+
+#define V4L2_CID_RDS_AF_SWITCH (V4L2_CID_FM_RX_CLASS_BASE + 1)
+#define V4L2_CID_TUNE_DEEMPHASIS   (V4L2_CID_FM_RX_CLASS_BASE + 2)
+
 /*
  * T U N I N G
  */
@@ -1820,6 +1828,7 @@ struct v4l2_modulator {
 #define V4L2_TUNER_CAP_RDS_BLOCK_IO0x0100
 #define V4L2_TUNER_CAP_RDS_CONTROLS0x0200
 
+
 /*  Flags for the 'rxsubchans' field */
 #define V4L2_TUNER_SUB_MONO0x0001
 #define V4L2_TUNER_SUB_STEREO  0x0002
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V7 3/5] Add new CID for FM TX RDS Alternate Frequency

2012-05-21 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

Acked-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/video/v4l2-ctrls.c |1 +
 include/linux/videodev2.h|1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 9d7608e..610076c 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -608,6 +608,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_RDS_TX_PTY:   return RDS Program Type;
case V4L2_CID_RDS_TX_PS_NAME:   return RDS PS Name;
case V4L2_CID_RDS_TX_RADIO_TEXT:return RDS Radio Text;
+   case V4L2_CID_RDS_TX_AF_FREQ:   return RDS Alternate 
Frequency;
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;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index eb2da58..2f6e2ef 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1699,6 +1699,7 @@ enum  v4l2_exposure_auto_type {
 #define V4L2_CID_RDS_TX_PTY(V4L2_CID_FM_TX_CLASS_BASE + 3)
 #define V4L2_CID_RDS_TX_PS_NAME
(V4L2_CID_FM_TX_CLASS_BASE + 5)
 #define V4L2_CID_RDS_TX_RADIO_TEXT (V4L2_CID_FM_TX_CLASS_BASE + 6)
+#define V4L2_CID_RDS_TX_AF_FREQ
(V4L2_CID_FM_TX_CLASS_BASE + 7)
 
 #define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 64)
 #define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME(V4L2_CID_FM_TX_CLASS_BASE + 65)
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V5 0/5] [Media] Radio: Fixes and New features for FM

2012-05-14 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

Mauro and the list,

This version 5 of patchset resolves the comments received from
Han's on patchset v4.

This patchset creates new control class 'V4L2_CTRL_CLASS_FM_RX' for FM RX,
introduces 2 new CID's for FM RX and and 1 new CID for FM TX. Also adds 1
field in struct v4l2_hw_freq_seek.

This patch adds few new features to TI's FM driver features
are listed below,

1) FM TX RDS Support (RT, PS, AF, PI, PTY)
2) FM RX Russian band support
3) FM RX AF set/get
4) FM RX De-emphasis mode set/get

Along with new features this patch also fixes few issues in the driver
like default rssi level for seek, unnecessory logs etc.

Manjunatha Halli (5):
  WL128x: Add support for FM TX RDS
  New control class and features for FM RX
  Add new CID for FM TX RDS Alternate Frequency
  Media: Update docs for V4L2 FM new features
  WL12xx: Add support for FM new features.

 Documentation/DocBook/media/v4l/compat.xml |3 +
 Documentation/DocBook/media/v4l/controls.xml   |   77 ++
 Documentation/DocBook/media/v4l/dev-rds.xml|5 +-
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   |7 +
 Documentation/DocBook/media/v4l/vidioc-g-tuner.xml |   25 
 .../DocBook/media/v4l/vidioc-s-hw-freq-seek.xml|   38 +-
 drivers/media/radio/wl128x/fmdrv.h |3 +-
 drivers/media/radio/wl128x/fmdrv_common.c  |   55 ++--
 drivers/media/radio/wl128x/fmdrv_common.h  |   43 +-
 drivers/media/radio/wl128x/fmdrv_rx.c  |   92 ++---
 drivers/media/radio/wl128x/fmdrv_rx.h  |2 +-
 drivers/media/radio/wl128x/fmdrv_tx.c  |   41 +++---
 drivers/media/radio/wl128x/fmdrv_tx.h  |3 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c|  148 +++-
 drivers/media/video/v4l2-ctrls.c   |   18 ++-
 include/linux/videodev2.h  |   26 -
 16 files changed, 504 insertions(+), 82 deletions(-)

-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V5 1/5] WL128x: Add support for FM TX RDS

2012-05-14 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch adds support for following FM TX RDS features,
 1. Radio Text
 2. PS Name
 3. PI Code
 4. PTY Code.

Along with above this patch fixes few other minor issues(like
fm tx get frequency, unnecessary error messages etc).

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_common.c |   17 +++---
 drivers/media/radio/wl128x/fmdrv_common.h |   17 +++
 drivers/media/radio/wl128x/fmdrv_rx.c |2 +-
 drivers/media/radio/wl128x/fmdrv_tx.c |   41 ++---
 drivers/media/radio/wl128x/fmdrv_tx.h |3 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |   47 +
 6 files changed, 90 insertions(+), 37 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index bf867a6..fcce61a 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -354,7 +354,7 @@ static void send_tasklet(unsigned long arg)
 
/* Check, is there any timeout happened to last transmitted packet */
if ((jiffies - fmdev-last_tx_jiffies)  FM_DRV_TX_TIMEOUT) {
-   fmerr(TX timeout occurred\n);
+   fmdbg(TX timeout occurred\n);
atomic_set(fmdev-tx_cnt, 1);
}
 
@@ -615,7 +615,11 @@ static void fm_irq_handle_rds_start(struct fmdev *fmdev)
 {
if (fmdev-irq_info.flag  FM_RDS_EVENT  fmdev-irq_info.mask) {
fmdbg(irq: rds threshold reached\n);
-   fmdev-irq_info.stage = FM_RDS_SEND_RDS_GETCMD_IDX;
+   /* If RSSI reached below threshold then dont get RDS data */
+   if (fmdev-irq_info.flag  FM_LEV_EVENT)
+   fmdev-irq_info.stage = FM_HW_TUNE_OP_ENDED_IDX;
+   else
+   fmdev-irq_info.stage = FM_RDS_SEND_RDS_GETCMD_IDX;
} else {
/* Continue next function in interrupt handler table */
fmdev-irq_info.stage = FM_HW_TUNE_OP_ENDED_IDX;
@@ -1129,8 +1133,9 @@ int fmc_set_freq(struct fmdev *fmdev, u32 freq_to_set)
 
 int fmc_get_freq(struct fmdev *fmdev, u32 *cur_tuned_frq)
 {
-   if (fmdev-rx.freq == FM_UNDEFINED_FREQ) {
-   fmerr(RX frequency is not set\n);
+   if (fmdev-rx.freq == FM_UNDEFINED_FREQ 
+   fmdev-tx_data.tx_frq == FM_UNDEFINED_FREQ) {
+   fmerr(RX/TX frequency is not set\n);
return -EPERM;
}
if (cur_tuned_frq == NULL) {
@@ -1144,7 +1149,7 @@ int fmc_get_freq(struct fmdev *fmdev, u32 *cur_tuned_frq)
return 0;
 
case FM_MODE_TX:
-   *cur_tuned_frq = 0; /* TODO : Change this later */
+   *cur_tuned_frq = fmdev-tx_data.tx_frq;
return 0;
 
default:
@@ -1574,6 +1579,8 @@ int fmc_prepare(struct fmdev *fmdev)
fmdev-rx.af_mode = FM_RX_RDS_AF_SWITCH_MODE_OFF;
fmdev-irq_info.retry = 0;
 
+   fmdev-tx_data.tx_frq = FM_UNDEFINED_FREQ;
+
fm_rx_reset_rds_cache(fmdev);
init_waitqueue_head(fmdev-rx.rds.read_queue);
 
diff --git a/drivers/media/radio/wl128x/fmdrv_common.h 
b/drivers/media/radio/wl128x/fmdrv_common.h
index d9b9c6c..196ff7d 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.h
+++ b/drivers/media/radio/wl128x/fmdrv_common.h
@@ -48,8 +48,8 @@ struct fm_reg_table {
 #define SEARCH_LVL_SET   15
 #define BAND_SET 16
 #define MUTE_STATUS_SET  17
-#define RDS_PAUSE_LVL_SET18
-#define RDS_PAUSE_DUR_SET19
+#define AUD_PAUSE_LVL_SET18
+#define AUD_PAUSE_DUR_SET19
 #define RDS_MEM_SET  20
 #define RDS_BLK_B_SET21
 #define RDS_MSK_B_SET22
@@ -84,11 +84,12 @@ struct fm_reg_table {
 
 #define FM_POWER_MODE254
 #define FM_INTERRUPT 255
+#define STATION_VALID   123
 
 /* Transmitter API */
 
 #define CHANL_SET55
-#define CHANL_BW_SET   56
+#define SCAN_SPACING_SET 56
 #define REF_SET  57
 #define POWER_ENB_SET90
 #define POWER_ATT_SET58
@@ -103,7 +104,8 @@ struct fm_reg_table {
 #define MONO_SET 66
 #define MUTE 92
 #define MPX_LMT_ENABLE   67
-#define PI_SET   93
+#define REF_ERR_SET 93
+#define PI_SET   68
 #define ECC_SET  69
 #define PTY  70
 #define AF   71
@@ -120,6 +122,10 @@ struct fm_reg_table {
 #define TX_AUDIO_LEVEL_TEST  96
 #define TX_AUDIO_LEVEL_TEST_THRESHOLD73
 #define TX_AUDIO_INPUT_LEVEL_RANGE_SET   54
+#define TX_AUDIO_LEVEL_GET  7
+#define READ_FMANT_TUNE_VALUE104
+
+/* New FM APIs (Rx and Tx) */
 #define RX_ANTENNA_SELECT87
 #define I2C_DEV_ADDR_SET 86
 #define REF_ERR_CALIB_PARAM_SET  

[PATCH V5 4/5] Media: Update docs for V4L2 FM new features

2012-05-14 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

The list of new features -
1) New control class for FM RX
2) New FM RX CID's - De-Emphasis filter mode and RDS AF switch
3) New FM TX CID - RDS Alternate frequency set.
4) New capability struct v4l2_tuner flags for band selection

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 Documentation/DocBook/media/v4l/compat.xml |3 +
 Documentation/DocBook/media/v4l/controls.xml   |   77 
 Documentation/DocBook/media/v4l/dev-rds.xml|5 +-
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   |7 ++
 Documentation/DocBook/media/v4l/vidioc-g-tuner.xml |   25 +++
 .../DocBook/media/v4l/vidioc-s-hw-freq-seek.xml|   38 +-
 6 files changed, 151 insertions(+), 4 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/compat.xml 
b/Documentation/DocBook/media/v4l/compat.xml
index bce97c5..df1f345 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2311,6 +2311,9 @@ more information./para
  paraAdded FM Modulator (FM TX) Extended Control Class: 
constantV4L2_CTRL_CLASS_FM_TX/constant and their Control IDs./para
/listitem
listitem
+   paraAdded FM Receiver (FM RX) Extended Control Class: 
constantV4L2_CTRL_CLASS_FM_RX/constant and their Control IDs./para
+   /listitem
+   listitem
  paraAdded Remote Controller chapter, describing the default Remote 
Controller mapping for media devices./para
/listitem
   /orderedlist
diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index b84f25e..976b11b 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3018,6 +3018,12 @@ to find receivers which can scroll strings sized as 32 x 
N or 64 x N characters.
 with steps of 32 or 64 characters. The result is it must always contain a 
string with size multiple of 32 or 64. /entry
  /row
  row
+ entry 
spanname=idconstantV4L2_CID_RDS_TX_AF_FREQ/constantnbsp;/entry
+ entryinteger/entry
+ /row
+ rowentry spanname=descrSets the RDS Alternate Frequency value 
which allows a receiver to re-tune to a different frequency providing the same 
station when the first signal becomes too weak (e.g., when moving out of 
range). /entry
+ /row
+ row
entry 
spanname=idconstantV4L2_CID_AUDIO_LIMITER_ENABLED/constantnbsp;/entry
entryboolean/entry
  /row
@@ -3146,6 +3152,77 @@ manually or automatically if set to zero. Unit, range 
and step are driver-specif
 xref linkend=en50067 / document, from CENELEC./para
 /section
 
+section id=fm-rx-controls
+  titleFM Receiver Control Reference/title
+
+  paraThe FM Receiver (FM_RX) class includes controls for common 
features of
+FM Reception capable devices./para
+
+  table pgwide=1 frame=none id=fm-rx-control-id
+  titleFM_RX 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=leftID/entry
+entry align=leftType/entry
+  /rowrow rowsep=1entry spanname=descr 
align=leftDescription/entry
+  /row
+/thead
+tbody valign=top
+  rowentry/entry/row
+  row
+entry 
spanname=idconstantV4L2_CID_FM_RX_CLASS/constantnbsp;/entry
+entryclass/entry
+  /rowrowentry spanname=descrThe FM_RX class
+descriptor. Calling VIDIOC-QUERYCTRL; for this control will return a
+description of this control class./entry
+  /row
+  row
+entry 
spanname=idconstantV4L2_CID_RDS_AF_SWITCH/constantnbsp;/entry
+entryboolean/entry
+  /row
+  rowentry spanname=descrEnable or Disable the RDS Alternate 
frequency feature. When enabled the driver will decode the RDS AF field and 
tries to switch to this AF frequency once the current frequency RSSI(Received 
signal strength indication) level goes below the threshold. If the frequency is 
switched, then VIDIOC-G-FREQUENCY; will return the new frequency./entry
+  /row
+  row
+   entry 
spanname=idconstantV4L2_CID_TUNE_DEEMPHASIS/constantnbsp;/entry
+   entryinteger/entry
+ /row
+ row id=v4l2-deemphasisentry spanname=descrConfigures the 
de-emphasis value for reception.
+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 enumnbsp;v4l2_preemphasis
+defines possible values for pre-emphasis. Here 

[PATCH V5 3/5] Add new CID for FM TX RDS Alternate Frequency

2012-05-14 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/video/v4l2-ctrls.c |1 +
 include/linux/videodev2.h|1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 9d7608e..610076c 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -608,6 +608,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_RDS_TX_PTY:   return RDS Program Type;
case V4L2_CID_RDS_TX_PS_NAME:   return RDS PS Name;
case V4L2_CID_RDS_TX_RADIO_TEXT:return RDS Radio Text;
+   case V4L2_CID_RDS_TX_AF_FREQ:   return RDS Alternate 
Frequency;
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;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 16c0e90..2170830 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1699,6 +1699,7 @@ enum  v4l2_exposure_auto_type {
 #define V4L2_CID_RDS_TX_PTY(V4L2_CID_FM_TX_CLASS_BASE + 3)
 #define V4L2_CID_RDS_TX_PS_NAME
(V4L2_CID_FM_TX_CLASS_BASE + 5)
 #define V4L2_CID_RDS_TX_RADIO_TEXT (V4L2_CID_FM_TX_CLASS_BASE + 6)
+#define V4L2_CID_RDS_TX_AF_FREQ
(V4L2_CID_FM_TX_CLASS_BASE + 7)
 
 #define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 64)
 #define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME(V4L2_CID_FM_TX_CLASS_BASE + 65)
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V6 5/5] WL12xx: Add support for FM new features.

2012-05-14 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch adds below features to TI's V4l2 FM driver for Wilink
chipsets,

1) FM RX Set frequency allows to set frequency anywhere between
65.5 MHz till 108 MHz (if chip is Wilink8 then till 164.55 MHz)
2) FM RX seek caters for band switch
3) FM RX RDS AF turn ON/OFF
4) FM RX De-Emphasis mode set/get
5) FM TX Alternate Frequency set/get

Also this patch fixes below issues

1) FM audio volume gain setting
2) Default rssi level is set to 8 instead of 20
3) Issue related to audio mute/unmute
4) Enable FM RX AF support in driver
5) In wrap_around seek mode try for once

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/radio/wl128x/fmdrv.h|3 +-
 drivers/media/radio/wl128x/fmdrv_common.c |   38 +--
 drivers/media/radio/wl128x/fmdrv_common.h |   28 +++-
 drivers/media/radio/wl128x/fmdrv_rx.c |   90 -
 drivers/media/radio/wl128x/fmdrv_rx.h |2 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |  101 +++--
 6 files changed, 224 insertions(+), 38 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv.h 
b/drivers/media/radio/wl128x/fmdrv.h
index d84ad9d..c806c85 100644
--- a/drivers/media/radio/wl128x/fmdrv.h
+++ b/drivers/media/radio/wl128x/fmdrv.h
@@ -150,6 +150,7 @@ struct fm_rx {
struct region_info region;  /* Current selected band */
u32 freq;   /* Current RX frquency */
u8 mute_mode;   /* Current mute mode */
+   u8 bl_flag; /* Band limit reached flag */
u8 deemphasis_mode; /* Current deemphasis mode */
/* RF dependent soft mute mode */
u8 rf_depend_mute;
@@ -203,7 +204,7 @@ struct fmtx_data {
 struct fmdev {
struct video_device *radio_dev; /* V4L2 video device pointer */
struct snd_card *card;  /* Card which holds FM mixer controls */
-   u16 asci_id;
+   u16 asic_id;
spinlock_t rds_buff_lock; /* To protect access to RDS buffer */
spinlock_t resp_skb_lock; /* To protect access to received SKB */
 
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index fcce61a..ac20556 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -44,20 +44,41 @@
 
 /* Region info */
 static struct region_info region_configs[] = {
+   /* Super set of all bands */
+   {
+.chanl_space = FM_CHANNEL_SPACING_200KHZ * FM_FREQ_MUL,
+.bot_freq = 65800, /* 87.5 MHz */
+.top_freq = 162550,/* 108 MHz */
+.fm_band = 0,
+},
/* Europe/US */
{
 .chanl_space = FM_CHANNEL_SPACING_200KHZ * FM_FREQ_MUL,
 .bot_freq = 87500, /* 87.5 MHz */
 .top_freq = 108000,/* 108 MHz */
-.fm_band = 0,
+.fm_band = 1,
 },
/* Japan */
{
 .chanl_space = FM_CHANNEL_SPACING_200KHZ * FM_FREQ_MUL,
 .bot_freq = 76000, /* 76 MHz */
 .top_freq = 9, /* 90 MHz */
-.fm_band = 1,
+.fm_band = 2,
 },
+   /* Russian (OIRT) band */
+   {
+   .chanl_space = FM_CHANNEL_SPACING_50KHZ * FM_FREQ_MUL_RUS,
+   .bot_freq = 65800, /* 65.8 MHz */
+   .top_freq = 74000, /* 74 MHz */
+   .fm_band = 3,
+   },
+   /* Wether Band */
+   {
+   .chanl_space = FM_CHANNEL_SPACING_50KHZ * FM_FREQ_MUL_WB,
+   .bot_freq = 162400, /* 162.4 MHz */
+   .top_freq = 162550, /* 162.55 MHz */
+   .fm_band = 4,
+   }
 };
 
 /* Band selection */
@@ -596,7 +617,6 @@ static void fm_irq_handle_flag_getcmd_resp(struct fmdev 
*fmdev)
memcpy(fmdev-irq_info.flag, skb-data, fm_evt_hdr-dlen);
 
fmdev-irq_info.flag = be16_to_cpu(fmdev-irq_info.flag);
-   fmdbg(irq: flag register(0x%x)\n, fmdev-irq_info.flag);
 
/* Continue next function in interrupt handler table */
fm_irq_call_stage(fmdev, FM_HW_MAL_FUNC_IDX);
@@ -702,7 +722,7 @@ static void fm_rdsparse_swapbytes(struct fmdev *fmdev,
 * in Dolphin they are in big endian, the parsing of the RDS data
 * is chip dependent
 */
-   if (fmdev-asci_id != 0x6350) {
+   if (fmdev-asic_id != 0x6350) {
rds_buff = rds_format-data.groupdatabuff.buff[0];
while (index + 1  FM_RX_RDS_INFO_FIELD_MAX) {
byte1 = rds_buff[index];
@@ -1353,11 +1373,13 @@ static int fm_power_up(struct fmdev *fmdev, u8 mode)
sizeof(asic_ver), asic_ver, resp_len))
goto rel;
 
+   fmdev-asic_id = be16_to_cpu(asic_id);
+
fmdbg(ASIC ID: 0x%x , ASIC Version: %d\n,
-   be16_to_cpu(asic_id), be16_to_cpu(asic_ver));
+   fmdev-asic_id, be16_to_cpu(asic_ver));
 
sprintf(fw_name, %s_%x.%d.bts, FM_FMC_FW_FILE_START,
-  

[PATCH V6 4/5] Media: Update docs for V4L2 FM new features

2012-05-14 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

The list of new features -
1) New control class for FM RX
2) New FM RX CID's - De-Emphasis filter mode and RDS AF switch
3) New FM TX CID - RDS Alternate frequency set.
4) New capability struct v4l2_tuner flags for band selection

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 Documentation/DocBook/media/v4l/compat.xml |3 +
 Documentation/DocBook/media/v4l/controls.xml   |   77 
 Documentation/DocBook/media/v4l/dev-rds.xml|5 +-
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   |7 ++
 Documentation/DocBook/media/v4l/vidioc-g-tuner.xml |   25 +++
 .../DocBook/media/v4l/vidioc-s-hw-freq-seek.xml|   38 +-
 6 files changed, 151 insertions(+), 4 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/compat.xml 
b/Documentation/DocBook/media/v4l/compat.xml
index bce97c5..df1f345 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2311,6 +2311,9 @@ more information./para
  paraAdded FM Modulator (FM TX) Extended Control Class: 
constantV4L2_CTRL_CLASS_FM_TX/constant and their Control IDs./para
/listitem
listitem
+   paraAdded FM Receiver (FM RX) Extended Control Class: 
constantV4L2_CTRL_CLASS_FM_RX/constant and their Control IDs./para
+   /listitem
+   listitem
  paraAdded Remote Controller chapter, describing the default Remote 
Controller mapping for media devices./para
/listitem
   /orderedlist
diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index b84f25e..ced2bee 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3018,6 +3018,12 @@ to find receivers which can scroll strings sized as 32 x 
N or 64 x N characters.
 with steps of 32 or 64 characters. The result is it must always contain a 
string with size multiple of 32 or 64. /entry
  /row
  row
+ entry 
spanname=idconstantV4L2_CID_RDS_TX_AF_FREQ/constantnbsp;/entry
+ entryinteger/entry
+ /row
+ rowentry spanname=descrSets the RDS Alternate Frequency value 
which allows a receiver to re-tune to a different frequency providing the same 
station when the first signal becomes too weak (e.g., when moving out of 
range). /entry
+ /row
+ row
entry 
spanname=idconstantV4L2_CID_AUDIO_LIMITER_ENABLED/constantnbsp;/entry
entryboolean/entry
  /row
@@ -3146,6 +3152,77 @@ manually or automatically if set to zero. Unit, range 
and step are driver-specif
 xref linkend=en50067 / document, from CENELEC./para
 /section
 
+section id=fm-rx-controls
+  titleFM Receiver Control Reference/title
+
+  paraThe FM Receiver (FM_RX) class includes controls for common 
features of
+FM Reception capable devices./para
+
+  table pgwide=1 frame=none id=fm-rx-control-id
+  titleFM_RX 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=leftID/entry
+entry align=leftType/entry
+  /rowrow rowsep=1entry spanname=descr 
align=leftDescription/entry
+  /row
+/thead
+tbody valign=top
+  rowentry/entry/row
+  row
+entry 
spanname=idconstantV4L2_CID_FM_RX_CLASS/constantnbsp;/entry
+entryclass/entry
+  /rowrowentry spanname=descrThe FM_RX class
+descriptor. Calling VIDIOC-QUERYCTRL; for this control will return a
+description of this control class./entry
+  /row
+  row
+entry 
spanname=idconstantV4L2_CID_RDS_AF_SWITCH/constantnbsp;/entry
+entryboolean/entry
+  /row
+  rowentry spanname=descrEnable or Disable the RDS Alternate 
frequency feature. When enabled the driver will decode the RDS AF field and 
tries to switch to this AF frequency once the current frequency RSSI (Received 
signal strength indication) level goes below the threshold. If the frequency is 
switched, then VIDIOC-G-FREQUENCY; will return the new frequency./entry
+  /row
+  row
+   entry 
spanname=idconstantV4L2_CID_TUNE_DEEMPHASIS/constantnbsp;/entry
+   entryinteger/entry
+ /row
+ row id=v4l2-deemphasisentry spanname=descrConfigures the 
de-emphasis value for reception.
+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 enumnbsp;v4l2_preemphasis
+defines possible values for pre-emphasis. Here 

[PATCH V6 0/5] [Media] Radio: Fixes and New features for FM

2012-05-14 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

Mauro and the list,

This version 6 of patchset resolves the comments received from
Han's on patchset v5.
 
This patchset creates new control class 'V4L2_CTRL_CLASS_FM_RX' for FM RX,
introduces 2 new CID's for FM RX and and 1 new CID for FM TX. Also adds 1
field in struct v4l2_hw_freq_seek.
  
This patch adds few new features to TI's FM driver features
are listed below,
   
1) FM TX RDS Support (RT, PS, AF, PI, PTY)  
2) FM RX Russian band support
3) FM RX AF set/get
4) FM RX De-emphasis mode set/get

Along with new features this patch also fixes few issues in the driver
like default rssi level for seek, unnecessory logs etc.

Manjunatha Halli (5):
  WL128x: Add support for FM TX RDS
  New control class and features for FM RX
  Add new CID for FM TX RDS Alternate Frequency
  Media: Update docs for V4L2 FM new features
  WL12xx: Add support for FM new features.

 Documentation/DocBook/media/v4l/compat.xml |3 +
 Documentation/DocBook/media/v4l/controls.xml   |   77 ++
 Documentation/DocBook/media/v4l/dev-rds.xml|5 +-
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   |7 +
 Documentation/DocBook/media/v4l/vidioc-g-tuner.xml |   25 
 .../DocBook/media/v4l/vidioc-s-hw-freq-seek.xml|   38 +-
 drivers/media/radio/wl128x/fmdrv.h |3 +-
 drivers/media/radio/wl128x/fmdrv_common.c  |   55 ++--
 drivers/media/radio/wl128x/fmdrv_common.h  |   43 +-
 drivers/media/radio/wl128x/fmdrv_rx.c  |   92 ++---
 drivers/media/radio/wl128x/fmdrv_rx.h  |2 +-
 drivers/media/radio/wl128x/fmdrv_tx.c  |   41 +++---
 drivers/media/radio/wl128x/fmdrv_tx.h  |3 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c|  148 +++-
 drivers/media/video/v4l2-ctrls.c   |   18 ++-
 include/linux/videodev2.h  |   25 +++-
 16 files changed, 503 insertions(+), 82 deletions(-)

-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V6 3/5] Add new CID for FM TX RDS Alternate Frequency

2012-05-14 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/video/v4l2-ctrls.c |1 +
 include/linux/videodev2.h|1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 9d7608e..610076c 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -608,6 +608,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_RDS_TX_PTY:   return RDS Program Type;
case V4L2_CID_RDS_TX_PS_NAME:   return RDS PS Name;
case V4L2_CID_RDS_TX_RADIO_TEXT:return RDS Radio Text;
+   case V4L2_CID_RDS_TX_AF_FREQ:   return RDS Alternate 
Frequency;
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;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 91bc47b..3931a99 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1699,6 +1699,7 @@ enum  v4l2_exposure_auto_type {
 #define V4L2_CID_RDS_TX_PTY(V4L2_CID_FM_TX_CLASS_BASE + 3)
 #define V4L2_CID_RDS_TX_PS_NAME
(V4L2_CID_FM_TX_CLASS_BASE + 5)
 #define V4L2_CID_RDS_TX_RADIO_TEXT (V4L2_CID_FM_TX_CLASS_BASE + 6)
+#define V4L2_CID_RDS_TX_AF_FREQ
(V4L2_CID_FM_TX_CLASS_BASE + 7)
 
 #define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 64)
 #define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME(V4L2_CID_FM_TX_CLASS_BASE + 65)
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V6 2/5] New control class and features for FM RX

2012-05-14 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch creates new ctrl class for FM RX and adds new CID's for
below FM features,
  1) De-Emphasis filter mode
  2) RDS Alternate Frequency switch

Also this patch adds a field for band selection in struct v4l2_hw_freq_seek
and adds new capability flags for all below FM bands
1) V4L2_TUNER_CAP_BAND_TYPE_DEFAULT - Default Band
2) V4L2_TUNER_CAP_BAND_TYPE_EUROPE_US - Europe/US Band
3) V4L2_TUNER_CAP_BAND_TYPE_JAPAN   - Japan Band
4) V4L2_TUNER_CAP_BAND_TYPE_RUSSIAN - Russian Band
5) V4L2_TUNER_CAP_BAND_TYPE_WEATHER - Weather Band

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/video/v4l2-ctrls.c |   17 ++---
 include/linux/videodev2.h|   24 +++-
 2 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 18015c0..9d7608e 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -243,8 +243,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
Vivid,
NULL
};
-   static const char * const tune_preemphasis[] = {
-   No Preemphasis,
+   static const char * const tune_emphasis[] = {
+   None,
50 Microseconds,
75 Microseconds,
NULL,
@@ -413,7 +413,9 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
case V4L2_CID_COLORFX:
return colorfx;
case V4L2_CID_TUNE_PREEMPHASIS:
-   return tune_preemphasis;
+   return tune_emphasis;
+   case V4L2_CID_TUNE_DEEMPHASIS:
+   return tune_emphasis;
case V4L2_CID_FLASH_LED_MODE:
return flash_led_mode;
case V4L2_CID_FLASH_STROBE_SOURCE:
@@ -644,6 +646,12 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_JPEG_COMPRESSION_QUALITY: return Compression Quality;
case V4L2_CID_JPEG_ACTIVE_MARKER:   return Active Markers;
 
+   /* FM Radio Receiver control */
+   /* Keep the order of the 'case's the same as in videodev2.h! */
+   case V4L2_CID_FM_RX_CLASS:  return FM Radio Receiver 
Controls;
+   case V4L2_CID_RDS_AF_SWITCH:return RDS Alternate Frequency 
Switch;
+   case V4L2_CID_TUNE_DEEMPHASIS:  return De-Emphasis;
+
default:
return NULL;
}
@@ -688,6 +696,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM:
case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE:
case V4L2_CID_MPEG_VIDEO_MPEG4_QPEL:
+   case V4L2_CID_RDS_AF_SWITCH:
*type = V4L2_CTRL_TYPE_BOOLEAN;
*min = 0;
*max = *step = 1;
@@ -733,6 +742,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL:
case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE:
case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
+   case V4L2_CID_TUNE_DEEMPHASIS:
*type = V4L2_CTRL_TYPE_MENU;
break;
case V4L2_CID_RDS_TX_PS_NAME:
@@ -745,6 +755,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_FM_TX_CLASS:
case V4L2_CID_FLASH_CLASS:
case V4L2_CID_JPEG_CLASS:
+   case V4L2_CID_FM_RX_CLASS:
*type = V4L2_CTRL_TYPE_CTRL_CLASS;
/* You can neither read not write these */
*flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index c9c9a46..91bc47b 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1137,6 +1137,7 @@ struct v4l2_ext_controls {
 #define V4L2_CTRL_CLASS_FM_TX 0x009b   /* FM Modulator control class */
 #define V4L2_CTRL_CLASS_FLASH 0x009c   /* Camera flash controls */
 #define V4L2_CTRL_CLASS_JPEG 0x009d/* JPEG-compression 
controls */
+#define V4L2_CTRL_CLASS_FM_RX 0x009e   /* FM Receiver control class */
 
 #define V4L2_CTRL_ID_MASK(0x0fff)
 #define V4L2_CTRL_ID2CLASS(id)((id)  0x0fffUL)
@@ -1782,6 +1783,13 @@ enum v4l2_jpeg_chroma_subsampling {
 #defineV4L2_JPEG_ACTIVE_MARKER_DQT (1  17)
 #defineV4L2_JPEG_ACTIVE_MARKER_DHT (1  18)
 
+/* FM Receiver class control IDs */
+#define V4L2_CID_FM_RX_CLASS_BASE  (V4L2_CTRL_CLASS_FM_RX | 0x900)
+#define V4L2_CID_FM_RX_CLASS   (V4L2_CTRL_CLASS_FM_RX | 1)
+
+#define V4L2_CID_RDS_AF_SWITCH (V4L2_CID_FM_RX_CLASS_BASE + 1)
+#define V4L2_CID_TUNE_DEEMPHASIS   (V4L2_CID_FM_RX_CLASS_BASE + 2)
+
 /*
  * T U N I N G
  */
@@ -1819,6 +1827,12 @@ struct v4l2_modulator {
 #define V4L2_TUNER_CAP_RDS 

[PATCH V6 1/5] WL128x: Add support for FM TX RDS

2012-05-14 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch adds support for following FM TX RDS features,
 1. Radio Text
 2. PS Name
 3. PI Code
 4. PTY Code.

Along with above this patch fixes few other minor issues(like
fm tx get frequency, unnecessary error messages etc).

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_common.c |   17 +++---
 drivers/media/radio/wl128x/fmdrv_common.h |   17 +++
 drivers/media/radio/wl128x/fmdrv_rx.c |2 +-
 drivers/media/radio/wl128x/fmdrv_tx.c |   41 ++---
 drivers/media/radio/wl128x/fmdrv_tx.h |3 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |   47 +
 6 files changed, 90 insertions(+), 37 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index bf867a6..fcce61a 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -354,7 +354,7 @@ static void send_tasklet(unsigned long arg)
 
/* Check, is there any timeout happened to last transmitted packet */
if ((jiffies - fmdev-last_tx_jiffies)  FM_DRV_TX_TIMEOUT) {
-   fmerr(TX timeout occurred\n);
+   fmdbg(TX timeout occurred\n);
atomic_set(fmdev-tx_cnt, 1);
}
 
@@ -615,7 +615,11 @@ static void fm_irq_handle_rds_start(struct fmdev *fmdev)
 {
if (fmdev-irq_info.flag  FM_RDS_EVENT  fmdev-irq_info.mask) {
fmdbg(irq: rds threshold reached\n);
-   fmdev-irq_info.stage = FM_RDS_SEND_RDS_GETCMD_IDX;
+   /* If RSSI reached below threshold then dont get RDS data */
+   if (fmdev-irq_info.flag  FM_LEV_EVENT)
+   fmdev-irq_info.stage = FM_HW_TUNE_OP_ENDED_IDX;
+   else
+   fmdev-irq_info.stage = FM_RDS_SEND_RDS_GETCMD_IDX;
} else {
/* Continue next function in interrupt handler table */
fmdev-irq_info.stage = FM_HW_TUNE_OP_ENDED_IDX;
@@ -1129,8 +1133,9 @@ int fmc_set_freq(struct fmdev *fmdev, u32 freq_to_set)
 
 int fmc_get_freq(struct fmdev *fmdev, u32 *cur_tuned_frq)
 {
-   if (fmdev-rx.freq == FM_UNDEFINED_FREQ) {
-   fmerr(RX frequency is not set\n);
+   if (fmdev-rx.freq == FM_UNDEFINED_FREQ 
+   fmdev-tx_data.tx_frq == FM_UNDEFINED_FREQ) {
+   fmerr(RX/TX frequency is not set\n);
return -EPERM;
}
if (cur_tuned_frq == NULL) {
@@ -1144,7 +1149,7 @@ int fmc_get_freq(struct fmdev *fmdev, u32 *cur_tuned_frq)
return 0;
 
case FM_MODE_TX:
-   *cur_tuned_frq = 0; /* TODO : Change this later */
+   *cur_tuned_frq = fmdev-tx_data.tx_frq;
return 0;
 
default:
@@ -1574,6 +1579,8 @@ int fmc_prepare(struct fmdev *fmdev)
fmdev-rx.af_mode = FM_RX_RDS_AF_SWITCH_MODE_OFF;
fmdev-irq_info.retry = 0;
 
+   fmdev-tx_data.tx_frq = FM_UNDEFINED_FREQ;
+
fm_rx_reset_rds_cache(fmdev);
init_waitqueue_head(fmdev-rx.rds.read_queue);
 
diff --git a/drivers/media/radio/wl128x/fmdrv_common.h 
b/drivers/media/radio/wl128x/fmdrv_common.h
index d9b9c6c..196ff7d 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.h
+++ b/drivers/media/radio/wl128x/fmdrv_common.h
@@ -48,8 +48,8 @@ struct fm_reg_table {
 #define SEARCH_LVL_SET   15
 #define BAND_SET 16
 #define MUTE_STATUS_SET  17
-#define RDS_PAUSE_LVL_SET18
-#define RDS_PAUSE_DUR_SET19
+#define AUD_PAUSE_LVL_SET18
+#define AUD_PAUSE_DUR_SET19
 #define RDS_MEM_SET  20
 #define RDS_BLK_B_SET21
 #define RDS_MSK_B_SET22
@@ -84,11 +84,12 @@ struct fm_reg_table {
 
 #define FM_POWER_MODE254
 #define FM_INTERRUPT 255
+#define STATION_VALID   123
 
 /* Transmitter API */
 
 #define CHANL_SET55
-#define CHANL_BW_SET   56
+#define SCAN_SPACING_SET 56
 #define REF_SET  57
 #define POWER_ENB_SET90
 #define POWER_ATT_SET58
@@ -103,7 +104,8 @@ struct fm_reg_table {
 #define MONO_SET 66
 #define MUTE 92
 #define MPX_LMT_ENABLE   67
-#define PI_SET   93
+#define REF_ERR_SET 93
+#define PI_SET   68
 #define ECC_SET  69
 #define PTY  70
 #define AF   71
@@ -120,6 +122,10 @@ struct fm_reg_table {
 #define TX_AUDIO_LEVEL_TEST  96
 #define TX_AUDIO_LEVEL_TEST_THRESHOLD73
 #define TX_AUDIO_INPUT_LEVEL_RANGE_SET   54
+#define TX_AUDIO_LEVEL_GET  7
+#define READ_FMANT_TUNE_VALUE104
+
+/* New FM APIs (Rx and Tx) */
 #define RX_ANTENNA_SELECT87
 #define I2C_DEV_ADDR_SET 86
 #define REF_ERR_CALIB_PARAM_SET  

[PATCH V6 0/5] [Media] Radio: Fixes and New features for FM

2012-05-14 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

Mauro and the list,

Fixed version 6 of patchset 2/5.
 
This version 6 of patchset resolves the comments received from
Han's on patchset v5.
 
This patchset creates new control class 'V4L2_CTRL_CLASS_FM_RX' for FM RX,
introduces 2 new CID's for FM RX and and 1 new CID for FM TX. Also adds 1
field in struct v4l2_hw_freq_seek.
  
This patch adds few new features to TI's FM driver features
are listed below,
   
1) FM TX RDS Support (RT, PS, AF, PI, PTY)  
2) FM RX Russian band support
3) FM RX AF set/get
4) FM RX De-emphasis mode set/get

Along with new features this patch also fixes few issues in the driver
like default rssi level for seek, unnecessory logs etc.

Manjunatha Halli (5):
  WL128x: Add support for FM TX RDS
  New control class and features for FM RX
  Add new CID for FM TX RDS Alternate Frequency
  Media: Update docs for V4L2 FM new features
  WL12xx: Add support for FM new features.

 Documentation/DocBook/media/v4l/compat.xml |3 +
 Documentation/DocBook/media/v4l/controls.xml   |   77 ++
 Documentation/DocBook/media/v4l/dev-rds.xml|5 +-
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   |7 +
 Documentation/DocBook/media/v4l/vidioc-g-tuner.xml |   25 
 .../DocBook/media/v4l/vidioc-s-hw-freq-seek.xml|   38 +-
 drivers/media/radio/wl128x/fmdrv.h |3 +-
 drivers/media/radio/wl128x/fmdrv_common.c  |   55 ++--
 drivers/media/radio/wl128x/fmdrv_common.h  |   43 +-
 drivers/media/radio/wl128x/fmdrv_rx.c  |   92 ++---
 drivers/media/radio/wl128x/fmdrv_rx.h  |2 +-
 drivers/media/radio/wl128x/fmdrv_tx.c  |   41 +++---
 drivers/media/radio/wl128x/fmdrv_tx.h  |3 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c|  148 +++-
 drivers/media/video/v4l2-ctrls.c   |   18 ++-
 include/linux/videodev2.h  |   25 +++-
 16 files changed, 503 insertions(+), 82 deletions(-)

-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V6 3/5] Add new CID for FM TX RDS Alternate Frequency

2012-05-14 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/video/v4l2-ctrls.c |1 +
 include/linux/videodev2.h|1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 9d7608e..610076c 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -608,6 +608,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_RDS_TX_PTY:   return RDS Program Type;
case V4L2_CID_RDS_TX_PS_NAME:   return RDS PS Name;
case V4L2_CID_RDS_TX_RADIO_TEXT:return RDS Radio Text;
+   case V4L2_CID_RDS_TX_AF_FREQ:   return RDS Alternate 
Frequency;
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;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 7b3dd95..b16d603 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1699,6 +1699,7 @@ enum  v4l2_exposure_auto_type {
 #define V4L2_CID_RDS_TX_PTY(V4L2_CID_FM_TX_CLASS_BASE + 3)
 #define V4L2_CID_RDS_TX_PS_NAME
(V4L2_CID_FM_TX_CLASS_BASE + 5)
 #define V4L2_CID_RDS_TX_RADIO_TEXT (V4L2_CID_FM_TX_CLASS_BASE + 6)
+#define V4L2_CID_RDS_TX_AF_FREQ
(V4L2_CID_FM_TX_CLASS_BASE + 7)
 
 #define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 64)
 #define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME(V4L2_CID_FM_TX_CLASS_BASE + 65)
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V6 5/5] WL12xx: Add support for FM new features.

2012-05-14 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch adds below features to TI's V4l2 FM driver for Wilink
chipsets,

1) FM RX Set frequency allows to set frequency anywhere between
65.5 MHz till 108 MHz (if chip is Wilink8 then till 164.55 MHz)
2) FM RX seek caters for band switch
3) FM RX RDS AF turn ON/OFF
4) FM RX De-Emphasis mode set/get
5) FM TX Alternate Frequency set/get

Also this patch fixes below issues

1) FM audio volume gain setting
2) Default rssi level is set to 8 instead of 20
3) Issue related to audio mute/unmute
4) Enable FM RX AF support in driver
5) In wrap_around seek mode try for once

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/radio/wl128x/fmdrv.h|3 +-
 drivers/media/radio/wl128x/fmdrv_common.c |   38 +--
 drivers/media/radio/wl128x/fmdrv_common.h |   28 +++-
 drivers/media/radio/wl128x/fmdrv_rx.c |   90 -
 drivers/media/radio/wl128x/fmdrv_rx.h |2 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |  101 +++--
 6 files changed, 224 insertions(+), 38 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv.h 
b/drivers/media/radio/wl128x/fmdrv.h
index d84ad9d..c806c85 100644
--- a/drivers/media/radio/wl128x/fmdrv.h
+++ b/drivers/media/radio/wl128x/fmdrv.h
@@ -150,6 +150,7 @@ struct fm_rx {
struct region_info region;  /* Current selected band */
u32 freq;   /* Current RX frquency */
u8 mute_mode;   /* Current mute mode */
+   u8 bl_flag; /* Band limit reached flag */
u8 deemphasis_mode; /* Current deemphasis mode */
/* RF dependent soft mute mode */
u8 rf_depend_mute;
@@ -203,7 +204,7 @@ struct fmtx_data {
 struct fmdev {
struct video_device *radio_dev; /* V4L2 video device pointer */
struct snd_card *card;  /* Card which holds FM mixer controls */
-   u16 asci_id;
+   u16 asic_id;
spinlock_t rds_buff_lock; /* To protect access to RDS buffer */
spinlock_t resp_skb_lock; /* To protect access to received SKB */
 
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index fcce61a..ac20556 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -44,20 +44,41 @@
 
 /* Region info */
 static struct region_info region_configs[] = {
+   /* Super set of all bands */
+   {
+.chanl_space = FM_CHANNEL_SPACING_200KHZ * FM_FREQ_MUL,
+.bot_freq = 65800, /* 87.5 MHz */
+.top_freq = 162550,/* 108 MHz */
+.fm_band = 0,
+},
/* Europe/US */
{
 .chanl_space = FM_CHANNEL_SPACING_200KHZ * FM_FREQ_MUL,
 .bot_freq = 87500, /* 87.5 MHz */
 .top_freq = 108000,/* 108 MHz */
-.fm_band = 0,
+.fm_band = 1,
 },
/* Japan */
{
 .chanl_space = FM_CHANNEL_SPACING_200KHZ * FM_FREQ_MUL,
 .bot_freq = 76000, /* 76 MHz */
 .top_freq = 9, /* 90 MHz */
-.fm_band = 1,
+.fm_band = 2,
 },
+   /* Russian (OIRT) band */
+   {
+   .chanl_space = FM_CHANNEL_SPACING_50KHZ * FM_FREQ_MUL_RUS,
+   .bot_freq = 65800, /* 65.8 MHz */
+   .top_freq = 74000, /* 74 MHz */
+   .fm_band = 3,
+   },
+   /* Wether Band */
+   {
+   .chanl_space = FM_CHANNEL_SPACING_50KHZ * FM_FREQ_MUL_WB,
+   .bot_freq = 162400, /* 162.4 MHz */
+   .top_freq = 162550, /* 162.55 MHz */
+   .fm_band = 4,
+   }
 };
 
 /* Band selection */
@@ -596,7 +617,6 @@ static void fm_irq_handle_flag_getcmd_resp(struct fmdev 
*fmdev)
memcpy(fmdev-irq_info.flag, skb-data, fm_evt_hdr-dlen);
 
fmdev-irq_info.flag = be16_to_cpu(fmdev-irq_info.flag);
-   fmdbg(irq: flag register(0x%x)\n, fmdev-irq_info.flag);
 
/* Continue next function in interrupt handler table */
fm_irq_call_stage(fmdev, FM_HW_MAL_FUNC_IDX);
@@ -702,7 +722,7 @@ static void fm_rdsparse_swapbytes(struct fmdev *fmdev,
 * in Dolphin they are in big endian, the parsing of the RDS data
 * is chip dependent
 */
-   if (fmdev-asci_id != 0x6350) {
+   if (fmdev-asic_id != 0x6350) {
rds_buff = rds_format-data.groupdatabuff.buff[0];
while (index + 1  FM_RX_RDS_INFO_FIELD_MAX) {
byte1 = rds_buff[index];
@@ -1353,11 +1373,13 @@ static int fm_power_up(struct fmdev *fmdev, u8 mode)
sizeof(asic_ver), asic_ver, resp_len))
goto rel;
 
+   fmdev-asic_id = be16_to_cpu(asic_id);
+
fmdbg(ASIC ID: 0x%x , ASIC Version: %d\n,
-   be16_to_cpu(asic_id), be16_to_cpu(asic_ver));
+   fmdev-asic_id, be16_to_cpu(asic_ver));
 
sprintf(fw_name, %s_%x.%d.bts, FM_FMC_FW_FILE_START,
-  

[PATCH V6 4/5] Media: Update docs for V4L2 FM new features

2012-05-14 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

The list of new features -
1) New control class for FM RX
2) New FM RX CID's - De-Emphasis filter mode and RDS AF switch
3) New FM TX CID - RDS Alternate frequency set.
4) New capability struct v4l2_tuner flags for band selection

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 Documentation/DocBook/media/v4l/compat.xml |3 +
 Documentation/DocBook/media/v4l/controls.xml   |   77 
 Documentation/DocBook/media/v4l/dev-rds.xml|5 +-
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   |7 ++
 Documentation/DocBook/media/v4l/vidioc-g-tuner.xml |   25 +++
 .../DocBook/media/v4l/vidioc-s-hw-freq-seek.xml|   38 +-
 6 files changed, 151 insertions(+), 4 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/compat.xml 
b/Documentation/DocBook/media/v4l/compat.xml
index bce97c5..df1f345 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2311,6 +2311,9 @@ more information./para
  paraAdded FM Modulator (FM TX) Extended Control Class: 
constantV4L2_CTRL_CLASS_FM_TX/constant and their Control IDs./para
/listitem
listitem
+   paraAdded FM Receiver (FM RX) Extended Control Class: 
constantV4L2_CTRL_CLASS_FM_RX/constant and their Control IDs./para
+   /listitem
+   listitem
  paraAdded Remote Controller chapter, describing the default Remote 
Controller mapping for media devices./para
/listitem
   /orderedlist
diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index b84f25e..ced2bee 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3018,6 +3018,12 @@ to find receivers which can scroll strings sized as 32 x 
N or 64 x N characters.
 with steps of 32 or 64 characters. The result is it must always contain a 
string with size multiple of 32 or 64. /entry
  /row
  row
+ entry 
spanname=idconstantV4L2_CID_RDS_TX_AF_FREQ/constantnbsp;/entry
+ entryinteger/entry
+ /row
+ rowentry spanname=descrSets the RDS Alternate Frequency value 
which allows a receiver to re-tune to a different frequency providing the same 
station when the first signal becomes too weak (e.g., when moving out of 
range). /entry
+ /row
+ row
entry 
spanname=idconstantV4L2_CID_AUDIO_LIMITER_ENABLED/constantnbsp;/entry
entryboolean/entry
  /row
@@ -3146,6 +3152,77 @@ manually or automatically if set to zero. Unit, range 
and step are driver-specif
 xref linkend=en50067 / document, from CENELEC./para
 /section
 
+section id=fm-rx-controls
+  titleFM Receiver Control Reference/title
+
+  paraThe FM Receiver (FM_RX) class includes controls for common 
features of
+FM Reception capable devices./para
+
+  table pgwide=1 frame=none id=fm-rx-control-id
+  titleFM_RX 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=leftID/entry
+entry align=leftType/entry
+  /rowrow rowsep=1entry spanname=descr 
align=leftDescription/entry
+  /row
+/thead
+tbody valign=top
+  rowentry/entry/row
+  row
+entry 
spanname=idconstantV4L2_CID_FM_RX_CLASS/constantnbsp;/entry
+entryclass/entry
+  /rowrowentry spanname=descrThe FM_RX class
+descriptor. Calling VIDIOC-QUERYCTRL; for this control will return a
+description of this control class./entry
+  /row
+  row
+entry 
spanname=idconstantV4L2_CID_RDS_AF_SWITCH/constantnbsp;/entry
+entryboolean/entry
+  /row
+  rowentry spanname=descrEnable or Disable the RDS Alternate 
frequency feature. When enabled the driver will decode the RDS AF field and 
tries to switch to this AF frequency once the current frequency RSSI (Received 
signal strength indication) level goes below the threshold. If the frequency is 
switched, then VIDIOC-G-FREQUENCY; will return the new frequency./entry
+  /row
+  row
+   entry 
spanname=idconstantV4L2_CID_TUNE_DEEMPHASIS/constantnbsp;/entry
+   entryinteger/entry
+ /row
+ row id=v4l2-deemphasisentry spanname=descrConfigures the 
de-emphasis value for reception.
+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 enumnbsp;v4l2_preemphasis
+defines possible values for pre-emphasis. Here 

[PATCH V6 2/5] New control class and features for FM RX

2012-05-14 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch creates new ctrl class for FM RX and adds new CID's for
below FM features,
  1) De-Emphasis filter mode
  2) RDS Alternate Frequency switch

Also this patch adds a field for band selection in struct v4l2_hw_freq_seek
and adds new capability flags for all below FM bands
1) V4L2_TUNER_CAP_BAND_TYPE_DEFAULT - Default Band
2) V4L2_TUNER_CAP_BAND_TYPE_EUROPE_US - Europe/US Band
3) V4L2_TUNER_CAP_BAND_TYPE_JAPAN   - Japan Band
4) V4L2_TUNER_CAP_BAND_TYPE_RUSSIAN - Russian Band
5) V4L2_TUNER_CAP_BAND_TYPE_WEATHER - Weather Band

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/video/v4l2-ctrls.c |   17 ++---
 include/linux/videodev2.h|   24 +++-
 2 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 18015c0..9d7608e 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -243,8 +243,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
Vivid,
NULL
};
-   static const char * const tune_preemphasis[] = {
-   No Preemphasis,
+   static const char * const tune_emphasis[] = {
+   None,
50 Microseconds,
75 Microseconds,
NULL,
@@ -413,7 +413,9 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
case V4L2_CID_COLORFX:
return colorfx;
case V4L2_CID_TUNE_PREEMPHASIS:
-   return tune_preemphasis;
+   return tune_emphasis;
+   case V4L2_CID_TUNE_DEEMPHASIS:
+   return tune_emphasis;
case V4L2_CID_FLASH_LED_MODE:
return flash_led_mode;
case V4L2_CID_FLASH_STROBE_SOURCE:
@@ -644,6 +646,12 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_JPEG_COMPRESSION_QUALITY: return Compression Quality;
case V4L2_CID_JPEG_ACTIVE_MARKER:   return Active Markers;
 
+   /* FM Radio Receiver control */
+   /* Keep the order of the 'case's the same as in videodev2.h! */
+   case V4L2_CID_FM_RX_CLASS:  return FM Radio Receiver 
Controls;
+   case V4L2_CID_RDS_AF_SWITCH:return RDS Alternate Frequency 
Switch;
+   case V4L2_CID_TUNE_DEEMPHASIS:  return De-Emphasis;
+
default:
return NULL;
}
@@ -688,6 +696,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM:
case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE:
case V4L2_CID_MPEG_VIDEO_MPEG4_QPEL:
+   case V4L2_CID_RDS_AF_SWITCH:
*type = V4L2_CTRL_TYPE_BOOLEAN;
*min = 0;
*max = *step = 1;
@@ -733,6 +742,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL:
case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE:
case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
+   case V4L2_CID_TUNE_DEEMPHASIS:
*type = V4L2_CTRL_TYPE_MENU;
break;
case V4L2_CID_RDS_TX_PS_NAME:
@@ -745,6 +755,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_FM_TX_CLASS:
case V4L2_CID_FLASH_CLASS:
case V4L2_CID_JPEG_CLASS:
+   case V4L2_CID_FM_RX_CLASS:
*type = V4L2_CTRL_TYPE_CTRL_CLASS;
/* You can neither read not write these */
*flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index c9c9a46..7b3dd95 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1137,6 +1137,7 @@ struct v4l2_ext_controls {
 #define V4L2_CTRL_CLASS_FM_TX 0x009b   /* FM Modulator control class */
 #define V4L2_CTRL_CLASS_FLASH 0x009c   /* Camera flash controls */
 #define V4L2_CTRL_CLASS_JPEG 0x009d/* JPEG-compression 
controls */
+#define V4L2_CTRL_CLASS_FM_RX 0x009e   /* FM Receiver control class */
 
 #define V4L2_CTRL_ID_MASK(0x0fff)
 #define V4L2_CTRL_ID2CLASS(id)((id)  0x0fffUL)
@@ -1782,6 +1783,13 @@ enum v4l2_jpeg_chroma_subsampling {
 #defineV4L2_JPEG_ACTIVE_MARKER_DQT (1  17)
 #defineV4L2_JPEG_ACTIVE_MARKER_DHT (1  18)
 
+/* FM Receiver class control IDs */
+#define V4L2_CID_FM_RX_CLASS_BASE  (V4L2_CTRL_CLASS_FM_RX | 0x900)
+#define V4L2_CID_FM_RX_CLASS   (V4L2_CTRL_CLASS_FM_RX | 1)
+
+#define V4L2_CID_RDS_AF_SWITCH (V4L2_CID_FM_RX_CLASS_BASE + 1)
+#define V4L2_CID_TUNE_DEEMPHASIS   (V4L2_CID_FM_RX_CLASS_BASE + 2)
+
 /*
  * T U N I N G
  */
@@ -1819,6 +1827,12 @@ struct v4l2_modulator {
 #define V4L2_TUNER_CAP_RDS 

[PATCH V6 1/5] WL128x: Add support for FM TX RDS

2012-05-14 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch adds support for following FM TX RDS features,
 1. Radio Text
 2. PS Name
 3. PI Code
 4. PTY Code.

Along with above this patch fixes few other minor issues(like
fm tx get frequency, unnecessary error messages etc).

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_common.c |   17 +++---
 drivers/media/radio/wl128x/fmdrv_common.h |   17 +++
 drivers/media/radio/wl128x/fmdrv_rx.c |2 +-
 drivers/media/radio/wl128x/fmdrv_tx.c |   41 ++---
 drivers/media/radio/wl128x/fmdrv_tx.h |3 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |   47 +
 6 files changed, 90 insertions(+), 37 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index bf867a6..fcce61a 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -354,7 +354,7 @@ static void send_tasklet(unsigned long arg)
 
/* Check, is there any timeout happened to last transmitted packet */
if ((jiffies - fmdev-last_tx_jiffies)  FM_DRV_TX_TIMEOUT) {
-   fmerr(TX timeout occurred\n);
+   fmdbg(TX timeout occurred\n);
atomic_set(fmdev-tx_cnt, 1);
}
 
@@ -615,7 +615,11 @@ static void fm_irq_handle_rds_start(struct fmdev *fmdev)
 {
if (fmdev-irq_info.flag  FM_RDS_EVENT  fmdev-irq_info.mask) {
fmdbg(irq: rds threshold reached\n);
-   fmdev-irq_info.stage = FM_RDS_SEND_RDS_GETCMD_IDX;
+   /* If RSSI reached below threshold then dont get RDS data */
+   if (fmdev-irq_info.flag  FM_LEV_EVENT)
+   fmdev-irq_info.stage = FM_HW_TUNE_OP_ENDED_IDX;
+   else
+   fmdev-irq_info.stage = FM_RDS_SEND_RDS_GETCMD_IDX;
} else {
/* Continue next function in interrupt handler table */
fmdev-irq_info.stage = FM_HW_TUNE_OP_ENDED_IDX;
@@ -1129,8 +1133,9 @@ int fmc_set_freq(struct fmdev *fmdev, u32 freq_to_set)
 
 int fmc_get_freq(struct fmdev *fmdev, u32 *cur_tuned_frq)
 {
-   if (fmdev-rx.freq == FM_UNDEFINED_FREQ) {
-   fmerr(RX frequency is not set\n);
+   if (fmdev-rx.freq == FM_UNDEFINED_FREQ 
+   fmdev-tx_data.tx_frq == FM_UNDEFINED_FREQ) {
+   fmerr(RX/TX frequency is not set\n);
return -EPERM;
}
if (cur_tuned_frq == NULL) {
@@ -1144,7 +1149,7 @@ int fmc_get_freq(struct fmdev *fmdev, u32 *cur_tuned_frq)
return 0;
 
case FM_MODE_TX:
-   *cur_tuned_frq = 0; /* TODO : Change this later */
+   *cur_tuned_frq = fmdev-tx_data.tx_frq;
return 0;
 
default:
@@ -1574,6 +1579,8 @@ int fmc_prepare(struct fmdev *fmdev)
fmdev-rx.af_mode = FM_RX_RDS_AF_SWITCH_MODE_OFF;
fmdev-irq_info.retry = 0;
 
+   fmdev-tx_data.tx_frq = FM_UNDEFINED_FREQ;
+
fm_rx_reset_rds_cache(fmdev);
init_waitqueue_head(fmdev-rx.rds.read_queue);
 
diff --git a/drivers/media/radio/wl128x/fmdrv_common.h 
b/drivers/media/radio/wl128x/fmdrv_common.h
index d9b9c6c..196ff7d 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.h
+++ b/drivers/media/radio/wl128x/fmdrv_common.h
@@ -48,8 +48,8 @@ struct fm_reg_table {
 #define SEARCH_LVL_SET   15
 #define BAND_SET 16
 #define MUTE_STATUS_SET  17
-#define RDS_PAUSE_LVL_SET18
-#define RDS_PAUSE_DUR_SET19
+#define AUD_PAUSE_LVL_SET18
+#define AUD_PAUSE_DUR_SET19
 #define RDS_MEM_SET  20
 #define RDS_BLK_B_SET21
 #define RDS_MSK_B_SET22
@@ -84,11 +84,12 @@ struct fm_reg_table {
 
 #define FM_POWER_MODE254
 #define FM_INTERRUPT 255
+#define STATION_VALID   123
 
 /* Transmitter API */
 
 #define CHANL_SET55
-#define CHANL_BW_SET   56
+#define SCAN_SPACING_SET 56
 #define REF_SET  57
 #define POWER_ENB_SET90
 #define POWER_ATT_SET58
@@ -103,7 +104,8 @@ struct fm_reg_table {
 #define MONO_SET 66
 #define MUTE 92
 #define MPX_LMT_ENABLE   67
-#define PI_SET   93
+#define REF_ERR_SET 93
+#define PI_SET   68
 #define ECC_SET  69
 #define PTY  70
 #define AF   71
@@ -120,6 +122,10 @@ struct fm_reg_table {
 #define TX_AUDIO_LEVEL_TEST  96
 #define TX_AUDIO_LEVEL_TEST_THRESHOLD73
 #define TX_AUDIO_INPUT_LEVEL_RANGE_SET   54
+#define TX_AUDIO_LEVEL_GET  7
+#define READ_FMANT_TUNE_VALUE104
+
+/* New FM APIs (Rx and Tx) */
 #define RX_ANTENNA_SELECT87
 #define I2C_DEV_ADDR_SET 86
 #define REF_ERR_CALIB_PARAM_SET  

[PATCH V4 5/5] WL12xx: Add support for FM new features.

2012-05-04 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch adds below features to TI's V4l2 FM driver for Wilink
chipsets,

1) FM RX Set frequency allows to set frequency anywhere between
65.5 MHz till 108 MHz (if chip is Wilink8 then till 164.55 MHz)
2) FM RX seek caters for band switch
3) FM RX RDS AF turn ON/OFF
4) FM RX De-Emphasis mode set/get
5) FM TX Alternate Frequency set/get

Also this patch fixes below issues

1) FM audio volume gain setting
2) Default rssi level is set to 8 instead of 20
3) Issue related to audio mute/unmute
4) Enable FM RX AF support in driver
5) In wrap_around seek mode try for once

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/radio/wl128x/fmdrv.h|3 +-
 drivers/media/radio/wl128x/fmdrv_common.c |   38 ++---
 drivers/media/radio/wl128x/fmdrv_common.h |   28 -
 drivers/media/radio/wl128x/fmdrv_rx.c |   90 +++--
 drivers/media/radio/wl128x/fmdrv_rx.h |2 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |   91 +++--
 6 files changed, 215 insertions(+), 37 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv.h 
b/drivers/media/radio/wl128x/fmdrv.h
index d84ad9d..c806c85 100644
--- a/drivers/media/radio/wl128x/fmdrv.h
+++ b/drivers/media/radio/wl128x/fmdrv.h
@@ -150,6 +150,7 @@ struct fm_rx {
struct region_info region;  /* Current selected band */
u32 freq;   /* Current RX frquency */
u8 mute_mode;   /* Current mute mode */
+   u8 bl_flag; /* Band limit reached flag */
u8 deemphasis_mode; /* Current deemphasis mode */
/* RF dependent soft mute mode */
u8 rf_depend_mute;
@@ -203,7 +204,7 @@ struct fmtx_data {
 struct fmdev {
struct video_device *radio_dev; /* V4L2 video device pointer */
struct snd_card *card;  /* Card which holds FM mixer controls */
-   u16 asci_id;
+   u16 asic_id;
spinlock_t rds_buff_lock; /* To protect access to RDS buffer */
spinlock_t resp_skb_lock; /* To protect access to received SKB */
 
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index fcce61a..ac20556 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -44,20 +44,41 @@
 
 /* Region info */
 static struct region_info region_configs[] = {
+   /* Super set of all bands */
+   {
+.chanl_space = FM_CHANNEL_SPACING_200KHZ * FM_FREQ_MUL,
+.bot_freq = 65800, /* 87.5 MHz */
+.top_freq = 162550,/* 108 MHz */
+.fm_band = 0,
+},
/* Europe/US */
{
 .chanl_space = FM_CHANNEL_SPACING_200KHZ * FM_FREQ_MUL,
 .bot_freq = 87500, /* 87.5 MHz */
 .top_freq = 108000,/* 108 MHz */
-.fm_band = 0,
+.fm_band = 1,
 },
/* Japan */
{
 .chanl_space = FM_CHANNEL_SPACING_200KHZ * FM_FREQ_MUL,
 .bot_freq = 76000, /* 76 MHz */
 .top_freq = 9, /* 90 MHz */
-.fm_band = 1,
+.fm_band = 2,
 },
+   /* Russian (OIRT) band */
+   {
+   .chanl_space = FM_CHANNEL_SPACING_50KHZ * FM_FREQ_MUL_RUS,
+   .bot_freq = 65800, /* 65.8 MHz */
+   .top_freq = 74000, /* 74 MHz */
+   .fm_band = 3,
+   },
+   /* Wether Band */
+   {
+   .chanl_space = FM_CHANNEL_SPACING_50KHZ * FM_FREQ_MUL_WB,
+   .bot_freq = 162400, /* 162.4 MHz */
+   .top_freq = 162550, /* 162.55 MHz */
+   .fm_band = 4,
+   }
 };
 
 /* Band selection */
@@ -596,7 +617,6 @@ static void fm_irq_handle_flag_getcmd_resp(struct fmdev 
*fmdev)
memcpy(fmdev-irq_info.flag, skb-data, fm_evt_hdr-dlen);
 
fmdev-irq_info.flag = be16_to_cpu(fmdev-irq_info.flag);
-   fmdbg(irq: flag register(0x%x)\n, fmdev-irq_info.flag);
 
/* Continue next function in interrupt handler table */
fm_irq_call_stage(fmdev, FM_HW_MAL_FUNC_IDX);
@@ -702,7 +722,7 @@ static void fm_rdsparse_swapbytes(struct fmdev *fmdev,
 * in Dolphin they are in big endian, the parsing of the RDS data
 * is chip dependent
 */
-   if (fmdev-asci_id != 0x6350) {
+   if (fmdev-asic_id != 0x6350) {
rds_buff = rds_format-data.groupdatabuff.buff[0];
while (index + 1  FM_RX_RDS_INFO_FIELD_MAX) {
byte1 = rds_buff[index];
@@ -1353,11 +1373,13 @@ static int fm_power_up(struct fmdev *fmdev, u8 mode)
sizeof(asic_ver), asic_ver, resp_len))
goto rel;
 
+   fmdev-asic_id = be16_to_cpu(asic_id);
+
fmdbg(ASIC ID: 0x%x , ASIC Version: %d\n,
-   be16_to_cpu(asic_id), be16_to_cpu(asic_ver));
+   fmdev-asic_id, be16_to_cpu(asic_ver));
 
sprintf(fw_name, %s_%x.%d.bts, FM_FMC_FW_FILE_START,

[PATCH V4 4/5] Media: Update docs for V4L2 FM new features

2012-05-04 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

The list of new features -
1) New control class for FM RX
2) New FM RX CID's - De-Emphasis filter mode and RDS AF switch
3) New FM TX CID - RDS Alternate frequency set.

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 Documentation/DocBook/media/v4l/compat.xml |3 +
 Documentation/DocBook/media/v4l/controls.xml   |   77 
 Documentation/DocBook/media/v4l/dev-rds.xml|5 +-
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   |7 ++
 .../DocBook/media/v4l/vidioc-s-hw-freq-seek.xml|   35 +-
 5 files changed, 124 insertions(+), 3 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/compat.xml 
b/Documentation/DocBook/media/v4l/compat.xml
index bce97c5..df1f345 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2311,6 +2311,9 @@ more information./para
  paraAdded FM Modulator (FM TX) Extended Control Class: 
constantV4L2_CTRL_CLASS_FM_TX/constant and their Control IDs./para
/listitem
listitem
+   paraAdded FM Receiver (FM RX) Extended Control Class: 
constantV4L2_CTRL_CLASS_FM_RX/constant and their Control IDs./para
+   /listitem
+   listitem
  paraAdded Remote Controller chapter, describing the default Remote 
Controller mapping for media devices./para
/listitem
   /orderedlist
diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index b84f25e..b831dd7 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3018,6 +3018,12 @@ to find receivers which can scroll strings sized as 32 x 
N or 64 x N characters.
 with steps of 32 or 64 characters. The result is it must always contain a 
string with size multiple of 32 or 64. /entry
  /row
  row
+ entry 
spanname=idconstantV4L2_CID_RDS_TX_AF_FREQ/constantnbsp;/entry
+ entryinteger/entry
+ /row
+ rowentry spanname=descrSets the RDS Alternate Frequency value 
which allows a receiver to re-tune to a different frequency providing the same 
station when the first signal becomes too weak (e.g., when moving out of 
range). /entry
+ /row
+ row
entry 
spanname=idconstantV4L2_CID_AUDIO_LIMITER_ENABLED/constantnbsp;/entry
entryboolean/entry
  /row
@@ -3146,6 +3152,77 @@ manually or automatically if set to zero. Unit, range 
and step are driver-specif
 xref linkend=en50067 / document, from CENELEC./para
 /section
 
+section id=fm-rx-controls
+  titleFM Receiver Control Reference/title
+
+  paraThe FM Receiver (FM_RX) class includes controls for common 
features of
+FM Reception capable devices./para
+
+  table pgwide=1 frame=none id=fm-rx-control-id
+  titleFM_RX 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=leftID/entry
+entry align=leftType/entry
+  /rowrow rowsep=1entry spanname=descr 
align=leftDescription/entry
+  /row
+/thead
+tbody valign=top
+  rowentry/entry/row
+  row
+entry 
spanname=idconstantV4L2_CID_FM_RX_CLASS/constantnbsp;/entry
+entryclass/entry
+  /rowrowentry spanname=descrThe FM_RX class
+descriptor. Calling VIDIOC-QUERYCTRL; for this control will return a
+description of this control class./entry
+  /row
+  row
+entry 
spanname=idconstantV4L2_CID_RDS_AF_SWITCH/constantnbsp;/entry
+entryboolean/entry
+  /row
+  rowentry spanname=descrEnable or Disable the RDS Alternate 
frequency feature. When enabled the driver will decode the RDS AF field and 
tries to switch to this AF frequency once the current frequency RSSI level goes 
below the threshold. If the frequency is switched, then VIDIOC-G-FREQUENCY; 
will return the new frequency./entry
+  /row
+  row
+   entry 
spanname=idconstantV4L2_CID_TUNE_DEEMPHASIS/constantnbsp;/entry
+   entryinteger/entry
+ /row
+ row id=v4l2-deemphasisentry spanname=descrConfigures the 
de-emphasis value for reception.
+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 enumnbsp;v4l2_preemphasis
+defines possible values for pre-emphasis. Here they are:/entry
+   /rowrow
+   entrytbl spanname=descr cols=2
+ tbody valign=top
+   row
+ 

[PATCH V4 3/5] Add new CID for FM TX RDS Alternate Frequency

2012-05-04 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/video/v4l2-ctrls.c |1 +
 include/linux/videodev2.h|1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 9d7608e..610076c 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -608,6 +608,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_RDS_TX_PTY:   return RDS Program Type;
case V4L2_CID_RDS_TX_PS_NAME:   return RDS PS Name;
case V4L2_CID_RDS_TX_RADIO_TEXT:return RDS Radio Text;
+   case V4L2_CID_RDS_TX_AF_FREQ:   return RDS Alternate 
Frequency;
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;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 534a3f1..e7a8e96 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1699,6 +1699,7 @@ enum  v4l2_exposure_auto_type {
 #define V4L2_CID_RDS_TX_PTY(V4L2_CID_FM_TX_CLASS_BASE + 3)
 #define V4L2_CID_RDS_TX_PS_NAME
(V4L2_CID_FM_TX_CLASS_BASE + 5)
 #define V4L2_CID_RDS_TX_RADIO_TEXT (V4L2_CID_FM_TX_CLASS_BASE + 6)
+#define V4L2_CID_RDS_TX_AF_FREQ
(V4L2_CID_FM_TX_CLASS_BASE + 7)
 
 #define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 64)
 #define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME(V4L2_CID_FM_TX_CLASS_BASE + 65)
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V4 1/5] WL128x: Add support for FM TX RDS

2012-05-04 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch adds support for following FM TX RDS features,
 1. Radio Text
 2. PS Name
 3. PI Code
 4. PTY Code.

Along with above this patch fixes few other minor issues(like
fm tx get frequency, unnecessary error messages etc).

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_common.c |   17 +++---
 drivers/media/radio/wl128x/fmdrv_common.h |   17 +++
 drivers/media/radio/wl128x/fmdrv_rx.c |2 +-
 drivers/media/radio/wl128x/fmdrv_tx.c |   41 ++---
 drivers/media/radio/wl128x/fmdrv_tx.h |3 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |   47 +
 6 files changed, 90 insertions(+), 37 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index bf867a6..fcce61a 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -354,7 +354,7 @@ static void send_tasklet(unsigned long arg)
 
/* Check, is there any timeout happened to last transmitted packet */
if ((jiffies - fmdev-last_tx_jiffies)  FM_DRV_TX_TIMEOUT) {
-   fmerr(TX timeout occurred\n);
+   fmdbg(TX timeout occurred\n);
atomic_set(fmdev-tx_cnt, 1);
}
 
@@ -615,7 +615,11 @@ static void fm_irq_handle_rds_start(struct fmdev *fmdev)
 {
if (fmdev-irq_info.flag  FM_RDS_EVENT  fmdev-irq_info.mask) {
fmdbg(irq: rds threshold reached\n);
-   fmdev-irq_info.stage = FM_RDS_SEND_RDS_GETCMD_IDX;
+   /* If RSSI reached below threshold then dont get RDS data */
+   if (fmdev-irq_info.flag  FM_LEV_EVENT)
+   fmdev-irq_info.stage = FM_HW_TUNE_OP_ENDED_IDX;
+   else
+   fmdev-irq_info.stage = FM_RDS_SEND_RDS_GETCMD_IDX;
} else {
/* Continue next function in interrupt handler table */
fmdev-irq_info.stage = FM_HW_TUNE_OP_ENDED_IDX;
@@ -1129,8 +1133,9 @@ int fmc_set_freq(struct fmdev *fmdev, u32 freq_to_set)
 
 int fmc_get_freq(struct fmdev *fmdev, u32 *cur_tuned_frq)
 {
-   if (fmdev-rx.freq == FM_UNDEFINED_FREQ) {
-   fmerr(RX frequency is not set\n);
+   if (fmdev-rx.freq == FM_UNDEFINED_FREQ 
+   fmdev-tx_data.tx_frq == FM_UNDEFINED_FREQ) {
+   fmerr(RX/TX frequency is not set\n);
return -EPERM;
}
if (cur_tuned_frq == NULL) {
@@ -1144,7 +1149,7 @@ int fmc_get_freq(struct fmdev *fmdev, u32 *cur_tuned_frq)
return 0;
 
case FM_MODE_TX:
-   *cur_tuned_frq = 0; /* TODO : Change this later */
+   *cur_tuned_frq = fmdev-tx_data.tx_frq;
return 0;
 
default:
@@ -1574,6 +1579,8 @@ int fmc_prepare(struct fmdev *fmdev)
fmdev-rx.af_mode = FM_RX_RDS_AF_SWITCH_MODE_OFF;
fmdev-irq_info.retry = 0;
 
+   fmdev-tx_data.tx_frq = FM_UNDEFINED_FREQ;
+
fm_rx_reset_rds_cache(fmdev);
init_waitqueue_head(fmdev-rx.rds.read_queue);
 
diff --git a/drivers/media/radio/wl128x/fmdrv_common.h 
b/drivers/media/radio/wl128x/fmdrv_common.h
index d9b9c6c..196ff7d 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.h
+++ b/drivers/media/radio/wl128x/fmdrv_common.h
@@ -48,8 +48,8 @@ struct fm_reg_table {
 #define SEARCH_LVL_SET   15
 #define BAND_SET 16
 #define MUTE_STATUS_SET  17
-#define RDS_PAUSE_LVL_SET18
-#define RDS_PAUSE_DUR_SET19
+#define AUD_PAUSE_LVL_SET18
+#define AUD_PAUSE_DUR_SET19
 #define RDS_MEM_SET  20
 #define RDS_BLK_B_SET21
 #define RDS_MSK_B_SET22
@@ -84,11 +84,12 @@ struct fm_reg_table {
 
 #define FM_POWER_MODE254
 #define FM_INTERRUPT 255
+#define STATION_VALID   123
 
 /* Transmitter API */
 
 #define CHANL_SET55
-#define CHANL_BW_SET   56
+#define SCAN_SPACING_SET 56
 #define REF_SET  57
 #define POWER_ENB_SET90
 #define POWER_ATT_SET58
@@ -103,7 +104,8 @@ struct fm_reg_table {
 #define MONO_SET 66
 #define MUTE 92
 #define MPX_LMT_ENABLE   67
-#define PI_SET   93
+#define REF_ERR_SET 93
+#define PI_SET   68
 #define ECC_SET  69
 #define PTY  70
 #define AF   71
@@ -120,6 +122,10 @@ struct fm_reg_table {
 #define TX_AUDIO_LEVEL_TEST  96
 #define TX_AUDIO_LEVEL_TEST_THRESHOLD73
 #define TX_AUDIO_INPUT_LEVEL_RANGE_SET   54
+#define TX_AUDIO_LEVEL_GET  7
+#define READ_FMANT_TUNE_VALUE104
+
+/* New FM APIs (Rx and Tx) */
 #define RX_ANTENNA_SELECT87
 #define I2C_DEV_ADDR_SET 86
 #define REF_ERR_CALIB_PARAM_SET  

[PATCH V4 0/5] [Media] Radio: Fixes and New features for FM

2012-05-04 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

Mauro and the list,

This version 4 of patchset resolves the comments received from
Han's on patchset v3.

This patchset creates new control class 'V4L2_CTRL_CLASS_FM_RX' for FM RX,
introduces 2 new CID's for FM RX and and 1 new CID for FM TX. Also adds 1
field in struct v4l2_hw_freq_seek.

This patch adds few new features to TI's FM driver features
are listed below,

1) FM TX RDS Support (RT, PS, AF, PI, PTY)
2) FM RX Russian band support
3) FM RX AF set/get
4) FM RX De-emphasis mode set/get

Along with new features this patch also fixes few issues in the driver
like default rssi level for seek, unnecessory logs etc.

Manjunatha Halli (5):
  WL128x: Add support for FM TX RDS
  New control class and features for FM RX
  Add new CID for FM TX RDS Alternate Frequency
  Media: Update docs for V4L2 FM new features
  WL12xx: Add support for FM new features.

 Documentation/DocBook/media/v4l/compat.xml |3 +
 Documentation/DocBook/media/v4l/controls.xml   |   77 +++
 Documentation/DocBook/media/v4l/dev-rds.xml|5 +-
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   |7 +
 .../DocBook/media/v4l/vidioc-s-hw-freq-seek.xml|   35 +-
 drivers/media/radio/wl128x/fmdrv.h |3 +-
 drivers/media/radio/wl128x/fmdrv_common.c  |   55 ++--
 drivers/media/radio/wl128x/fmdrv_common.h  |   43 +-
 drivers/media/radio/wl128x/fmdrv_rx.c  |   92 ++---
 drivers/media/radio/wl128x/fmdrv_rx.h  |2 +-
 drivers/media/radio/wl128x/fmdrv_tx.c  |   41 +++
 drivers/media/radio/wl128x/fmdrv_tx.h  |3 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c|  138 +++-
 drivers/media/video/v4l2-ctrls.c   |   18 ++-
 include/linux/videodev2.h  |   20 +++-
 15 files changed, 462 insertions(+), 80 deletions(-)

-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V4 2/5] New control class and features for FM RX

2012-05-04 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch creates new ctrl class for FM RX and adds new CID's for
below FM features,
  1) De-Emphasis filter mode
  2) RDS Alternate Frequency switch

Also this patch adds a field for band selection in struct v4l2_hw_freq_seek

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/video/v4l2-ctrls.c |   17 ++---
 include/linux/videodev2.h|   19 ++-
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 18015c0..9d7608e 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -243,8 +243,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
Vivid,
NULL
};
-   static const char * const tune_preemphasis[] = {
-   No Preemphasis,
+   static const char * const tune_emphasis[] = {
+   None,
50 Microseconds,
75 Microseconds,
NULL,
@@ -413,7 +413,9 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
case V4L2_CID_COLORFX:
return colorfx;
case V4L2_CID_TUNE_PREEMPHASIS:
-   return tune_preemphasis;
+   return tune_emphasis;
+   case V4L2_CID_TUNE_DEEMPHASIS:
+   return tune_emphasis;
case V4L2_CID_FLASH_LED_MODE:
return flash_led_mode;
case V4L2_CID_FLASH_STROBE_SOURCE:
@@ -644,6 +646,12 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_JPEG_COMPRESSION_QUALITY: return Compression Quality;
case V4L2_CID_JPEG_ACTIVE_MARKER:   return Active Markers;
 
+   /* FM Radio Receiver control */
+   /* Keep the order of the 'case's the same as in videodev2.h! */
+   case V4L2_CID_FM_RX_CLASS:  return FM Radio Receiver 
Controls;
+   case V4L2_CID_RDS_AF_SWITCH:return RDS Alternate Frequency 
Switch;
+   case V4L2_CID_TUNE_DEEMPHASIS:  return De-Emphasis;
+
default:
return NULL;
}
@@ -688,6 +696,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM:
case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE:
case V4L2_CID_MPEG_VIDEO_MPEG4_QPEL:
+   case V4L2_CID_RDS_AF_SWITCH:
*type = V4L2_CTRL_TYPE_BOOLEAN;
*min = 0;
*max = *step = 1;
@@ -733,6 +742,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL:
case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE:
case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
+   case V4L2_CID_TUNE_DEEMPHASIS:
*type = V4L2_CTRL_TYPE_MENU;
break;
case V4L2_CID_RDS_TX_PS_NAME:
@@ -745,6 +755,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_FM_TX_CLASS:
case V4L2_CID_FLASH_CLASS:
case V4L2_CID_JPEG_CLASS:
+   case V4L2_CID_FM_RX_CLASS:
*type = V4L2_CTRL_TYPE_CTRL_CLASS;
/* You can neither read not write these */
*flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index c9c9a46..534a3f1 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1137,6 +1137,7 @@ struct v4l2_ext_controls {
 #define V4L2_CTRL_CLASS_FM_TX 0x009b   /* FM Modulator control class */
 #define V4L2_CTRL_CLASS_FLASH 0x009c   /* Camera flash controls */
 #define V4L2_CTRL_CLASS_JPEG 0x009d/* JPEG-compression 
controls */
+#define V4L2_CTRL_CLASS_FM_RX 0x009e   /* FM Receiver control class */
 
 #define V4L2_CTRL_ID_MASK(0x0fff)
 #define V4L2_CTRL_ID2CLASS(id)((id)  0x0fffUL)
@@ -1782,6 +1783,13 @@ enum v4l2_jpeg_chroma_subsampling {
 #defineV4L2_JPEG_ACTIVE_MARKER_DQT (1  17)
 #defineV4L2_JPEG_ACTIVE_MARKER_DHT (1  18)
 
+/* FM Receiver class control IDs */
+#define V4L2_CID_FM_RX_CLASS_BASE  (V4L2_CTRL_CLASS_FM_RX | 0x900)
+#define V4L2_CID_FM_RX_CLASS   (V4L2_CTRL_CLASS_FM_RX | 1)
+
+#define V4L2_CID_RDS_AF_SWITCH (V4L2_CID_FM_RX_CLASS_BASE + 1)
+#define V4L2_CID_TUNE_DEEMPHASIS   (V4L2_CID_FM_RX_CLASS_BASE + 2)
+
 /*
  * T U N I N G
  */
@@ -1843,13 +1851,22 @@ struct v4l2_frequency {
__u32 reserved[8];
 };
 
+
+#define FM_BAND_TYPE_ALL   0   /* All Bands 65.8 MHz till 108 Mhz
+  or 162.55 MHz if weather band */
+#define FM_BAND_TYPE_EUROPE_US 1   /* 87.5 Mhz - 108 MHz*/
+#define FM_BAND_TYPE_JAPAN 2   /* 76 MHz - 90 MHz*/
+#define FM_BAND_TYPE_RUSSIAN   3   /* 65.8 MHz - 74 MHz*/
+#define 

[PATCH V3 4/5] [Documentation] Media: Update docs for V4L2 FM new features

2012-05-02 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

The list of new features -
1) New control class for FM RX
2) New FM RX CID's - De-Emphasis filter mode and RDS AF switch
3) New FM TX CID - RDS Alternate frequency set.

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 Documentation/DocBook/media/v4l/compat.xml |3 +
 Documentation/DocBook/media/v4l/controls.xml   |   78 
 Documentation/DocBook/media/v4l/dev-rds.xml|5 +-
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   |7 ++
 .../DocBook/media/v4l/vidioc-s-hw-freq-seek.xml|7 ++-
 5 files changed, 97 insertions(+), 3 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/compat.xml 
b/Documentation/DocBook/media/v4l/compat.xml
index bce97c5..df1f345 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2311,6 +2311,9 @@ more information./para
  paraAdded FM Modulator (FM TX) Extended Control Class: 
constantV4L2_CTRL_CLASS_FM_TX/constant and their Control IDs./para
/listitem
listitem
+   paraAdded FM Receiver (FM RX) Extended Control Class: 
constantV4L2_CTRL_CLASS_FM_RX/constant and their Control IDs./para
+   /listitem
+   listitem
  paraAdded Remote Controller chapter, describing the default Remote 
Controller mapping for media devices./para
/listitem
   /orderedlist
diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index b84f25e..b6e4db2 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3018,6 +3018,12 @@ to find receivers which can scroll strings sized as 32 x 
N or 64 x N characters.
 with steps of 32 or 64 characters. The result is it must always contain a 
string with size multiple of 32 or 64. /entry
  /row
  row
+ entry 
spanname=idconstantV4L2_CID_RDS_TX_AF_FREQ/constantnbsp;/entry
+ entryinteger/entry
+ /row
+ rowentry spanname=descrSets the RDS Alternate Frequency value 
which allows a receiver to re-tune to a different frequency providing the same 
station when the first signal becomes too weak (e.g., when moving out of 
range). /entry
+ /row
+ row
entry 
spanname=idconstantV4L2_CID_AUDIO_LIMITER_ENABLED/constantnbsp;/entry
entryboolean/entry
  /row
@@ -3146,6 +3152,78 @@ manually or automatically if set to zero. Unit, range 
and step are driver-specif
 xref linkend=en50067 / document, from CENELEC./para
 /section
 
+section id=fm-rx-controls
+  titleFM Receiver Control Reference/title
+
+  paraThe FM Receiver (FM_RX) class includes controls for common 
features of
+FM Reception capable devices. Currently this class includes parameter for 
Alternate
+frequency./para
+
+  table pgwide=1 frame=none id=fm-rx-control-id
+  titleFM_RX 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=leftID/entry
+entry align=leftType/entry
+  /rowrow rowsep=1entry spanname=descr 
align=leftDescription/entry
+  /row
+/thead
+tbody valign=top
+  rowentry/entry/row
+  row
+entry 
spanname=idconstantV4L2_CID_FM_RX_CLASS/constantnbsp;/entry
+entryclass/entry
+  /rowrowentry spanname=descrThe FM_RX class
+descriptor. Calling VIDIOC-QUERYCTRL; for this control will return a
+description of this control class./entry
+  /row
+  row
+entry 
spanname=idconstantV4L2_CID_RDS_AF_SWITCH/constantnbsp;/entry
+entryboolean/entry
+  /row
+  rowentry spanname=descrEnable/Disable's FM RX RDS Alternate 
frequency feature. When enabled driver will decode the RDS AF field and tries 
to switch to this AF frequency once current frequency RSSI level goes below 
threshold. Value of G_FREQUENCY is unchanged since both original frequency and 
AF frequency share the same PI code./entry
+  /row
+  row
+   entry 
spanname=idconstantV4L2_CID_TUNE_DEEMPHASIS/constantnbsp;/entry
+   entryinteger/entry
+ /row
+ row id=v4l2-deemphasisentry spanname=descrConfigures the 
de-emphasis value for reception.
+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 enumnbsp;v4l2_preemphasis
+defines possible values for pre-emphasis. Here they are:/entry
+   /rowrow
+   entrytbl spanname=descr cols=2
+ tbody valign=top
+  

[PATCH V3 5/5] [Media] WL12xx: Add support for FM new features.

2012-05-02 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch adds below features to TI's V4l2 FM driver for Wilink
chipsets,

1) FM RX Set frequency allows to set frequency anywhere between
65.5 MHz till 108 MHz (if chip is Wilink8 then till 164.55 MHz)
2) FM RX seek caters for band switch
3) FM RX RDS AF turn ON/OFF
4) FM RX De-Emphasis mode set/get
5) FM TX Alternate Frequency set/get

Also this patch fixes below issues

1) FM audio volume gain setting
2) Default rssi level is set to 8 instead of 20
3) Issue related to audio mute/unmute
4) Enable FM RX AF support in driver
5) In wrap_around seek mode try for once

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/radio/wl128x/fmdrv.h|3 +-
 drivers/media/radio/wl128x/fmdrv_common.c |   38 ++---
 drivers/media/radio/wl128x/fmdrv_common.h |   28 -
 drivers/media/radio/wl128x/fmdrv_rx.c |   90 +++--
 drivers/media/radio/wl128x/fmdrv_rx.h |2 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |   91 +++--
 6 files changed, 215 insertions(+), 37 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv.h 
b/drivers/media/radio/wl128x/fmdrv.h
index d84ad9d..c806c85 100644
--- a/drivers/media/radio/wl128x/fmdrv.h
+++ b/drivers/media/radio/wl128x/fmdrv.h
@@ -150,6 +150,7 @@ struct fm_rx {
struct region_info region;  /* Current selected band */
u32 freq;   /* Current RX frquency */
u8 mute_mode;   /* Current mute mode */
+   u8 bl_flag; /* Band limit reached flag */
u8 deemphasis_mode; /* Current deemphasis mode */
/* RF dependent soft mute mode */
u8 rf_depend_mute;
@@ -203,7 +204,7 @@ struct fmtx_data {
 struct fmdev {
struct video_device *radio_dev; /* V4L2 video device pointer */
struct snd_card *card;  /* Card which holds FM mixer controls */
-   u16 asci_id;
+   u16 asic_id;
spinlock_t rds_buff_lock; /* To protect access to RDS buffer */
spinlock_t resp_skb_lock; /* To protect access to received SKB */
 
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index fcce61a..ac20556 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -44,20 +44,41 @@
 
 /* Region info */
 static struct region_info region_configs[] = {
+   /* Super set of all bands */
+   {
+.chanl_space = FM_CHANNEL_SPACING_200KHZ * FM_FREQ_MUL,
+.bot_freq = 65800, /* 87.5 MHz */
+.top_freq = 162550,/* 108 MHz */
+.fm_band = 0,
+},
/* Europe/US */
{
 .chanl_space = FM_CHANNEL_SPACING_200KHZ * FM_FREQ_MUL,
 .bot_freq = 87500, /* 87.5 MHz */
 .top_freq = 108000,/* 108 MHz */
-.fm_band = 0,
+.fm_band = 1,
 },
/* Japan */
{
 .chanl_space = FM_CHANNEL_SPACING_200KHZ * FM_FREQ_MUL,
 .bot_freq = 76000, /* 76 MHz */
 .top_freq = 9, /* 90 MHz */
-.fm_band = 1,
+.fm_band = 2,
 },
+   /* Russian (OIRT) band */
+   {
+   .chanl_space = FM_CHANNEL_SPACING_50KHZ * FM_FREQ_MUL_RUS,
+   .bot_freq = 65800, /* 65.8 MHz */
+   .top_freq = 74000, /* 74 MHz */
+   .fm_band = 3,
+   },
+   /* Wether Band */
+   {
+   .chanl_space = FM_CHANNEL_SPACING_50KHZ * FM_FREQ_MUL_WB,
+   .bot_freq = 162400, /* 162.4 MHz */
+   .top_freq = 162550, /* 162.55 MHz */
+   .fm_band = 4,
+   }
 };
 
 /* Band selection */
@@ -596,7 +617,6 @@ static void fm_irq_handle_flag_getcmd_resp(struct fmdev 
*fmdev)
memcpy(fmdev-irq_info.flag, skb-data, fm_evt_hdr-dlen);
 
fmdev-irq_info.flag = be16_to_cpu(fmdev-irq_info.flag);
-   fmdbg(irq: flag register(0x%x)\n, fmdev-irq_info.flag);
 
/* Continue next function in interrupt handler table */
fm_irq_call_stage(fmdev, FM_HW_MAL_FUNC_IDX);
@@ -702,7 +722,7 @@ static void fm_rdsparse_swapbytes(struct fmdev *fmdev,
 * in Dolphin they are in big endian, the parsing of the RDS data
 * is chip dependent
 */
-   if (fmdev-asci_id != 0x6350) {
+   if (fmdev-asic_id != 0x6350) {
rds_buff = rds_format-data.groupdatabuff.buff[0];
while (index + 1  FM_RX_RDS_INFO_FIELD_MAX) {
byte1 = rds_buff[index];
@@ -1353,11 +1373,13 @@ static int fm_power_up(struct fmdev *fmdev, u8 mode)
sizeof(asic_ver), asic_ver, resp_len))
goto rel;
 
+   fmdev-asic_id = be16_to_cpu(asic_id);
+
fmdbg(ASIC ID: 0x%x , ASIC Version: %d\n,
-   be16_to_cpu(asic_id), be16_to_cpu(asic_ver));
+   fmdev-asic_id, be16_to_cpu(asic_ver));
 
sprintf(fw_name, %s_%x.%d.bts, FM_FMC_FW_FILE_START,

[PATCH V3 3/5] [Media] Add new CID for FM TX RDS Alternate Frequency

2012-05-02 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/video/v4l2-ctrls.c |1 +
 include/linux/videodev2.h|1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index e1bba7d..b4ddd6b 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -614,6 +614,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_RDS_TX_PTY:   return RDS Program Type;
case V4L2_CID_RDS_TX_PS_NAME:   return RDS PS Name;
case V4L2_CID_RDS_TX_RADIO_TEXT:return RDS Radio Text;
+   case V4L2_CID_RDS_TX_AF_FREQ:   return RDS Alternate 
Frequency;
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;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index f94acfd..2514658 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1699,6 +1699,7 @@ enum  v4l2_exposure_auto_type {
 #define V4L2_CID_RDS_TX_PTY(V4L2_CID_FM_TX_CLASS_BASE + 3)
 #define V4L2_CID_RDS_TX_PS_NAME
(V4L2_CID_FM_TX_CLASS_BASE + 5)
 #define V4L2_CID_RDS_TX_RADIO_TEXT (V4L2_CID_FM_TX_CLASS_BASE + 6)
+#define V4L2_CID_RDS_TX_AF_FREQ
(V4L2_CID_FM_TX_CLASS_BASE + 7)
 
 #define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 64)
 #define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME(V4L2_CID_FM_TX_CLASS_BASE + 65)
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V3 0/5] [Media] Radio: Fixes and New features for FM

2012-05-02 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

Mauro and the list,

This version 3 of patchset resolves the comments received from
Han's on patchset v2.
  
This patchset creates new control class 'V4L2_CTRL_CLASS_FM_RX' for FM RX,
introduces 2 new CID's for FM RX and and 1 new CID for FM TX. Also adds 1
field in struct v4l2_hw_freq_seek.

This patch adds few new features to TI's FM driver features
are listed below,
   
1) FM TX RDS Support (RT, PS, AF, PI, PTY)
2) FM RX Russian band support
3) FM RX AF set/get
4) FM RX De-emphasis mode set/get

Along with new features this patch also fixes few issues in the driver
like default rssi level for seek, unnecessory logs etc.

Manjunatha Halli (5):
  [Media] WL128x: Add support for FM TX RDS
  [Media] New control class and features for FM RX
  [Media] Add new CID for FM TX RDS Alternate Frequency
  [Documentation] Media: Update docs for V4L2 FM new features
  [Media] WL12xx: Add support for FM new features.

 Documentation/DocBook/media/v4l/compat.xml |3 +
 Documentation/DocBook/media/v4l/controls.xml   |   78 +++
 Documentation/DocBook/media/v4l/dev-rds.xml|5 +-
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   |7 +
 .../DocBook/media/v4l/vidioc-s-hw-freq-seek.xml|7 +-
 drivers/media/radio/wl128x/fmdrv.h |3 +-
 drivers/media/radio/wl128x/fmdrv_common.c  |   55 ++--
 drivers/media/radio/wl128x/fmdrv_common.h  |   43 +-
 drivers/media/radio/wl128x/fmdrv_rx.c  |   92 ++---
 drivers/media/radio/wl128x/fmdrv_rx.h  |2 +-
 drivers/media/radio/wl128x/fmdrv_tx.c  |   41 +++
 drivers/media/radio/wl128x/fmdrv_tx.h  |3 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c|  138 +++-
 drivers/media/video/v4l2-ctrls.c   |   18 +++
 include/linux/videodev2.h  |   12 ++-
 15 files changed, 430 insertions(+), 77 deletions(-)

-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V3 2/5] [Media] New control class and features for FM RX

2012-05-02 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch creates new ctrl class for FM RX and adds new CID's for
below FM features,
1) De-Emphasis filter mode
2) RDS AF switch

Also this patch adds a field for band selection in struct v4l2_hw_freq_seek

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/video/v4l2-ctrls.c |   17 +
 include/linux/videodev2.h|   11 ++-
 2 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 18015c0..e1bba7d 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -372,6 +372,12 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
NULL,
};
 
+   static const char * const tune_deemphasis[] = {
+   No deemphasis,
+   50 useconds,
+   75 useconds,
+   NULL,
+   };
switch (id) {
case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ:
return mpeg_audio_sampling_freq;
@@ -414,6 +420,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
return colorfx;
case V4L2_CID_TUNE_PREEMPHASIS:
return tune_preemphasis;
+   case V4L2_CID_TUNE_DEEMPHASIS:
+   return tune_deemphasis;
case V4L2_CID_FLASH_LED_MODE:
return flash_led_mode;
case V4L2_CID_FLASH_STROBE_SOURCE:
@@ -644,6 +652,12 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_JPEG_COMPRESSION_QUALITY: return Compression Quality;
case V4L2_CID_JPEG_ACTIVE_MARKER:   return Active Markers;
 
+   /* FM Radio Receiver control */
+   /* Keep the order of the 'case's the same as in videodev2.h! */
+   case V4L2_CID_FM_RX_CLASS:  return FM Radio Receiver 
Controls;
+   case V4L2_CID_RDS_AF_SWITCH:return FM RX RDS AF switch;
+   case V4L2_CID_TUNE_DEEMPHASIS:  return FM RX De-emphasis 
settings;
+
default:
return NULL;
}
@@ -688,6 +702,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM:
case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE:
case V4L2_CID_MPEG_VIDEO_MPEG4_QPEL:
+   case V4L2_CID_RDS_AF_SWITCH:
*type = V4L2_CTRL_TYPE_BOOLEAN;
*min = 0;
*max = *step = 1;
@@ -733,6 +748,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL:
case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE:
case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
+   case V4L2_CID_TUNE_DEEMPHASIS:
*type = V4L2_CTRL_TYPE_MENU;
break;
case V4L2_CID_RDS_TX_PS_NAME:
@@ -745,6 +761,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_FM_TX_CLASS:
case V4L2_CID_FLASH_CLASS:
case V4L2_CID_JPEG_CLASS:
+   case V4L2_CID_FM_RX_CLASS:
*type = V4L2_CTRL_TYPE_CTRL_CLASS;
/* You can neither read not write these */
*flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index c9c9a46..f94acfd 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1137,6 +1137,7 @@ struct v4l2_ext_controls {
 #define V4L2_CTRL_CLASS_FM_TX 0x009b   /* FM Modulator control class */
 #define V4L2_CTRL_CLASS_FLASH 0x009c   /* Camera flash controls */
 #define V4L2_CTRL_CLASS_JPEG 0x009d/* JPEG-compression 
controls */
+#define V4L2_CTRL_CLASS_FM_RX 0x009e   /* FM Receiver control class */
 
 #define V4L2_CTRL_ID_MASK(0x0fff)
 #define V4L2_CTRL_ID2CLASS(id)((id)  0x0fffUL)
@@ -1782,6 +1783,13 @@ enum v4l2_jpeg_chroma_subsampling {
 #defineV4L2_JPEG_ACTIVE_MARKER_DQT (1  17)
 #defineV4L2_JPEG_ACTIVE_MARKER_DHT (1  18)
 
+/* FM Receiver class control IDs */
+#define V4L2_CID_FM_RX_CLASS_BASE  (V4L2_CTRL_CLASS_FM_RX | 0x900)
+#define V4L2_CID_FM_RX_CLASS   (V4L2_CTRL_CLASS_FM_RX | 1)
+
+#define V4L2_CID_RDS_AF_SWITCH (V4L2_CID_FM_RX_CLASS_BASE + 1)
+#define V4L2_CID_TUNE_DEEMPHASIS   (V4L2_CID_FM_RX_CLASS_BASE + 2)
+
 /*
  * T U N I N G
  */
@@ -1849,7 +1857,8 @@ struct v4l2_hw_freq_seek {
__u32 seek_upward;
__u32 wrap_around;
__u32 spacing;
-   __u32 reserved[7];
+   __u32 fm_band;
+   __u32 reserved[6];
 };
 
 /*
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  

[PATCH V3 1/5] [Media] WL128x: Add support for FM TX RDS

2012-05-02 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch adds support for following FM TX RDS features,
 1. Radio Text
 2. PS Name
 3. PI Code
 4. PTY Code.

Along with above this patch fixes few other minor issues(like
fm tx get frequency, unnecessary error messages etc).

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_common.c |   17 +++---
 drivers/media/radio/wl128x/fmdrv_common.h |   17 +++
 drivers/media/radio/wl128x/fmdrv_rx.c |2 +-
 drivers/media/radio/wl128x/fmdrv_tx.c |   41 ++---
 drivers/media/radio/wl128x/fmdrv_tx.h |3 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |   47 +
 6 files changed, 90 insertions(+), 37 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index bf867a6..fcce61a 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -354,7 +354,7 @@ static void send_tasklet(unsigned long arg)
 
/* Check, is there any timeout happened to last transmitted packet */
if ((jiffies - fmdev-last_tx_jiffies)  FM_DRV_TX_TIMEOUT) {
-   fmerr(TX timeout occurred\n);
+   fmdbg(TX timeout occurred\n);
atomic_set(fmdev-tx_cnt, 1);
}
 
@@ -615,7 +615,11 @@ static void fm_irq_handle_rds_start(struct fmdev *fmdev)
 {
if (fmdev-irq_info.flag  FM_RDS_EVENT  fmdev-irq_info.mask) {
fmdbg(irq: rds threshold reached\n);
-   fmdev-irq_info.stage = FM_RDS_SEND_RDS_GETCMD_IDX;
+   /* If RSSI reached below threshold then dont get RDS data */
+   if (fmdev-irq_info.flag  FM_LEV_EVENT)
+   fmdev-irq_info.stage = FM_HW_TUNE_OP_ENDED_IDX;
+   else
+   fmdev-irq_info.stage = FM_RDS_SEND_RDS_GETCMD_IDX;
} else {
/* Continue next function in interrupt handler table */
fmdev-irq_info.stage = FM_HW_TUNE_OP_ENDED_IDX;
@@ -1129,8 +1133,9 @@ int fmc_set_freq(struct fmdev *fmdev, u32 freq_to_set)
 
 int fmc_get_freq(struct fmdev *fmdev, u32 *cur_tuned_frq)
 {
-   if (fmdev-rx.freq == FM_UNDEFINED_FREQ) {
-   fmerr(RX frequency is not set\n);
+   if (fmdev-rx.freq == FM_UNDEFINED_FREQ 
+   fmdev-tx_data.tx_frq == FM_UNDEFINED_FREQ) {
+   fmerr(RX/TX frequency is not set\n);
return -EPERM;
}
if (cur_tuned_frq == NULL) {
@@ -1144,7 +1149,7 @@ int fmc_get_freq(struct fmdev *fmdev, u32 *cur_tuned_frq)
return 0;
 
case FM_MODE_TX:
-   *cur_tuned_frq = 0; /* TODO : Change this later */
+   *cur_tuned_frq = fmdev-tx_data.tx_frq;
return 0;
 
default:
@@ -1574,6 +1579,8 @@ int fmc_prepare(struct fmdev *fmdev)
fmdev-rx.af_mode = FM_RX_RDS_AF_SWITCH_MODE_OFF;
fmdev-irq_info.retry = 0;
 
+   fmdev-tx_data.tx_frq = FM_UNDEFINED_FREQ;
+
fm_rx_reset_rds_cache(fmdev);
init_waitqueue_head(fmdev-rx.rds.read_queue);
 
diff --git a/drivers/media/radio/wl128x/fmdrv_common.h 
b/drivers/media/radio/wl128x/fmdrv_common.h
index d9b9c6c..196ff7d 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.h
+++ b/drivers/media/radio/wl128x/fmdrv_common.h
@@ -48,8 +48,8 @@ struct fm_reg_table {
 #define SEARCH_LVL_SET   15
 #define BAND_SET 16
 #define MUTE_STATUS_SET  17
-#define RDS_PAUSE_LVL_SET18
-#define RDS_PAUSE_DUR_SET19
+#define AUD_PAUSE_LVL_SET18
+#define AUD_PAUSE_DUR_SET19
 #define RDS_MEM_SET  20
 #define RDS_BLK_B_SET21
 #define RDS_MSK_B_SET22
@@ -84,11 +84,12 @@ struct fm_reg_table {
 
 #define FM_POWER_MODE254
 #define FM_INTERRUPT 255
+#define STATION_VALID   123
 
 /* Transmitter API */
 
 #define CHANL_SET55
-#define CHANL_BW_SET   56
+#define SCAN_SPACING_SET 56
 #define REF_SET  57
 #define POWER_ENB_SET90
 #define POWER_ATT_SET58
@@ -103,7 +104,8 @@ struct fm_reg_table {
 #define MONO_SET 66
 #define MUTE 92
 #define MPX_LMT_ENABLE   67
-#define PI_SET   93
+#define REF_ERR_SET 93
+#define PI_SET   68
 #define ECC_SET  69
 #define PTY  70
 #define AF   71
@@ -120,6 +122,10 @@ struct fm_reg_table {
 #define TX_AUDIO_LEVEL_TEST  96
 #define TX_AUDIO_LEVEL_TEST_THRESHOLD73
 #define TX_AUDIO_INPUT_LEVEL_RANGE_SET   54
+#define TX_AUDIO_LEVEL_GET  7
+#define READ_FMANT_TUNE_VALUE104
+
+/* New FM APIs (Rx and Tx) */
 #define RX_ANTENNA_SELECT87
 #define I2C_DEV_ADDR_SET 86
 #define REF_ERR_CALIB_PARAM_SET  

[PATCH V2 0/5] [Media] Radio: Fixes and New features for FM

2012-04-18 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

Mauro and the list,

This version 2 of patchset resolves the comments received from
Joonyoung Shim on patchset v1

This patchset creates new control class 'V4L2_CTRL_CLASS_FM_RX' for FM RX,
introduces 2 new CID's for FM RX and and 1 new CID for FM TX. Also adds 1
field in struct v4l2_hw_freq_seek.

This patch adds few new features to TI's FM driver features
are listed below,

1) FM TX RDS Support (RT, PS, AF, PI, PTY)
2) FM RX Russian band support
3) FM RX AF set/get
4) FM RX De-emphasis mode set/get

Along with new features this patch also fixes few issues in the driver
like default rssi level for seek, unnecessory logs etc.

Manjunatha Halli (5):
  [Media] WL128x: Add support for FM TX RDS
  [Media] New control class and features for FM RX
  [Media] Add new CID for FM TX RDS Alternate Frequency
  [Documentation] Media: Update docs for V4L2 FM new features
  [Media] WL12xx: Add support for FM new features.

 Documentation/DocBook/media/v4l/compat.xml |3 +
 Documentation/DocBook/media/v4l/controls.xml   |   78 +++
 Documentation/DocBook/media/v4l/dev-rds.xml|5 +-
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   |7 +
 drivers/media/radio/wl128x/fmdrv.h |3 +-
 drivers/media/radio/wl128x/fmdrv_common.c  |   55 ++--
 drivers/media/radio/wl128x/fmdrv_common.h  |   43 +-
 drivers/media/radio/wl128x/fmdrv_rx.c  |   92 ++---
 drivers/media/radio/wl128x/fmdrv_rx.h  |2 +-
 drivers/media/radio/wl128x/fmdrv_tx.c  |   41 +++
 drivers/media/radio/wl128x/fmdrv_tx.h  |3 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c|  138 +++-
 drivers/media/video/v4l2-ctrls.c   |   18 +++
 include/linux/videodev2.h  |   17 +++-
 14 files changed, 429 insertions(+), 76 deletions(-)

-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 2/5] [Media] New control class and features for FM RX

2012-04-18 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch creates new ctrl class for FM RX and adds new CID's for
below FM features,
1) De-Emphasis filter mode
2) RDS AF switch

Also this patch adds a field for band selection in struct v4l2_hw_freq_seek

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/video/v4l2-ctrls.c |   17 +
 include/linux/videodev2.h|   16 +++-
 2 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 18015c0..e1bba7d 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -372,6 +372,12 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
NULL,
};
 
+   static const char * const tune_deemphasis[] = {
+   No deemphasis,
+   50 useconds,
+   75 useconds,
+   NULL,
+   };
switch (id) {
case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ:
return mpeg_audio_sampling_freq;
@@ -414,6 +420,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
return colorfx;
case V4L2_CID_TUNE_PREEMPHASIS:
return tune_preemphasis;
+   case V4L2_CID_TUNE_DEEMPHASIS:
+   return tune_deemphasis;
case V4L2_CID_FLASH_LED_MODE:
return flash_led_mode;
case V4L2_CID_FLASH_STROBE_SOURCE:
@@ -644,6 +652,12 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_JPEG_COMPRESSION_QUALITY: return Compression Quality;
case V4L2_CID_JPEG_ACTIVE_MARKER:   return Active Markers;
 
+   /* FM Radio Receiver control */
+   /* Keep the order of the 'case's the same as in videodev2.h! */
+   case V4L2_CID_FM_RX_CLASS:  return FM Radio Receiver 
Controls;
+   case V4L2_CID_RDS_AF_SWITCH:return FM RX RDS AF switch;
+   case V4L2_CID_TUNE_DEEMPHASIS:  return FM RX De-emphasis 
settings;
+
default:
return NULL;
}
@@ -688,6 +702,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM:
case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE:
case V4L2_CID_MPEG_VIDEO_MPEG4_QPEL:
+   case V4L2_CID_RDS_AF_SWITCH:
*type = V4L2_CTRL_TYPE_BOOLEAN;
*min = 0;
*max = *step = 1;
@@ -733,6 +748,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL:
case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE:
case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
+   case V4L2_CID_TUNE_DEEMPHASIS:
*type = V4L2_CTRL_TYPE_MENU;
break;
case V4L2_CID_RDS_TX_PS_NAME:
@@ -745,6 +761,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_FM_TX_CLASS:
case V4L2_CID_FLASH_CLASS:
case V4L2_CID_JPEG_CLASS:
+   case V4L2_CID_FM_RX_CLASS:
*type = V4L2_CTRL_TYPE_CTRL_CLASS;
/* You can neither read not write these */
*flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index c9c9a46..00ac1b7 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1137,6 +1137,7 @@ struct v4l2_ext_controls {
 #define V4L2_CTRL_CLASS_FM_TX 0x009b   /* FM Modulator control class */
 #define V4L2_CTRL_CLASS_FLASH 0x009c   /* Camera flash controls */
 #define V4L2_CTRL_CLASS_JPEG 0x009d/* JPEG-compression 
controls */
+#define V4L2_CTRL_CLASS_FM_RX 0x009e   /* FM Receiver control class */
 
 #define V4L2_CTRL_ID_MASK(0x0fff)
 #define V4L2_CTRL_ID2CLASS(id)((id)  0x0fffUL)
@@ -1782,6 +1783,18 @@ enum v4l2_jpeg_chroma_subsampling {
 #defineV4L2_JPEG_ACTIVE_MARKER_DQT (1  17)
 #defineV4L2_JPEG_ACTIVE_MARKER_DHT (1  18)
 
+/* FM Receiver class control IDs */
+#define V4L2_CID_FM_RX_CLASS_BASE  (V4L2_CTRL_CLASS_FM_RX | 0x900)
+#define V4L2_CID_FM_RX_CLASS   (V4L2_CTRL_CLASS_FM_RX | 1)
+
+#define V4L2_CID_RDS_AF_SWITCH (V4L2_CID_FM_RX_CLASS_BASE + 1)
+#define V4L2_CID_TUNE_DEEMPHASIS   (V4L2_CID_FM_RX_CLASS_BASE + 2)
+enum v4l2_deemphasis {
+   V4L2_DEEMPHASIS_DISABLED= 0,
+   V4L2_DEEMPHASIS_50_uS   = 1,
+   V4L2_DEEMPHASIS_75_uS   = 2,
+};
+
 /*
  * T U N I N G
  */
@@ -1849,7 +1862,8 @@ struct v4l2_hw_freq_seek {
__u32 seek_upward;
__u32 wrap_around;
__u32 spacing;
-   __u32 reserved[7];
+   __u32 fm_band;
+   __u32 reserved[6];
 };
 
 /*
-- 
1.7.4.1

--
To 

[PATCH V2 5/5] [Media] WL12xx: Add support for FM new features.

2012-04-18 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch adds below features to TI's V4l2 FM driver for Wilink
chipsets,

1) FM RX Set frequency allows to set frequency anywhere between
65.5 MHz till 108 MHz (if chip is Wilink8 then till 164.55 MHz)
2) FM RX seek caters for band switch
3) FM RX RDS AF turn ON/OFF
4) FM RX De-Emphasis mode set/get
5) FM TX Alternate Frequency set/get

Also this patch fixes below issues

1) FM audio volume gain setting
2) Default rssi level is set to 8 instead of 20
3) Issue related to audio mute/unmute
4) Enable FM RX AF support in driver
5) In wrap_around seek mode try for once

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/radio/wl128x/fmdrv.h|3 +-
 drivers/media/radio/wl128x/fmdrv_common.c |   38 ++---
 drivers/media/radio/wl128x/fmdrv_common.h |   28 -
 drivers/media/radio/wl128x/fmdrv_rx.c |   90 +++--
 drivers/media/radio/wl128x/fmdrv_rx.h |2 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |   91 +++--
 6 files changed, 215 insertions(+), 37 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv.h 
b/drivers/media/radio/wl128x/fmdrv.h
index d84ad9d..c806c85 100644
--- a/drivers/media/radio/wl128x/fmdrv.h
+++ b/drivers/media/radio/wl128x/fmdrv.h
@@ -150,6 +150,7 @@ struct fm_rx {
struct region_info region;  /* Current selected band */
u32 freq;   /* Current RX frquency */
u8 mute_mode;   /* Current mute mode */
+   u8 bl_flag; /* Band limit reached flag */
u8 deemphasis_mode; /* Current deemphasis mode */
/* RF dependent soft mute mode */
u8 rf_depend_mute;
@@ -203,7 +204,7 @@ struct fmtx_data {
 struct fmdev {
struct video_device *radio_dev; /* V4L2 video device pointer */
struct snd_card *card;  /* Card which holds FM mixer controls */
-   u16 asci_id;
+   u16 asic_id;
spinlock_t rds_buff_lock; /* To protect access to RDS buffer */
spinlock_t resp_skb_lock; /* To protect access to received SKB */
 
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index fcce61a..ac20556 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -44,20 +44,41 @@
 
 /* Region info */
 static struct region_info region_configs[] = {
+   /* Super set of all bands */
+   {
+.chanl_space = FM_CHANNEL_SPACING_200KHZ * FM_FREQ_MUL,
+.bot_freq = 65800, /* 87.5 MHz */
+.top_freq = 162550,/* 108 MHz */
+.fm_band = 0,
+},
/* Europe/US */
{
 .chanl_space = FM_CHANNEL_SPACING_200KHZ * FM_FREQ_MUL,
 .bot_freq = 87500, /* 87.5 MHz */
 .top_freq = 108000,/* 108 MHz */
-.fm_band = 0,
+.fm_band = 1,
 },
/* Japan */
{
 .chanl_space = FM_CHANNEL_SPACING_200KHZ * FM_FREQ_MUL,
 .bot_freq = 76000, /* 76 MHz */
 .top_freq = 9, /* 90 MHz */
-.fm_band = 1,
+.fm_band = 2,
 },
+   /* Russian (OIRT) band */
+   {
+   .chanl_space = FM_CHANNEL_SPACING_50KHZ * FM_FREQ_MUL_RUS,
+   .bot_freq = 65800, /* 65.8 MHz */
+   .top_freq = 74000, /* 74 MHz */
+   .fm_band = 3,
+   },
+   /* Wether Band */
+   {
+   .chanl_space = FM_CHANNEL_SPACING_50KHZ * FM_FREQ_MUL_WB,
+   .bot_freq = 162400, /* 162.4 MHz */
+   .top_freq = 162550, /* 162.55 MHz */
+   .fm_band = 4,
+   }
 };
 
 /* Band selection */
@@ -596,7 +617,6 @@ static void fm_irq_handle_flag_getcmd_resp(struct fmdev 
*fmdev)
memcpy(fmdev-irq_info.flag, skb-data, fm_evt_hdr-dlen);
 
fmdev-irq_info.flag = be16_to_cpu(fmdev-irq_info.flag);
-   fmdbg(irq: flag register(0x%x)\n, fmdev-irq_info.flag);
 
/* Continue next function in interrupt handler table */
fm_irq_call_stage(fmdev, FM_HW_MAL_FUNC_IDX);
@@ -702,7 +722,7 @@ static void fm_rdsparse_swapbytes(struct fmdev *fmdev,
 * in Dolphin they are in big endian, the parsing of the RDS data
 * is chip dependent
 */
-   if (fmdev-asci_id != 0x6350) {
+   if (fmdev-asic_id != 0x6350) {
rds_buff = rds_format-data.groupdatabuff.buff[0];
while (index + 1  FM_RX_RDS_INFO_FIELD_MAX) {
byte1 = rds_buff[index];
@@ -1353,11 +1373,13 @@ static int fm_power_up(struct fmdev *fmdev, u8 mode)
sizeof(asic_ver), asic_ver, resp_len))
goto rel;
 
+   fmdev-asic_id = be16_to_cpu(asic_id);
+
fmdbg(ASIC ID: 0x%x , ASIC Version: %d\n,
-   be16_to_cpu(asic_id), be16_to_cpu(asic_ver));
+   fmdev-asic_id, be16_to_cpu(asic_ver));
 
sprintf(fw_name, %s_%x.%d.bts, FM_FMC_FW_FILE_START,

[PATCH V2 4/5] [Documentation] Media: Update docs for V4L2 FM new features

2012-04-18 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

The list of new features -
1) New control class for FM RX
2) New FM RX CID's - De-Emphasis filter mode and RDS AF switch
3) New FM TX CID - RDS Alternate frequency set.

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 Documentation/DocBook/media/v4l/compat.xml |3 +
 Documentation/DocBook/media/v4l/controls.xml   |   78 
 Documentation/DocBook/media/v4l/dev-rds.xml|5 +-
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   |7 ++
 4 files changed, 91 insertions(+), 2 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/compat.xml 
b/Documentation/DocBook/media/v4l/compat.xml
index bce97c5..df1f345 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2311,6 +2311,9 @@ more information./para
  paraAdded FM Modulator (FM TX) Extended Control Class: 
constantV4L2_CTRL_CLASS_FM_TX/constant and their Control IDs./para
/listitem
listitem
+   paraAdded FM Receiver (FM RX) Extended Control Class: 
constantV4L2_CTRL_CLASS_FM_RX/constant and their Control IDs./para
+   /listitem
+   listitem
  paraAdded Remote Controller chapter, describing the default Remote 
Controller mapping for media devices./para
/listitem
   /orderedlist
diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index b84f25e..f6c8034 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3018,6 +3018,12 @@ to find receivers which can scroll strings sized as 32 x 
N or 64 x N characters.
 with steps of 32 or 64 characters. The result is it must always contain a 
string with size multiple of 32 or 64. /entry
  /row
  row
+ entry 
spanname=idconstantV4L2_CID_RDS_TX_AF_FREQ/constantnbsp;/entry
+ entryinteger/entry
+ /row
+ rowentry spanname=descrSets the RDS Alternate Frequency value 
which allows a receiver to re-tune to a different frequency providing the same 
station when the first signal becomes too weak (e.g., when moving out of 
range). /entry
+ /row
+ row
entry 
spanname=idconstantV4L2_CID_AUDIO_LIMITER_ENABLED/constantnbsp;/entry
entryboolean/entry
  /row
@@ -3146,6 +3152,78 @@ manually or automatically if set to zero. Unit, range 
and step are driver-specif
 xref linkend=en50067 / document, from CENELEC./para
 /section
 
+section id=fm-rx-controls
+  titleFM Receiver Control Reference/title
+
+  paraThe FM Receiver (FM_RX) class includes controls for common 
features of
+FM Reception capable devices. Currently this class includes parameter for 
Alternate
+frequency./para
+
+  table pgwide=1 frame=none id=fm-rx-control-id
+  titleFM_RX 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=leftID/entry
+entry align=leftType/entry
+  /rowrow rowsep=1entry spanname=descr 
align=leftDescription/entry
+  /row
+/thead
+tbody valign=top
+  rowentry/entry/row
+  row
+entry 
spanname=idconstantV4L2_CID_FM_RX_CLASS/constantnbsp;/entry
+entryclass/entry
+  /rowrowentry spanname=descrThe FM_RX class
+descriptor. Calling VIDIOC-QUERYCTRL; for this control will return a
+description of this control class./entry
+  /row
+  row
+entry 
spanname=idconstantV4L2_CID_RDS_AF_SWITCH/constantnbsp;/entry
+entryboolean/entry
+  /row
+  rowentry spanname=descrEnable or Disable's FM RX RDS Alternate 
frequency feature./entry
+  /row
+  row
+   entry 
spanname=idconstantV4L2_CID_TUNE_DEEMPHASIS/constantnbsp;/entry
+   entryinteger/entry
+ /row
+ row id=v4l2-deemphasisentry spanname=descrConfigures the 
de-emphasis value for reception.
+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 enumnbsp;v4l2_deemphasis
+defines possible values for pre-emphasis. Here they are:/entry
+   /rowrow
+   entrytbl spanname=descr cols=2
+ tbody valign=top
+   row
+ 
entryconstantV4L2_DEEMPHASIS_DISABLED/constantnbsp;/entry
+ entryNo de-emphasis is applied./entry
+   /row
+   row
+ 
entryconstantV4L2_DEEMPHASIS_50_uS/constantnbsp;/entry
+ 

[PATCH V2 3/5] [Media] Add new CID for FM TX RDS Alternate Frequency

2012-04-18 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/video/v4l2-ctrls.c |1 +
 include/linux/videodev2.h|1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index e1bba7d..b4ddd6b 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -614,6 +614,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_RDS_TX_PTY:   return RDS Program Type;
case V4L2_CID_RDS_TX_PS_NAME:   return RDS PS Name;
case V4L2_CID_RDS_TX_RADIO_TEXT:return RDS Radio Text;
+   case V4L2_CID_RDS_TX_AF_FREQ:   return RDS Alternate 
Frequency;
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;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 00ac1b7..d1c8c1b 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1699,6 +1699,7 @@ enum  v4l2_exposure_auto_type {
 #define V4L2_CID_RDS_TX_PTY(V4L2_CID_FM_TX_CLASS_BASE + 3)
 #define V4L2_CID_RDS_TX_PS_NAME
(V4L2_CID_FM_TX_CLASS_BASE + 5)
 #define V4L2_CID_RDS_TX_RADIO_TEXT (V4L2_CID_FM_TX_CLASS_BASE + 6)
+#define V4L2_CID_RDS_TX_AF_FREQ
(V4L2_CID_FM_TX_CLASS_BASE + 7)
 
 #define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 64)
 #define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME(V4L2_CID_FM_TX_CLASS_BASE + 65)
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 1/5] [Media] WL128x: Add support for FM TX RDS

2012-04-18 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch adds support for following FM TX RDS features,
 1. Radio Text
 2. PS Name
 3. PI Code
 4. PTY Code.

Along with above this patch fixes few other minor issues(like
fm tx get frequency, unnecessary error messages etc).

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_common.c |   17 +++---
 drivers/media/radio/wl128x/fmdrv_common.h |   17 +++
 drivers/media/radio/wl128x/fmdrv_rx.c |2 +-
 drivers/media/radio/wl128x/fmdrv_tx.c |   41 ++---
 drivers/media/radio/wl128x/fmdrv_tx.h |3 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |   47 +
 6 files changed, 90 insertions(+), 37 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index bf867a6..fcce61a 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -354,7 +354,7 @@ static void send_tasklet(unsigned long arg)
 
/* Check, is there any timeout happened to last transmitted packet */
if ((jiffies - fmdev-last_tx_jiffies)  FM_DRV_TX_TIMEOUT) {
-   fmerr(TX timeout occurred\n);
+   fmdbg(TX timeout occurred\n);
atomic_set(fmdev-tx_cnt, 1);
}
 
@@ -615,7 +615,11 @@ static void fm_irq_handle_rds_start(struct fmdev *fmdev)
 {
if (fmdev-irq_info.flag  FM_RDS_EVENT  fmdev-irq_info.mask) {
fmdbg(irq: rds threshold reached\n);
-   fmdev-irq_info.stage = FM_RDS_SEND_RDS_GETCMD_IDX;
+   /* If RSSI reached below threshold then dont get RDS data */
+   if (fmdev-irq_info.flag  FM_LEV_EVENT)
+   fmdev-irq_info.stage = FM_HW_TUNE_OP_ENDED_IDX;
+   else
+   fmdev-irq_info.stage = FM_RDS_SEND_RDS_GETCMD_IDX;
} else {
/* Continue next function in interrupt handler table */
fmdev-irq_info.stage = FM_HW_TUNE_OP_ENDED_IDX;
@@ -1129,8 +1133,9 @@ int fmc_set_freq(struct fmdev *fmdev, u32 freq_to_set)
 
 int fmc_get_freq(struct fmdev *fmdev, u32 *cur_tuned_frq)
 {
-   if (fmdev-rx.freq == FM_UNDEFINED_FREQ) {
-   fmerr(RX frequency is not set\n);
+   if (fmdev-rx.freq == FM_UNDEFINED_FREQ 
+   fmdev-tx_data.tx_frq == FM_UNDEFINED_FREQ) {
+   fmerr(RX/TX frequency is not set\n);
return -EPERM;
}
if (cur_tuned_frq == NULL) {
@@ -1144,7 +1149,7 @@ int fmc_get_freq(struct fmdev *fmdev, u32 *cur_tuned_frq)
return 0;
 
case FM_MODE_TX:
-   *cur_tuned_frq = 0; /* TODO : Change this later */
+   *cur_tuned_frq = fmdev-tx_data.tx_frq;
return 0;
 
default:
@@ -1574,6 +1579,8 @@ int fmc_prepare(struct fmdev *fmdev)
fmdev-rx.af_mode = FM_RX_RDS_AF_SWITCH_MODE_OFF;
fmdev-irq_info.retry = 0;
 
+   fmdev-tx_data.tx_frq = FM_UNDEFINED_FREQ;
+
fm_rx_reset_rds_cache(fmdev);
init_waitqueue_head(fmdev-rx.rds.read_queue);
 
diff --git a/drivers/media/radio/wl128x/fmdrv_common.h 
b/drivers/media/radio/wl128x/fmdrv_common.h
index d9b9c6c..196ff7d 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.h
+++ b/drivers/media/radio/wl128x/fmdrv_common.h
@@ -48,8 +48,8 @@ struct fm_reg_table {
 #define SEARCH_LVL_SET   15
 #define BAND_SET 16
 #define MUTE_STATUS_SET  17
-#define RDS_PAUSE_LVL_SET18
-#define RDS_PAUSE_DUR_SET19
+#define AUD_PAUSE_LVL_SET18
+#define AUD_PAUSE_DUR_SET19
 #define RDS_MEM_SET  20
 #define RDS_BLK_B_SET21
 #define RDS_MSK_B_SET22
@@ -84,11 +84,12 @@ struct fm_reg_table {
 
 #define FM_POWER_MODE254
 #define FM_INTERRUPT 255
+#define STATION_VALID   123
 
 /* Transmitter API */
 
 #define CHANL_SET55
-#define CHANL_BW_SET   56
+#define SCAN_SPACING_SET 56
 #define REF_SET  57
 #define POWER_ENB_SET90
 #define POWER_ATT_SET58
@@ -103,7 +104,8 @@ struct fm_reg_table {
 #define MONO_SET 66
 #define MUTE 92
 #define MPX_LMT_ENABLE   67
-#define PI_SET   93
+#define REF_ERR_SET 93
+#define PI_SET   68
 #define ECC_SET  69
 #define PTY  70
 #define AF   71
@@ -120,6 +122,10 @@ struct fm_reg_table {
 #define TX_AUDIO_LEVEL_TEST  96
 #define TX_AUDIO_LEVEL_TEST_THRESHOLD73
 #define TX_AUDIO_INPUT_LEVEL_RANGE_SET   54
+#define TX_AUDIO_LEVEL_GET  7
+#define READ_FMANT_TUNE_VALUE104
+
+/* New FM APIs (Rx and Tx) */
 #define RX_ANTENNA_SELECT87
 #define I2C_DEV_ADDR_SET 86
 #define REF_ERR_CALIB_PARAM_SET  

[PATCH 1/4] [Media] WL128x: Add support for FM TX RDS

2012-04-17 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch adds support for following FM TX RDS features,
 1. Radio Text
 2. PS Name
 3. PI Code
 4. PTY Code.

Along with above this patch fixes few other minor issues(like
fm tx get frequency, unnecessary error messages etc).

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_common.c |   17 +++---
 drivers/media/radio/wl128x/fmdrv_common.h |   17 +++
 drivers/media/radio/wl128x/fmdrv_rx.c |2 +-
 drivers/media/radio/wl128x/fmdrv_tx.c |   41 ++---
 drivers/media/radio/wl128x/fmdrv_tx.h |3 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |   47 +
 6 files changed, 90 insertions(+), 37 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index bf867a6..fcce61a 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -354,7 +354,7 @@ static void send_tasklet(unsigned long arg)
 
/* Check, is there any timeout happened to last transmitted packet */
if ((jiffies - fmdev-last_tx_jiffies)  FM_DRV_TX_TIMEOUT) {
-   fmerr(TX timeout occurred\n);
+   fmdbg(TX timeout occurred\n);
atomic_set(fmdev-tx_cnt, 1);
}
 
@@ -615,7 +615,11 @@ static void fm_irq_handle_rds_start(struct fmdev *fmdev)
 {
if (fmdev-irq_info.flag  FM_RDS_EVENT  fmdev-irq_info.mask) {
fmdbg(irq: rds threshold reached\n);
-   fmdev-irq_info.stage = FM_RDS_SEND_RDS_GETCMD_IDX;
+   /* If RSSI reached below threshold then dont get RDS data */
+   if (fmdev-irq_info.flag  FM_LEV_EVENT)
+   fmdev-irq_info.stage = FM_HW_TUNE_OP_ENDED_IDX;
+   else
+   fmdev-irq_info.stage = FM_RDS_SEND_RDS_GETCMD_IDX;
} else {
/* Continue next function in interrupt handler table */
fmdev-irq_info.stage = FM_HW_TUNE_OP_ENDED_IDX;
@@ -1129,8 +1133,9 @@ int fmc_set_freq(struct fmdev *fmdev, u32 freq_to_set)
 
 int fmc_get_freq(struct fmdev *fmdev, u32 *cur_tuned_frq)
 {
-   if (fmdev-rx.freq == FM_UNDEFINED_FREQ) {
-   fmerr(RX frequency is not set\n);
+   if (fmdev-rx.freq == FM_UNDEFINED_FREQ 
+   fmdev-tx_data.tx_frq == FM_UNDEFINED_FREQ) {
+   fmerr(RX/TX frequency is not set\n);
return -EPERM;
}
if (cur_tuned_frq == NULL) {
@@ -1144,7 +1149,7 @@ int fmc_get_freq(struct fmdev *fmdev, u32 *cur_tuned_frq)
return 0;
 
case FM_MODE_TX:
-   *cur_tuned_frq = 0; /* TODO : Change this later */
+   *cur_tuned_frq = fmdev-tx_data.tx_frq;
return 0;
 
default:
@@ -1574,6 +1579,8 @@ int fmc_prepare(struct fmdev *fmdev)
fmdev-rx.af_mode = FM_RX_RDS_AF_SWITCH_MODE_OFF;
fmdev-irq_info.retry = 0;
 
+   fmdev-tx_data.tx_frq = FM_UNDEFINED_FREQ;
+
fm_rx_reset_rds_cache(fmdev);
init_waitqueue_head(fmdev-rx.rds.read_queue);
 
diff --git a/drivers/media/radio/wl128x/fmdrv_common.h 
b/drivers/media/radio/wl128x/fmdrv_common.h
index d9b9c6c..196ff7d 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.h
+++ b/drivers/media/radio/wl128x/fmdrv_common.h
@@ -48,8 +48,8 @@ struct fm_reg_table {
 #define SEARCH_LVL_SET   15
 #define BAND_SET 16
 #define MUTE_STATUS_SET  17
-#define RDS_PAUSE_LVL_SET18
-#define RDS_PAUSE_DUR_SET19
+#define AUD_PAUSE_LVL_SET18
+#define AUD_PAUSE_DUR_SET19
 #define RDS_MEM_SET  20
 #define RDS_BLK_B_SET21
 #define RDS_MSK_B_SET22
@@ -84,11 +84,12 @@ struct fm_reg_table {
 
 #define FM_POWER_MODE254
 #define FM_INTERRUPT 255
+#define STATION_VALID   123
 
 /* Transmitter API */
 
 #define CHANL_SET55
-#define CHANL_BW_SET   56
+#define SCAN_SPACING_SET 56
 #define REF_SET  57
 #define POWER_ENB_SET90
 #define POWER_ATT_SET58
@@ -103,7 +104,8 @@ struct fm_reg_table {
 #define MONO_SET 66
 #define MUTE 92
 #define MPX_LMT_ENABLE   67
-#define PI_SET   93
+#define REF_ERR_SET 93
+#define PI_SET   68
 #define ECC_SET  69
 #define PTY  70
 #define AF   71
@@ -120,6 +122,10 @@ struct fm_reg_table {
 #define TX_AUDIO_LEVEL_TEST  96
 #define TX_AUDIO_LEVEL_TEST_THRESHOLD73
 #define TX_AUDIO_INPUT_LEVEL_RANGE_SET   54
+#define TX_AUDIO_LEVEL_GET  7
+#define READ_FMANT_TUNE_VALUE104
+
+/* New FM APIs (Rx and Tx) */
 #define RX_ANTENNA_SELECT87
 #define I2C_DEV_ADDR_SET 86
 #define REF_ERR_CALIB_PARAM_SET  

[PATCH 0/4] [Media] Radio: Fixes and New features for FM

2012-04-17 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

Mauro and the list,
 
This patchset sreates new control class 'V4L2_CTRL_CLASS_FM_RX' for FM RX.
Also this patches set introduces 3 new CID's for FM RX and FM TX.
  
Also this patch adds few new features to TI's FM driver fetures
are listed below,
   
1) FM TX RDS Support (RT, PS, AF, PI, PTY)  
2) FM RX Russian band support
3) FM RX AF set/get
4) FM RX De-emphasis mode set/get

Along with new features this patch also fixes few issues in the driver
like default rssi level for seek, unnecessory logs etc.


Manjunatha Halli (4):
  [Media] WL128x: Add support for FM TX RDS
  [Media] Create new control class for FM RX.
  [Documentation] Add documentation for V4L2 FM new features,
  [Media] WL12xx: Add support for FM new features.

 Documentation/DocBook/media/v4l/compat.xml |3 +
 Documentation/DocBook/media/v4l/controls.xml   |   78 +++
 Documentation/DocBook/media/v4l/dev-rds.xml|5 +-
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   |7 +
 drivers/media/radio/wl128x/fmdrv.h |3 +-
 drivers/media/radio/wl128x/fmdrv_common.c  |   55 ++--
 drivers/media/radio/wl128x/fmdrv_common.h  |   43 +-
 drivers/media/radio/wl128x/fmdrv_rx.c  |   92 ++---
 drivers/media/radio/wl128x/fmdrv_rx.h  |2 +-
 drivers/media/radio/wl128x/fmdrv_tx.c  |   41 +++
 drivers/media/radio/wl128x/fmdrv_tx.h  |3 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c|  138 +++-
 drivers/media/video/v4l2-ctrls.c   |   18 +++
 include/linux/videodev2.h  |   17 +++-
 14 files changed, 429 insertions(+), 76 deletions(-)

-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] [Media] WL12xx: Add support for FM new features.

2012-04-17 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch adds below features to TI's V4l2 FM driver for Wilink
chipsets,

1) FM RX Set frequency allows to set frequency anywhere between
65.5 MHz till 108 MHz (if chip is Wilink8 then till 164.55 MHz)
2) FM RX seek caters for band switch
3) FM RX RDS AF turn ON/OFF
4) FM RX De-Emphasis mode set/get
5) FM TX Alternate Frequency set/get

Also this patch fixes below issues

1) FM audio volume gain setting
2) Default rssi level is set to 8 instead of 20
3) Issue related to audio mute/unmute
4) Enable FM RX AF support in driver
5) In wrap_around seek mode try for once

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/radio/wl128x/fmdrv.h|3 +-
 drivers/media/radio/wl128x/fmdrv_common.c |   38 ++---
 drivers/media/radio/wl128x/fmdrv_common.h |   28 -
 drivers/media/radio/wl128x/fmdrv_rx.c |   90 +++--
 drivers/media/radio/wl128x/fmdrv_rx.h |2 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |   91 +++--
 6 files changed, 215 insertions(+), 37 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv.h 
b/drivers/media/radio/wl128x/fmdrv.h
index d84ad9d..c806c85 100644
--- a/drivers/media/radio/wl128x/fmdrv.h
+++ b/drivers/media/radio/wl128x/fmdrv.h
@@ -150,6 +150,7 @@ struct fm_rx {
struct region_info region;  /* Current selected band */
u32 freq;   /* Current RX frquency */
u8 mute_mode;   /* Current mute mode */
+   u8 bl_flag; /* Band limit reached flag */
u8 deemphasis_mode; /* Current deemphasis mode */
/* RF dependent soft mute mode */
u8 rf_depend_mute;
@@ -203,7 +204,7 @@ struct fmtx_data {
 struct fmdev {
struct video_device *radio_dev; /* V4L2 video device pointer */
struct snd_card *card;  /* Card which holds FM mixer controls */
-   u16 asci_id;
+   u16 asic_id;
spinlock_t rds_buff_lock; /* To protect access to RDS buffer */
spinlock_t resp_skb_lock; /* To protect access to received SKB */
 
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index fcce61a..ac20556 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -44,20 +44,41 @@
 
 /* Region info */
 static struct region_info region_configs[] = {
+   /* Super set of all bands */
+   {
+.chanl_space = FM_CHANNEL_SPACING_200KHZ * FM_FREQ_MUL,
+.bot_freq = 65800, /* 87.5 MHz */
+.top_freq = 162550,/* 108 MHz */
+.fm_band = 0,
+},
/* Europe/US */
{
 .chanl_space = FM_CHANNEL_SPACING_200KHZ * FM_FREQ_MUL,
 .bot_freq = 87500, /* 87.5 MHz */
 .top_freq = 108000,/* 108 MHz */
-.fm_band = 0,
+.fm_band = 1,
 },
/* Japan */
{
 .chanl_space = FM_CHANNEL_SPACING_200KHZ * FM_FREQ_MUL,
 .bot_freq = 76000, /* 76 MHz */
 .top_freq = 9, /* 90 MHz */
-.fm_band = 1,
+.fm_band = 2,
 },
+   /* Russian (OIRT) band */
+   {
+   .chanl_space = FM_CHANNEL_SPACING_50KHZ * FM_FREQ_MUL_RUS,
+   .bot_freq = 65800, /* 65.8 MHz */
+   .top_freq = 74000, /* 74 MHz */
+   .fm_band = 3,
+   },
+   /* Wether Band */
+   {
+   .chanl_space = FM_CHANNEL_SPACING_50KHZ * FM_FREQ_MUL_WB,
+   .bot_freq = 162400, /* 162.4 MHz */
+   .top_freq = 162550, /* 162.55 MHz */
+   .fm_band = 4,
+   }
 };
 
 /* Band selection */
@@ -596,7 +617,6 @@ static void fm_irq_handle_flag_getcmd_resp(struct fmdev 
*fmdev)
memcpy(fmdev-irq_info.flag, skb-data, fm_evt_hdr-dlen);
 
fmdev-irq_info.flag = be16_to_cpu(fmdev-irq_info.flag);
-   fmdbg(irq: flag register(0x%x)\n, fmdev-irq_info.flag);
 
/* Continue next function in interrupt handler table */
fm_irq_call_stage(fmdev, FM_HW_MAL_FUNC_IDX);
@@ -702,7 +722,7 @@ static void fm_rdsparse_swapbytes(struct fmdev *fmdev,
 * in Dolphin they are in big endian, the parsing of the RDS data
 * is chip dependent
 */
-   if (fmdev-asci_id != 0x6350) {
+   if (fmdev-asic_id != 0x6350) {
rds_buff = rds_format-data.groupdatabuff.buff[0];
while (index + 1  FM_RX_RDS_INFO_FIELD_MAX) {
byte1 = rds_buff[index];
@@ -1353,11 +1373,13 @@ static int fm_power_up(struct fmdev *fmdev, u8 mode)
sizeof(asic_ver), asic_ver, resp_len))
goto rel;
 
+   fmdev-asic_id = be16_to_cpu(asic_id);
+
fmdbg(ASIC ID: 0x%x , ASIC Version: %d\n,
-   be16_to_cpu(asic_id), be16_to_cpu(asic_ver));
+   fmdev-asic_id, be16_to_cpu(asic_ver));
 
sprintf(fw_name, %s_%x.%d.bts, FM_FMC_FW_FILE_START,

[PATCH 3/4] [Documentation] Add documentation for V4L2 FM new features,

2012-04-17 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

The list of new features -
1) New control class for FM RX
2) New FM RX CID's - De-Emphasis filter mode and RDS AF switch
3) New FM TX CID - RDS Alternate frequency set.

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 Documentation/DocBook/media/v4l/compat.xml |3 +
 Documentation/DocBook/media/v4l/controls.xml   |   78 
 Documentation/DocBook/media/v4l/dev-rds.xml|5 +-
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   |7 ++
 4 files changed, 91 insertions(+), 2 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/compat.xml 
b/Documentation/DocBook/media/v4l/compat.xml
index bce97c5..df1f345 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2311,6 +2311,9 @@ more information./para
  paraAdded FM Modulator (FM TX) Extended Control Class: 
constantV4L2_CTRL_CLASS_FM_TX/constant and their Control IDs./para
/listitem
listitem
+   paraAdded FM Receiver (FM RX) Extended Control Class: 
constantV4L2_CTRL_CLASS_FM_RX/constant and their Control IDs./para
+   /listitem
+   listitem
  paraAdded Remote Controller chapter, describing the default Remote 
Controller mapping for media devices./para
/listitem
   /orderedlist
diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index b84f25e..f6c8034 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3018,6 +3018,12 @@ to find receivers which can scroll strings sized as 32 x 
N or 64 x N characters.
 with steps of 32 or 64 characters. The result is it must always contain a 
string with size multiple of 32 or 64. /entry
  /row
  row
+ entry 
spanname=idconstantV4L2_CID_RDS_TX_AF_FREQ/constantnbsp;/entry
+ entryinteger/entry
+ /row
+ rowentry spanname=descrSets the RDS Alternate Frequency value 
which allows a receiver to re-tune to a different frequency providing the same 
station when the first signal becomes too weak (e.g., when moving out of 
range). /entry
+ /row
+ row
entry 
spanname=idconstantV4L2_CID_AUDIO_LIMITER_ENABLED/constantnbsp;/entry
entryboolean/entry
  /row
@@ -3146,6 +3152,78 @@ manually or automatically if set to zero. Unit, range 
and step are driver-specif
 xref linkend=en50067 / document, from CENELEC./para
 /section
 
+section id=fm-rx-controls
+  titleFM Receiver Control Reference/title
+
+  paraThe FM Receiver (FM_RX) class includes controls for common 
features of
+FM Reception capable devices. Currently this class includes parameter for 
Alternate
+frequency./para
+
+  table pgwide=1 frame=none id=fm-rx-control-id
+  titleFM_RX 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=leftID/entry
+entry align=leftType/entry
+  /rowrow rowsep=1entry spanname=descr 
align=leftDescription/entry
+  /row
+/thead
+tbody valign=top
+  rowentry/entry/row
+  row
+entry 
spanname=idconstantV4L2_CID_FM_RX_CLASS/constantnbsp;/entry
+entryclass/entry
+  /rowrowentry spanname=descrThe FM_RX class
+descriptor. Calling VIDIOC-QUERYCTRL; for this control will return a
+description of this control class./entry
+  /row
+  row
+entry 
spanname=idconstantV4L2_CID_RDS_AF_SWITCH/constantnbsp;/entry
+entryboolean/entry
+  /row
+  rowentry spanname=descrEnable or Disable's FM RX RDS Alternate 
frequency feature./entry
+  /row
+  row
+   entry 
spanname=idconstantV4L2_CID_TUNE_DEEMPHASIS/constantnbsp;/entry
+   entryinteger/entry
+ /row
+ row id=v4l2-deemphasisentry spanname=descrConfigures the 
de-emphasis value for reception.
+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 enumnbsp;v4l2_deemphasis
+defines possible values for pre-emphasis. Here they are:/entry
+   /rowrow
+   entrytbl spanname=descr cols=2
+ tbody valign=top
+   row
+ 
entryconstantV4L2_DEEMPHASIS_DISABLED/constantnbsp;/entry
+ entryNo de-emphasis is applied./entry
+   /row
+   row
+ 
entryconstantV4L2_DEEMPHASIS_50_uS/constantnbsp;/entry
+ 

[PATCH 2/4] [Media] Create new control class for FM RX.

2012-04-17 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

Also this patch adds CID's for below new FM features,
1) FM RX - De-Emphasis filter mode and RDS AF switch
2) FM TX - RDS Alternate frequency set.

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/video/v4l2-ctrls.c |   18 ++
 include/linux/videodev2.h|   17 -
 2 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 18015c0..b4ddd6b 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -372,6 +372,12 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
NULL,
};
 
+   static const char * const tune_deemphasis[] = {
+   No deemphasis,
+   50 useconds,
+   75 useconds,
+   NULL,
+   };
switch (id) {
case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ:
return mpeg_audio_sampling_freq;
@@ -414,6 +420,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
return colorfx;
case V4L2_CID_TUNE_PREEMPHASIS:
return tune_preemphasis;
+   case V4L2_CID_TUNE_DEEMPHASIS:
+   return tune_deemphasis;
case V4L2_CID_FLASH_LED_MODE:
return flash_led_mode;
case V4L2_CID_FLASH_STROBE_SOURCE:
@@ -606,6 +614,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_RDS_TX_PTY:   return RDS Program Type;
case V4L2_CID_RDS_TX_PS_NAME:   return RDS PS Name;
case V4L2_CID_RDS_TX_RADIO_TEXT:return RDS Radio Text;
+   case V4L2_CID_RDS_TX_AF_FREQ:   return RDS Alternate 
Frequency;
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;
@@ -644,6 +653,12 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_JPEG_COMPRESSION_QUALITY: return Compression Quality;
case V4L2_CID_JPEG_ACTIVE_MARKER:   return Active Markers;
 
+   /* FM Radio Receiver control */
+   /* Keep the order of the 'case's the same as in videodev2.h! */
+   case V4L2_CID_FM_RX_CLASS:  return FM Radio Receiver 
Controls;
+   case V4L2_CID_RDS_AF_SWITCH:return FM RX RDS AF switch;
+   case V4L2_CID_TUNE_DEEMPHASIS:  return FM RX De-emphasis 
settings;
+
default:
return NULL;
}
@@ -688,6 +703,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM:
case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE:
case V4L2_CID_MPEG_VIDEO_MPEG4_QPEL:
+   case V4L2_CID_RDS_AF_SWITCH:
*type = V4L2_CTRL_TYPE_BOOLEAN;
*min = 0;
*max = *step = 1;
@@ -733,6 +749,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL:
case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE:
case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
+   case V4L2_CID_TUNE_DEEMPHASIS:
*type = V4L2_CTRL_TYPE_MENU;
break;
case V4L2_CID_RDS_TX_PS_NAME:
@@ -745,6 +762,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_FM_TX_CLASS:
case V4L2_CID_FLASH_CLASS:
case V4L2_CID_JPEG_CLASS:
+   case V4L2_CID_FM_RX_CLASS:
*type = V4L2_CTRL_TYPE_CTRL_CLASS;
/* You can neither read not write these */
*flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index c9c9a46..d1c8c1b 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1137,6 +1137,7 @@ struct v4l2_ext_controls {
 #define V4L2_CTRL_CLASS_FM_TX 0x009b   /* FM Modulator control class */
 #define V4L2_CTRL_CLASS_FLASH 0x009c   /* Camera flash controls */
 #define V4L2_CTRL_CLASS_JPEG 0x009d/* JPEG-compression 
controls */
+#define V4L2_CTRL_CLASS_FM_RX 0x009e   /* FM Receiver control class */
 
 #define V4L2_CTRL_ID_MASK(0x0fff)
 #define V4L2_CTRL_ID2CLASS(id)((id)  0x0fffUL)
@@ -1698,6 +1699,7 @@ enum  v4l2_exposure_auto_type {
 #define V4L2_CID_RDS_TX_PTY(V4L2_CID_FM_TX_CLASS_BASE + 3)
 #define V4L2_CID_RDS_TX_PS_NAME
(V4L2_CID_FM_TX_CLASS_BASE + 5)
 #define V4L2_CID_RDS_TX_RADIO_TEXT (V4L2_CID_FM_TX_CLASS_BASE + 6)
+#define V4L2_CID_RDS_TX_AF_FREQ
(V4L2_CID_FM_TX_CLASS_BASE + 7)
 
 #define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 64)
 #define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME

[PATCH 3/3] wl128x: Add sysfs based support for FM features

2012-02-24 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch adds support for below features via sysfs file system

1) FM RX Band selection (US/Europe, Japan and Russian bands)
2) FM RX RDS AF turn ON/OFF
3) FM RX RSSI level set/get
4) FM TX Alternate Frequency set/get
5) FM RX De-Emphasis mode set/get

Also this patch fixes below issues

1) FM audio volume gain setting
2) Default rssi level is set to 8 instead of 20
3) Issue related to audio mute/unmute
4)Enable FM RX AF support in driver
5)In wrap_around seek mode try for once

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/radio/wl128x/fmdrv.h|1 +
 drivers/media/radio/wl128x/fmdrv_common.c |   11 ++-
 drivers/media/radio/wl128x/fmdrv_common.h |   26 +++--
 drivers/media/radio/wl128x/fmdrv_rx.c |   13 ++-
 drivers/media/radio/wl128x/fmdrv_tx.c |6 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |  188 -
 6 files changed, 225 insertions(+), 20 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv.h 
b/drivers/media/radio/wl128x/fmdrv.h
index d84ad9d..8fe773d 100644
--- a/drivers/media/radio/wl128x/fmdrv.h
+++ b/drivers/media/radio/wl128x/fmdrv.h
@@ -196,6 +196,7 @@ struct fmtx_data {
u16 aud_mode;
u32 preemph;
u32 tx_frq;
+   u32 af_frq;
struct tx_rds rds;
 };
 
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index fcce61a..1a580a7 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -58,6 +58,13 @@ static struct region_info region_configs[] = {
 .top_freq = 9, /* 90 MHz */
 .fm_band = 1,
 },
+   /* Russian (OIRT) band */
+   {
+.chanl_space = FM_CHANNEL_SPACING_200KHZ * FM_FREQ_MUL,
+.bot_freq = 65800, /* 65.8 MHz */
+.top_freq = 74000, /* 74 MHz */
+.fm_band = 2,
+},
 };
 
 /* Band selection */
@@ -659,7 +666,7 @@ static void fm_rx_update_af_cache(struct fmdev *fmdev, u8 
af)
if (reg_idx == FM_BAND_JAPAN  af  FM_RDS_MAX_AF_JAPAN)
return;
 
-   freq = fmdev-rx.region.bot_freq + (af * 100);
+   freq = fmdev-rx.region.bot_freq + (af * FM_KHZ);
if (freq == fmdev-rx.freq) {
fmdbg(Current freq(%d) is matching with received AF(%d)\n,
fmdev-rx.freq, freq);
@@ -1576,7 +1583,7 @@ int fmc_prepare(struct fmdev *fmdev)
fmdev-rx.rds.flag = FM_RDS_DISABLE;
fmdev-rx.freq = FM_UNDEFINED_FREQ;
fmdev-rx.rds_mode = FM_RDS_SYSTEM_RDS;
-   fmdev-rx.af_mode = FM_RX_RDS_AF_SWITCH_MODE_OFF;
+   fmdev-rx.af_mode = FM_RX_RDS_AF_SWITCH_MODE_ON;
fmdev-irq_info.retry = 0;
 
fmdev-tx_data.tx_frq = FM_UNDEFINED_FREQ;
diff --git a/drivers/media/radio/wl128x/fmdrv_common.h 
b/drivers/media/radio/wl128x/fmdrv_common.h
index 196ff7d..aaa54bc 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.h
+++ b/drivers/media/radio/wl128x/fmdrv_common.h
@@ -203,6 +203,7 @@ struct fm_event_msg_hdr {
 /* Band types */
 #define FM_BAND_EUROPE_US  0
 #define FM_BAND_JAPAN  1
+#define FM_BAND_RUSSIAN2
 
 /* Seek directions */
 #define FM_SEARCH_DIRECTION_DOWN   0
@@ -216,14 +217,11 @@ struct fm_event_msg_hdr {
 
 /* Min and Max volume */
 #define FM_RX_VOLUME_MIN   0
-#define FM_RX_VOLUME_MAX   70
-
-/* Volume gain step */
-#define FM_RX_VOLUME_GAIN_STEP 0x370
+#define FM_RX_VOLUME_MAX   0x
 
 /* Mute modes */
-#defineFM_MUTE_ON  0
-#define FM_MUTE_OFF1
+#define FM_MUTE_OFF0
+#defineFM_MUTE_ON  1
 #defineFM_MUTE_ATTENUATE   2
 
 #define FM_RX_UNMUTE_MODE  0x00
@@ -238,8 +236,8 @@ struct fm_event_msg_hdr {
 #define FM_RX_RF_DEPENDENT_MUTE_OFF0
 
 /* RSSI threshold min and max */
-#define FM_RX_RSSI_THRESHOLD_MIN   -128
-#define FM_RX_RSSI_THRESHOLD_MAX   127
+#define FM_RX_RSSI_THRESHOLD_MIN   0   /* 0 dBuV */
+#define FM_RX_RSSI_THRESHOLD_MAX   127 /* 191.1477 dBuV */
 
 /* Stereo/Mono mode */
 #define FM_STEREO_MODE 0
@@ -352,8 +350,8 @@ struct fm_event_msg_hdr {
  * Default RX mode configuration. Chip will be configured
  * with this default values after loading RX firmware.
  */
-#define FM_DEFAULT_RX_VOLUME   10
-#define FM_DEFAULT_RSSI_THRESHOLD  20
+#define FM_DEFAULT_RX_VOLUME   1
+#define FM_DEFAULT_RSSI_THRESHOLD  8   /* 12.0408 dBuV */
 
 /* Range for TX power level in units for dB/uV */
 #define FM_PWR_LVL_LOW 91
@@ -403,5 +401,13 @@ int fmc_get_mode(struct fmdev *, u8 *);
 #define FM_CHANNEL_SPACING_200KHZ 4
 #define FM_FREQ_MUL 50
 
+#define FM_US_BAND_LOW 87500
+#define FM_US_BAND_HIGH18
+#define FM_JAPAN_BAND_LOW  76000
+#define FM_JAPAN_BAND_HIGH 9
+
+#define FM_KHZ 100
+
+
 #endif
 
diff --git 

[PATCH 1/3] wl128x: Fix build errors when GPIOLIB is not enabled.

2012-02-24 Thread manjunatha_halli
From: Randy Dunlap rdun...@xenotime.net

Fix wl128x Kconfig to depend on GPIOLIB since TI_ST also
depends on GPIOLIB.

(.text+0xe6d60): undefined reference to `st_register'
(.text+0xe7016): undefined reference to `st_unregister'
(.text+0xe70ce): undefined reference to `st_unregister'

Signed-off-by: Randy Dunlap rdun...@xenotime.net
Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/wl128x/Kconfig |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/radio/wl128x/Kconfig 
b/drivers/media/radio/wl128x/Kconfig
index 86b2857..ea1e654 100644
--- a/drivers/media/radio/wl128x/Kconfig
+++ b/drivers/media/radio/wl128x/Kconfig
@@ -4,8 +4,8 @@
 menu Texas Instruments WL128x FM driver (ST based)
 config RADIO_WL128X
tristate Texas Instruments WL128x FM Radio
-   depends on VIDEO_V4L2  RFKILL
-   select TI_ST if NET  GPIOLIB
+   depends on VIDEO_V4L2  RFKILL  GPIOLIB
+   select TI_ST if NET
help
Choose Y here if you have this FM radio chip.
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] [media] wl128x: Fixes and few new features

2012-02-24 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

Mauro and the list,

This patch set Fix build errors when GPIOLIB is not enabled.

Also this patch adds few new features to TI's FM driver fetures
are listed below,

1) FM TX RDS Support (RT, PS, AF, PI, PTY)
2) FM RX Russian band support
3) FM RX AF set/get
4) FM RX De-emphasis mode set/get

Along with new features this patch also fixes few issues in the driver
like default rssi level for seek, unnecessory logs etc.

Manjunatha Halli (2):
  wl128x: Add support for FM TX RDS
  wl128x: Add sysfs based support for FM features

Randy Dunlap (1):
  wl128x: Fix build errors when GPIOLIB is not enabled.

 drivers/media/radio/wl128x/Kconfig|4 +-
 drivers/media/radio/wl128x/fmdrv.h|1 +
 drivers/media/radio/wl128x/fmdrv_common.c |   28 +++-
 drivers/media/radio/wl128x/fmdrv_common.h |   41 +++--
 drivers/media/radio/wl128x/fmdrv_rx.c |   15 ++-
 drivers/media/radio/wl128x/fmdrv_tx.c |   47 +++
 drivers/media/radio/wl128x/fmdrv_tx.h |3 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |  235 -
 8 files changed, 316 insertions(+), 58 deletions(-)

-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] wl128x: Add support for FM TX RDS

2012-02-24 Thread manjunatha_halli
From: Manjunatha Halli x0130...@ti.com

This patch adds support for following FM TX RDS features,
 1. Radio Text
 2. PS Name
 3. PI Code
 4. PTY Code.

Along with above this patch fixes few other minor issues(like
fm tx get frequency, unnecessary error messages etc).

Signed-off-by: Manjunatha Halli x0130...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_common.c |   17 +++---
 drivers/media/radio/wl128x/fmdrv_common.h |   17 +++
 drivers/media/radio/wl128x/fmdrv_rx.c |2 +-
 drivers/media/radio/wl128x/fmdrv_tx.c |   41 ++---
 drivers/media/radio/wl128x/fmdrv_tx.h |3 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |   47 +
 6 files changed, 90 insertions(+), 37 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index bf867a6..fcce61a 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -354,7 +354,7 @@ static void send_tasklet(unsigned long arg)
 
/* Check, is there any timeout happened to last transmitted packet */
if ((jiffies - fmdev-last_tx_jiffies)  FM_DRV_TX_TIMEOUT) {
-   fmerr(TX timeout occurred\n);
+   fmdbg(TX timeout occurred\n);
atomic_set(fmdev-tx_cnt, 1);
}
 
@@ -615,7 +615,11 @@ static void fm_irq_handle_rds_start(struct fmdev *fmdev)
 {
if (fmdev-irq_info.flag  FM_RDS_EVENT  fmdev-irq_info.mask) {
fmdbg(irq: rds threshold reached\n);
-   fmdev-irq_info.stage = FM_RDS_SEND_RDS_GETCMD_IDX;
+   /* If RSSI reached below threshold then dont get RDS data */
+   if (fmdev-irq_info.flag  FM_LEV_EVENT)
+   fmdev-irq_info.stage = FM_HW_TUNE_OP_ENDED_IDX;
+   else
+   fmdev-irq_info.stage = FM_RDS_SEND_RDS_GETCMD_IDX;
} else {
/* Continue next function in interrupt handler table */
fmdev-irq_info.stage = FM_HW_TUNE_OP_ENDED_IDX;
@@ -1129,8 +1133,9 @@ int fmc_set_freq(struct fmdev *fmdev, u32 freq_to_set)
 
 int fmc_get_freq(struct fmdev *fmdev, u32 *cur_tuned_frq)
 {
-   if (fmdev-rx.freq == FM_UNDEFINED_FREQ) {
-   fmerr(RX frequency is not set\n);
+   if (fmdev-rx.freq == FM_UNDEFINED_FREQ 
+   fmdev-tx_data.tx_frq == FM_UNDEFINED_FREQ) {
+   fmerr(RX/TX frequency is not set\n);
return -EPERM;
}
if (cur_tuned_frq == NULL) {
@@ -1144,7 +1149,7 @@ int fmc_get_freq(struct fmdev *fmdev, u32 *cur_tuned_frq)
return 0;
 
case FM_MODE_TX:
-   *cur_tuned_frq = 0; /* TODO : Change this later */
+   *cur_tuned_frq = fmdev-tx_data.tx_frq;
return 0;
 
default:
@@ -1574,6 +1579,8 @@ int fmc_prepare(struct fmdev *fmdev)
fmdev-rx.af_mode = FM_RX_RDS_AF_SWITCH_MODE_OFF;
fmdev-irq_info.retry = 0;
 
+   fmdev-tx_data.tx_frq = FM_UNDEFINED_FREQ;
+
fm_rx_reset_rds_cache(fmdev);
init_waitqueue_head(fmdev-rx.rds.read_queue);
 
diff --git a/drivers/media/radio/wl128x/fmdrv_common.h 
b/drivers/media/radio/wl128x/fmdrv_common.h
index d9b9c6c..196ff7d 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.h
+++ b/drivers/media/radio/wl128x/fmdrv_common.h
@@ -48,8 +48,8 @@ struct fm_reg_table {
 #define SEARCH_LVL_SET   15
 #define BAND_SET 16
 #define MUTE_STATUS_SET  17
-#define RDS_PAUSE_LVL_SET18
-#define RDS_PAUSE_DUR_SET19
+#define AUD_PAUSE_LVL_SET18
+#define AUD_PAUSE_DUR_SET19
 #define RDS_MEM_SET  20
 #define RDS_BLK_B_SET21
 #define RDS_MSK_B_SET22
@@ -84,11 +84,12 @@ struct fm_reg_table {
 
 #define FM_POWER_MODE254
 #define FM_INTERRUPT 255
+#define STATION_VALID   123
 
 /* Transmitter API */
 
 #define CHANL_SET55
-#define CHANL_BW_SET   56
+#define SCAN_SPACING_SET 56
 #define REF_SET  57
 #define POWER_ENB_SET90
 #define POWER_ATT_SET58
@@ -103,7 +104,8 @@ struct fm_reg_table {
 #define MONO_SET 66
 #define MUTE 92
 #define MPX_LMT_ENABLE   67
-#define PI_SET   93
+#define REF_ERR_SET 93
+#define PI_SET   68
 #define ECC_SET  69
 #define PTY  70
 #define AF   71
@@ -120,6 +122,10 @@ struct fm_reg_table {
 #define TX_AUDIO_LEVEL_TEST  96
 #define TX_AUDIO_LEVEL_TEST_THRESHOLD73
 #define TX_AUDIO_INPUT_LEVEL_RANGE_SET   54
+#define TX_AUDIO_LEVEL_GET  7
+#define READ_FMANT_TUNE_VALUE104
+
+/* New FM APIs (Rx and Tx) */
 #define RX_ANTENNA_SELECT87
 #define I2C_DEV_ADDR_SET 86
 #define REF_ERR_CALIB_PARAM_SET  

[PATCH] [media] radio: wl128x: Update registration process with ST.

2011-03-23 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

As underlying ST driver registration API's have changed with
latest 2.6.38-rc8 kernel this patch will update the FM driver
accordingly.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_common.c |   16 +---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index 96a95c5..b09b283 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -1494,12 +1494,17 @@ u32 fmc_prepare(struct fmdev *fmdev)
}
 
memset(fm_st_proto, 0, sizeof(fm_st_proto));
-   fm_st_proto.type = ST_FM;
fm_st_proto.recv = fm_st_receive;
fm_st_proto.match_packet = NULL;
fm_st_proto.reg_complete_cb = fm_st_reg_comp_cb;
fm_st_proto.write = NULL; /* TI ST driver will fill write pointer */
fm_st_proto.priv_data = fmdev;
+   fm_st_proto.chnl_id = 0x08;
+   fm_st_proto.max_frame_size = 0xff;
+   fm_st_proto.hdr_len = 1;
+   fm_st_proto.offset_len_in_hdr = 0;
+   fm_st_proto.len_size = 1;
+   fm_st_proto.reserve = 1;
 
ret = st_register(fm_st_proto);
if (ret == -EINPROGRESS) {
@@ -1532,7 +1537,7 @@ u32 fmc_prepare(struct fmdev *fmdev)
g_st_write = fm_st_proto.write;
} else {
fmerr(Failed to get ST write func pointer\n);
-   ret = st_unregister(ST_FM);
+   ret = st_unregister(fm_st_proto);
if (ret  0)
fmerr(st_unregister failed %d\n, ret);
return -EAGAIN;
@@ -1586,6 +1591,7 @@ u32 fmc_prepare(struct fmdev *fmdev)
  */
 u32 fmc_release(struct fmdev *fmdev)
 {
+   static struct st_proto_s fm_st_proto;
u32 ret;
 
if (!test_bit(FM_CORE_READY, fmdev-flag)) {
@@ -1604,7 +1610,11 @@ u32 fmc_release(struct fmdev *fmdev)
fmdev-resp_comp = NULL;
fmdev-rx.freq = 0;
 
-   ret = st_unregister(ST_FM);
+   memset(fm_st_proto, 0, sizeof(fm_st_proto));
+   fm_st_proto.chnl_id = 0x08;
+
+   ret = st_unregister(fm_st_proto);
+
if (ret  0)
fmerr(Failed to de-register FM from ST %d\n, ret);
else
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] [media] radio: wl128x: Update registration process with ST.

2011-03-21 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

As underlying ST driver registration API's have changed this
patch will update the FM driver accordingly.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_common.c |   16 +---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index 96a95c5..b09b283 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -1494,12 +1494,17 @@ u32 fmc_prepare(struct fmdev *fmdev)
}
 
memset(fm_st_proto, 0, sizeof(fm_st_proto));
-   fm_st_proto.type = ST_FM;
fm_st_proto.recv = fm_st_receive;
fm_st_proto.match_packet = NULL;
fm_st_proto.reg_complete_cb = fm_st_reg_comp_cb;
fm_st_proto.write = NULL; /* TI ST driver will fill write pointer */
fm_st_proto.priv_data = fmdev;
+   fm_st_proto.chnl_id = 0x08;
+   fm_st_proto.max_frame_size = 0xff;
+   fm_st_proto.hdr_len = 1;
+   fm_st_proto.offset_len_in_hdr = 0;
+   fm_st_proto.len_size = 1;
+   fm_st_proto.reserve = 1;
 
ret = st_register(fm_st_proto);
if (ret == -EINPROGRESS) {
@@ -1532,7 +1537,7 @@ u32 fmc_prepare(struct fmdev *fmdev)
g_st_write = fm_st_proto.write;
} else {
fmerr(Failed to get ST write func pointer\n);
-   ret = st_unregister(ST_FM);
+   ret = st_unregister(fm_st_proto);
if (ret  0)
fmerr(st_unregister failed %d\n, ret);
return -EAGAIN;
@@ -1586,6 +1591,7 @@ u32 fmc_prepare(struct fmdev *fmdev)
  */
 u32 fmc_release(struct fmdev *fmdev)
 {
+   static struct st_proto_s fm_st_proto;
u32 ret;
 
if (!test_bit(FM_CORE_READY, fmdev-flag)) {
@@ -1604,7 +1610,11 @@ u32 fmc_release(struct fmdev *fmdev)
fmdev-resp_comp = NULL;
fmdev-rx.freq = 0;
 
-   ret = st_unregister(ST_FM);
+   memset(fm_st_proto, 0, sizeof(fm_st_proto));
+   fm_st_proto.chnl_id = 0x08;
+
+   ret = st_unregister(fm_st_proto);
+
if (ret  0)
fmerr(Failed to de-register FM from ST %d\n, ret);
else
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] [media] radio: wl128x: Fix printk format warning

2011-03-21 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
Signed-off-by: Randy Dunlap randy.dun...@oracle.com
---
 drivers/media/radio/wl128x/fmdrv_common.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index 12f4c65..96a95c5 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -272,7 +272,7 @@ static void recv_tasklet(unsigned long arg)
while ((skb = skb_dequeue(fmdev-rx_q))) {
if (skb-len  sizeof(struct fm_event_msg_hdr)) {
fmerr(skb(%p) has only %d bytes
-   atleast need %d bytes to decode\n, skb,
+   need at least %zd bytes to decode\n, skb,
skb-len, sizeof(struct fm_event_msg_hdr));
kfree_skb(skb);
continue;
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC V10 1/7] drivers:media:radio: wl128x: FM Driver common header file

2011-01-11 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

These are common headers used in FM submodules (FM V4L2,
FM common, FM Rx,and FM TX).

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
Reviewed-by: Hans Verkuil hverk...@xs4all.nl
---
 drivers/media/radio/wl128x/fmdrv.h |  244 
 1 files changed, 244 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/fmdrv.h

diff --git a/drivers/media/radio/wl128x/fmdrv.h 
b/drivers/media/radio/wl128x/fmdrv.h
new file mode 100644
index 000..392b62d
--- /dev/null
+++ b/drivers/media/radio/wl128x/fmdrv.h
@@ -0,0 +1,244 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *
+ *  Common header for all FM driver sub-modules.
+ *
+ *  Copyright (C) 2011 Texas Instruments
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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
+ *
+ */
+
+#ifndef _FM_DRV_H
+#define _FM_DRV_H
+
+#include linux/skbuff.h
+#include linux/interrupt.h
+#include sound/core.h
+#include sound/initval.h
+#include linux/timer.h
+#include linux/version.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-common.h
+#include media/v4l2-ctrls.h
+
+#define FM_DRV_VERSION0.09
+/* Should match with FM_DRV_VERSION */
+#define FM_DRV_RADIO_VERSION  KERNEL_VERSION(0, 0, 1)
+#define FM_DRV_NAME   ti_fmdrv
+#define FM_DRV_CARD_SHORT_NAMETI FM Radio
+#define FM_DRV_CARD_LONG_NAME Texas Instruments FM Radio
+
+/* Flag info */
+#define FM_INTTASK_RUNNING0
+#define FM_INTTASK_SCHEDULE_PENDING   1
+#define FM_FW_DW_INPROGRESS 2
+#define FM_CORE_READY 3
+#define FM_CORE_TRANSPORT_READY   4
+#define FM_AF_SWITCH_INPROGRESS  5
+#define FM_CORE_TX_XMITING   6
+
+#define FM_TUNE_COMPLETE 0x1
+#define FM_BAND_LIMIT0x2
+
+#define FM_DRV_TX_TIMEOUT  (5*HZ)  /* 5 seconds */
+#define FM_DRV_RX_SEEK_TIMEOUT (20*HZ) /* 20 seconds */
+
+#define NO_OF_ENTRIES_IN_ARRAY(array) (sizeof(array) / sizeof(array[0]))
+
+#define fmerr(format, ...) \
+   printk(KERN_ERR fmdrv:  format, ## __VA_ARGS__)
+#define fmwarn(format, ...) \
+   printk(KERN_WARNING fmdrv:  format, ##__VA_ARGS__)
+#ifdef DEBUG
+#define fmdbg(format, ...) \
+   printk(KERN_DEBUG fmdrv:  format, ## __VA_ARGS__)
+#else /* DEBUG */
+#define fmdbg(format, ...)
+#endif
+enum {
+   FM_MODE_OFF,
+   FM_MODE_TX,
+   FM_MODE_RX,
+   FM_MODE_ENTRY_MAX
+};
+
+#define FM_RX_RDS_INFO_FIELD_MAX   8   /* 4 Group * 2 Bytes */
+
+/* RX RDS data format */
+struct fm_rdsdata_format {
+   union {
+   struct {
+   u8 buff[FM_RX_RDS_INFO_FIELD_MAX];
+   } groupdatabuff;
+   struct {
+   u16 pidata;
+   u8 blk_b[2];
+   u8 blk_c[2];
+   u8 blk_d[2];
+   } groupgeneral;
+   struct {
+   u16 pidata;
+   u8 blk_b[2];
+   u8 af[2];
+   u8 ps[2];
+   } group0A;
+   struct {
+   u16 pi[2];
+   u8 blk_b[2];
+   u8 ps[2];
+   } group0B;
+   } data;
+};
+
+/* FM region (Europe/US, Japan) info */
+struct region_info {
+   u32 chanl_space;
+   u32 bot_freq;
+   u32 top_freq;
+   u8 fm_band;
+};
+struct fmdev;
+typedef void (*int_handler_prototype) (struct fmdev *);
+
+/* FM Interrupt processing related info */
+struct fm_irq {
+   u8 stage;
+   u16 flag;   /* FM interrupt flag */
+   u16 mask;   /* FM interrupt mask */
+   /* Interrupt process timeout handler */
+   struct timer_list timer;
+   u8 retry;
+   int_handler_prototype *handlers;
+};
+
+/* RDS info */
+struct fm_rds {
+   u8 flag;/* RX RDS on/off status */
+   u8 last_blk_idx;/* Last received RDS block */
+
+   /* RDS buffer */
+   wait_queue_head_t read_queue;
+   u32 buf_size;   /* Size is always multiple of 3 */
+   u32 wr_idx;
+   u32 rd_idx;
+   u8 *buff;
+};
+
+#define FM_RDS_MAX_AF_LIST 25
+
+/*
+ * Current RX channel Alternate Frequency cache.
+ * This info is used to switch to other freq (AF)
+ * when current channel signal strengh is below RSSI 

[RFC V10 6/7] drivers:media:radio: wl128x: Kconfig Makefile for wl128x driver

2011-01-11 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
Reviewed-by: Hans Verkuil hverk...@xs4all.nl
---
 drivers/media/radio/wl128x/Kconfig  |   17 +
 drivers/media/radio/wl128x/Makefile |6 ++
 2 files changed, 23 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/Kconfig
 create mode 100644 drivers/media/radio/wl128x/Makefile

diff --git a/drivers/media/radio/wl128x/Kconfig 
b/drivers/media/radio/wl128x/Kconfig
new file mode 100644
index 000..749f67b
--- /dev/null
+++ b/drivers/media/radio/wl128x/Kconfig
@@ -0,0 +1,17 @@
+#
+# TI's wl128x FM driver based on TI's ST driver.
+#
+menu Texas Instruments WL128x FM driver (ST based)
+config RADIO_WL128X
+   tristate Texas Instruments WL128x FM Radio
+   depends on VIDEO_V4L2  RFKILL
+   select TI_ST
+   help
+   Choose Y here if you have this FM radio chip.
+
+   In order to control your radio card, you will need to use programs
+   that are compatible with the Video For Linux 2 API.  Information on
+   this API and pointers to v4l2 programs may be found at
+   file:Documentation/video4linux/API.html.
+
+endmenu
diff --git a/drivers/media/radio/wl128x/Makefile 
b/drivers/media/radio/wl128x/Makefile
new file mode 100644
index 000..32a0ead
--- /dev/null
+++ b/drivers/media/radio/wl128x/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for TI's shared transport driver based wl128x
+# FM radio.
+#
+obj-$(CONFIG_RADIO_WL128X) += fm_drv.o
+fm_drv-objs:= fmdrv_common.o fmdrv_rx.o fmdrv_tx.o fmdrv_v4l2.o
-- 
1.5.6.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC V10 5/7] drivers:media:radio: wl128x: FM driver TX sources

2011-01-11 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

This has implementation for FM TX functionality.
It communicates with FM V4l2 module and FM common module.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
Reviewed-by: Hans Verkuil hverk...@xs4all.nl
---
 drivers/media/radio/wl128x/fmdrv_tx.c |  425 +
 drivers/media/radio/wl128x/fmdrv_tx.h |   37 +++
 2 files changed, 462 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/fmdrv_tx.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_tx.h

diff --git a/drivers/media/radio/wl128x/fmdrv_tx.c 
b/drivers/media/radio/wl128x/fmdrv_tx.c
new file mode 100644
index 000..be54068
--- /dev/null
+++ b/drivers/media/radio/wl128x/fmdrv_tx.c
@@ -0,0 +1,425 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *  This sub-module of FM driver implements FM TX functionality.
+ *
+ *  Copyright (C) 2011 Texas Instruments
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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/delay.h
+#include fmdrv.h
+#include fmdrv_common.h
+#include fmdrv_tx.h
+
+u32 fm_tx_set_stereo_mono(struct fmdev *fmdev, u16 mode)
+{
+   u16 payload;
+   u32 ret;
+
+   if (fmdev-tx_data.aud_mode == mode)
+   return 0;
+
+   fmdbg(stereo mode: %d\n, mode);
+
+   /* Set Stereo/Mono mode */
+   payload = (1 - mode);
+   ret = fmc_send_cmd(fmdev, MONO_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   fmdev-tx_data.aud_mode = mode;
+
+   return ret;
+}
+
+static u32 set_rds_text(struct fmdev *fmdev, u8 *rds_text)
+{
+   u16 payload;
+   u32 ret;
+
+   ret = fmc_send_cmd(fmdev, RDS_DATA_SET, REG_WR, rds_text,
+   strlen(rds_text), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Scroll mode */
+   payload = (u16)0x1;
+   ret = fmc_send_cmd(fmdev, DISPLAY_MODE, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   return 0;
+}
+
+static u32 set_rds_data_mode(struct fmdev *fmdev, u8 mode)
+{
+   u16 payload;
+   u32 ret;
+
+   /* Setting unique PI TODO: how unique? */
+   payload = (u16)0xcafe;
+   ret = fmc_send_cmd(fmdev, PI_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Set decoder id */
+   payload = (u16)0xa;
+   ret = fmc_send_cmd(fmdev, DI_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* TODO: RDS_MODE_GET? */
+   return 0;
+}
+
+static u32 set_rds_len(struct fmdev *fmdev, u8 type, u16 len)
+{
+   u16 payload;
+   u32 ret;
+
+   len |= type  8;
+   payload = len;
+   ret = fmc_send_cmd(fmdev, RDS_CONFIG_DATA_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* TODO: LENGTH_GET? */
+   return 0;
+}
+
+u32 fm_tx_set_rds_mode(struct fmdev *fmdev, u8 rds_en_dis)
+{
+   u16 payload;
+   u32 ret;
+   u8 rds_text[] = Zoom2\n;
+
+   fmdbg(rds_en_dis:%d(E:%d, D:%d)\n, rds_en_dis,
+  FM_RDS_ENABLE, FM_RDS_DISABLE);
+
+   if (rds_en_dis == FM_RDS_ENABLE) {
+   /* Set RDS length */
+   set_rds_len(fmdev, 0, strlen(rds_text));
+
+   /* Set RDS text */
+   set_rds_text(fmdev, rds_text);
+
+   /* Set RDS mode */
+   set_rds_data_mode(fmdev, 0x0);
+   }
+
+   /* Send command to enable RDS */
+   if (rds_en_dis == FM_RDS_ENABLE)
+   payload = 0x01;
+   else
+   payload = 0x00;
+
+   ret = fmc_send_cmd(fmdev, RDS_DATA_ENB, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   if (rds_en_dis == FM_RDS_ENABLE) {
+   /* Set RDS length */
+   set_rds_len(fmdev, 0, strlen(rds_text));
+
+   /* Set RDS text */
+   set_rds_text(fmdev, rds_text);
+   }
+   fmdev-tx_data.rds.flag = rds_en_dis;
+
+   return 0;
+}
+
+u32 fm_tx_set_radio_text(struct fmdev 

[RFC V10 4/7] drivers:media:radio: wl128x: FM driver RX sources

2011-01-11 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

This has implementation for FM RX functionality.
It communicates with FM V4l2 module and FM common module

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
Reviewed-by: Hans Verkuil hverk...@xs4all.nl
---
 drivers/media/radio/wl128x/fmdrv_rx.c |  847 +
 drivers/media/radio/wl128x/fmdrv_rx.h |   59 +++
 2 files changed, 906 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/fmdrv_rx.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_rx.h

diff --git a/drivers/media/radio/wl128x/fmdrv_rx.c 
b/drivers/media/radio/wl128x/fmdrv_rx.c
new file mode 100644
index 000..ec529b5
--- /dev/null
+++ b/drivers/media/radio/wl128x/fmdrv_rx.c
@@ -0,0 +1,847 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *  This sub-module of FM driver implements FM RX functionality.
+ *
+ *  Copyright (C) 2011 Texas Instruments
+ *  Author: Raja Mani raja_m...@ti.com
+ *  Author: Manjunatha Halli manjunatha_ha...@ti.com
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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 fmdrv.h
+#include fmdrv_common.h
+#include fmdrv_rx.h
+
+void fm_rx_reset_rds_cache(struct fmdev *fmdev)
+{
+   fmdev-rx.rds.flag = FM_RDS_DISABLE;
+   fmdev-rx.rds.last_blk_idx = 0;
+   fmdev-rx.rds.wr_idx = 0;
+   fmdev-rx.rds.rd_idx = 0;
+
+   if (fmdev-rx.af_mode == FM_RX_RDS_AF_SWITCH_MODE_ON)
+   fmdev-irq_info.mask |= FM_LEV_EVENT;
+}
+
+void fm_rx_reset_station_info(struct fmdev *fmdev)
+{
+   fmdev-rx.stat_info.picode = FM_NO_PI_CODE;
+   fmdev-rx.stat_info.afcache_size = 0;
+   fmdev-rx.stat_info.af_list_max = 0;
+}
+
+u32 fm_rx_set_freq(struct fmdev *fmdev, u32 freq)
+{
+   unsigned long timeleft;
+   u16 payload, curr_frq, intr_flag;
+   u32 curr_frq_in_khz;
+   u32 ret, resp_len;
+
+   if (freq  fmdev-rx.region.bot_freq || freq  
fmdev-rx.region.top_freq) {
+   fmerr(Invalid frequency %d\n, freq);
+   return -EINVAL;
+   }
+
+   /* Set audio enable */
+   payload = FM_RX_AUDIO_ENABLE_I2S_AND_ANALOG;
+
+   ret = fmc_send_cmd(fmdev, AUDIO_ENABLE_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Set hilo to automatic selection */
+   payload = FM_RX_IFFREQ_HILO_AUTOMATIC;
+   ret = fmc_send_cmd(fmdev, HILO_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Calculate frequency index and set*/
+   payload = (freq - fmdev-rx.region.bot_freq) / FM_FREQ_MUL;
+
+   ret = fmc_send_cmd(fmdev, FREQ_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Read flags - just to clear any pending interrupts if we had */
+   ret = fmc_send_cmd(fmdev, FLAG_GET, REG_RD, NULL, 2, NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Enable FR, BL interrupts */
+   intr_flag = fmdev-irq_info.mask;
+   fmdev-irq_info.mask = (FM_FR_EVENT | FM_BL_EVENT);
+   payload = fmdev-irq_info.mask;
+   ret = fmc_send_cmd(fmdev, INT_MASK_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Start tune */
+   payload = FM_TUNER_PRESET_MODE;
+   ret = fmc_send_cmd(fmdev, TUNER_MODE_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   goto exit;
+
+   /* Wait for tune ended interrupt */
+   init_completion(fmdev-maintask_comp);
+   timeleft = wait_for_completion_timeout(fmdev-maintask_comp,
+   FM_DRV_TX_TIMEOUT);
+   if (!timeleft) {
+   fmerr(Timeout(%d sec),didn't get tune ended int\n,
+  jiffies_to_msecs(FM_DRV_TX_TIMEOUT) / 1000);
+   ret = -ETIMEDOUT;
+   goto exit;
+   }
+
+   /* Read freq back to confirm */
+   ret = fmc_send_cmd(fmdev, FREQ_SET, REG_RD, NULL, 2, curr_frq, 
resp_len);
+   if (ret  0)
+   goto exit;
+
+   curr_frq = be16_to_cpu(curr_frq);
+   curr_frq_in_khz = (fmdev-rx.region.bot_freq + ((u32)curr_frq * 
FM_FREQ_MUL));
+
+ 

[RFC V10 7/7] drivers:media:radio: Update Kconfig and Makefile for wl128x FM driver.

2011-01-11 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
Reviewed-by: Hans Verkuil hverk...@xs4all.nl
---
 drivers/media/radio/Kconfig  |3 +++
 drivers/media/radio/Makefile |1 +
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 83567b8..4529bc7 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -452,4 +452,7 @@ config RADIO_TIMBERDALE
  found behind the Timberdale FPGA on the Russellville board.
  Enabling this driver will automatically select the DSP and tuner.
 
+# TI's ST based wl128x FM radio
+source drivers/media/radio/wl128x/Kconfig
+
 endif # RADIO_ADAPTERS
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
index f615583..b71f448 100644
--- a/drivers/media/radio/Makefile
+++ b/drivers/media/radio/Makefile
@@ -26,5 +26,6 @@ obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o
 obj-$(CONFIG_RADIO_SAA7706H) += saa7706h.o
 obj-$(CONFIG_RADIO_TEF6862) += tef6862.o
 obj-$(CONFIG_RADIO_TIMBERDALE) += radio-timb.o
+obj-$(CONFIG_RADIO_WL128X) += wl128x/
 
 EXTRA_CFLAGS += -Isound
-- 
1.5.6.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC V10 2/7] drivers:media:radio: wl128x: FM Driver V4L2 sources

2011-01-11 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

This module interfaces V4L2 subsystem and FM common module.
It registers itself with V4L2 as Radio module.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
Reviewed-by: Hans Verkuil hverk...@xs4all.nl
---
 drivers/media/radio/wl128x/fmdrv_v4l2.c |  580 +++
 drivers/media/radio/wl128x/fmdrv_v4l2.h |   33 ++
 2 files changed, 613 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/fmdrv_v4l2.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_v4l2.h

diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c 
b/drivers/media/radio/wl128x/fmdrv_v4l2.c
new file mode 100644
index 000..d50e5ac
--- /dev/null
+++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c
@@ -0,0 +1,580 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *  This file provides interfaces to V4L2 subsystem.
+ *
+ *  This module registers with V4L2 subsystem as Radio
+ *  data system interface (/dev/radio). During the registration,
+ *  it will expose two set of function pointers.
+ *
+ *1) File operation related API (open, close, read, write, poll...etc).
+ *2) Set of V4L2 IOCTL complaint API.
+ *
+ *  Copyright (C) 2011 Texas Instruments
+ *  Author: Raja Mani raja_m...@ti.com
+ *  Author: Manjunatha Halli manjunatha_ha...@ti.com
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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 fmdrv.h
+#include fmdrv_v4l2.h
+#include fmdrv_common.h
+#include fmdrv_rx.h
+#include fmdrv_tx.h
+
+static struct video_device *gradio_dev;
+static u8 radio_disconnected;
+
+/* -- V4L2 RADIO (/dev/radioX) device file operation interfaces --- */
+
+/* Read RX RDS data */
+static ssize_t fm_v4l2_fops_read(struct file *file, char __user * buf,
+   size_t count, loff_t *ppos)
+{
+   u8 rds_mode;
+   int ret;
+   struct fmdev *fmdev;
+
+   fmdev = video_drvdata(file);
+
+   if (!radio_disconnected) {
+   fmerr(FM device is already disconnected\n);
+   return -EIO;
+   }
+
+   /* Turn on RDS mode , if it is disabled */
+   ret = fm_rx_get_rds_mode(fmdev, rds_mode);
+   if (ret  0) {
+   fmerr(Unable to read current rds mode\n);
+   return ret;
+   }
+
+   if (rds_mode == FM_RDS_DISABLE) {
+   ret = fmc_set_rds_mode(fmdev, FM_RDS_ENABLE);
+   if (ret  0) {
+   fmerr(Failed to enable rds mode\n);
+   return ret;
+   }
+   }
+
+   /* Copy RDS data from internal buffer to user buffer */
+   return fmc_transfer_rds_from_internal_buff(fmdev, file, buf, count);
+}
+
+/* Write TX RDS data */
+static ssize_t fm_v4l2_fops_write(struct file *file, const char __user * buf,
+   size_t count, loff_t *ppos)
+{
+   struct tx_rds rds;
+   int ret;
+   struct fmdev *fmdev;
+
+   ret = copy_from_user(rds, buf, sizeof(rds));
+   fmdbg((%d)type: %d, text %s, af %d\n,
+  ret, rds.text_type, rds.text, rds.af_freq);
+
+   fmdev = video_drvdata(file);
+   fm_tx_set_radio_text(fmdev, rds.text, rds.text_type);
+   fm_tx_set_af(fmdev, rds.af_freq);
+
+   return 0;
+}
+
+static u32 fm_v4l2_fops_poll(struct file *file, struct poll_table_struct *pts)
+{
+   int ret;
+   struct fmdev *fmdev;
+
+   fmdev = video_drvdata(file);
+   ret = fmc_is_rds_data_available(fmdev, file, pts);
+   if (ret  0)
+   return POLLIN | POLLRDNORM;
+
+   return 0;
+}
+
+/*
+ * Handle open request for /dev/radioX device.
+ * Start with FM RX mode as default.
+ */
+static int fm_v4l2_fops_open(struct file *file)
+{
+   int ret;
+   struct fmdev *fmdev = NULL;
+
+   /* Don't allow multiple open */
+   if (radio_disconnected) {
+   fmerr(FM device is already opened\n);
+   return -EBUSY;
+   }
+
+   fmdev = video_drvdata(file);
+
+   ret = fmc_prepare(fmdev);
+   if (ret  0) {
+   fmerr(Unable to prepare FM CORE\n);
+   return ret;
+   }
+
+   fmdbg(Load FM RX firmware..\n);
+
+   ret = fmc_set_mode(fmdev, FM_MODE_RX);
+   if (ret  0) {
+   fmerr(Unable to load FM RX firmware\n);
+   return ret;
+   }
+   radio_disconnected = 1;
+
+ 

[RFC V10 0/7] FM V4L2 drivers for WL128x

2011-01-11 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Mauro and the list,

This is the v10 version of the TI WL128x FM V4L2 drivers patchset.
This introduces wl128x folder under the drivers/media/radio which cater
to FM core on Texas Instrument's WL128x (also compatible with WL127x)
WiLink chipsets.
WL128x's FM can work in either Rx or Tx mode, and V4L2 interfaces are
provided for both.

** patch description **

Texas Instrument's WL128x chipset packs BT, FM, GPS and WLAN in a single
die with BT, FM and GPS being interfaced over a single UART.
This driver works on top of the shared transport line discipline driver.
This driver can also be made use for the WL127x version of the chip which
packs BT, FM and WLAN only.

Comments on the last version of the patches have been taken care,
such as,
- Remove use of 'break' after 'return' statment in few switch case statments.
- Remove some unneccessory checks in fmdrv_common and fmdrv_rx

Thanks  Regards,
Manjunatha Halli

Manjunatha Halli (7):
  drivers:media:radio: wl128x: FM Driver common header file
  drivers:media:radio: wl128x: FM Driver V4L2 sources
  drivers:media:radio: wl128x: FM Driver Common  sources
  drivers:media:radio: wl128x: FM driver RX sources
  drivers:media:radio: wl128x: FM driver TX sources
  drivers:media:radio: wl128x: Kconfig  Makefile for wl128x driver
  drivers:media:radio: Update Kconfig and Makefile for wl128x FM
driver.

 drivers/media/radio/Kconfig   |3 +
 drivers/media/radio/Makefile  |1 +
 drivers/media/radio/wl128x/Kconfig|   17 +
 drivers/media/radio/wl128x/Makefile   |6 +
 drivers/media/radio/wl128x/fmdrv.h|  244 +
 drivers/media/radio/wl128x/fmdrv_common.c | 1677 +
 drivers/media/radio/wl128x/fmdrv_common.h |  402 +++
 drivers/media/radio/wl128x/fmdrv_rx.c |  847 +++
 drivers/media/radio/wl128x/fmdrv_rx.h |   59 +
 drivers/media/radio/wl128x/fmdrv_tx.c |  425 
 drivers/media/radio/wl128x/fmdrv_tx.h |   37 +
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |  580 ++
 drivers/media/radio/wl128x/fmdrv_v4l2.h   |   33 +
 13 files changed, 4331 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/Kconfig
 create mode 100644 drivers/media/radio/wl128x/Makefile
 create mode 100644 drivers/media/radio/wl128x/fmdrv.h
 create mode 100644 drivers/media/radio/wl128x/fmdrv_common.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_common.h
 create mode 100644 drivers/media/radio/wl128x/fmdrv_rx.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_rx.h
 create mode 100644 drivers/media/radio/wl128x/fmdrv_tx.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_tx.h
 create mode 100644 drivers/media/radio/wl128x/fmdrv_v4l2.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_v4l2.h

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC V9 7/7] drivers:media:radio: Update Kconfig and Makefile for wl128x FM driver.

2011-01-10 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/Kconfig  |3 +++
 drivers/media/radio/Makefile |1 +
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 83567b8..4529bc7 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -452,4 +452,7 @@ config RADIO_TIMBERDALE
  found behind the Timberdale FPGA on the Russellville board.
  Enabling this driver will automatically select the DSP and tuner.
 
+# TI's ST based wl128x FM radio
+source drivers/media/radio/wl128x/Kconfig
+
 endif # RADIO_ADAPTERS
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
index f615583..b71f448 100644
--- a/drivers/media/radio/Makefile
+++ b/drivers/media/radio/Makefile
@@ -26,5 +26,6 @@ obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o
 obj-$(CONFIG_RADIO_SAA7706H) += saa7706h.o
 obj-$(CONFIG_RADIO_TEF6862) += tef6862.o
 obj-$(CONFIG_RADIO_TIMBERDALE) += radio-timb.o
+obj-$(CONFIG_RADIO_WL128X) += wl128x/
 
 EXTRA_CFLAGS += -Isound
-- 
1.5.6.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC V9 0/7] FM V4L2 drivers for WL128x

2011-01-10 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Mauro and the list,

This is the v9 version of the TI WL128x FM V4L2 drivers patchset.
This introduces wl128x folder under the drivers/media/radio which cater
to FM core on Texas Instrument's WL128x (also compatible with WL127x)
WiLink chipsets.
WL128x's FM can work in either Rx or Tx mode, and V4L2 interfaces are
provided for both.

** patch description **

Texas Instrument's WL128x chipset packs BT, FM, GPS and WLAN in a single
die with BT, FM and GPS being interfaced over a single UART.
This driver works on top of the shared transport line discipline driver.
This driver can also be made use for the WL127x version of the chip which
packs BT, FM and WLAN only.

Comments on the last version of the patches have been taken care,
such as,
- using the 'early return' constructs where applicable.
- Renaming all the variables based on scope and frequency of use.
- Use of 'temp' pointers wherever required insted of breaking the lines.
- printing the error messages at the lowest level,and just propagate the
error code up without repeating the error message.

Thanks  Regards,
Manjunatha Halli


Manjunatha Halli (7):
  drivers:media:radio: wl128x: fmdrv common header file
  drivers:media:radio: wl128x: FM Driver V4L2 sources
  drivers:media:radio: wl128x: FM Driver Common  sources
  drivers:media:radio: wl128x: FM driver RX sources
  drivers:media:radio: wl128x: FM driver TX sources
  drivers:media:radio: wl128x: Kconfig  Makefile for wl128x driver
  drivers:media:radio: Update Kconfig and Makefile for wl128x FM
driver.

 drivers/media/radio/Kconfig   |3 +
 drivers/media/radio/Makefile  |1 +
 drivers/media/radio/wl128x/Kconfig|   17 +
 drivers/media/radio/wl128x/Makefile   |6 +
 drivers/media/radio/wl128x/fmdrv.h|  242 
 drivers/media/radio/wl128x/fmdrv_common.c | 1693 +
 drivers/media/radio/wl128x/fmdrv_common.h |  402 +++
 drivers/media/radio/wl128x/fmdrv_rx.c |  876 +++
 drivers/media/radio/wl128x/fmdrv_rx.h |   59 +
 drivers/media/radio/wl128x/fmdrv_tx.c |  433 
 drivers/media/radio/wl128x/fmdrv_tx.h |   37 +
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |  594 ++
 drivers/media/radio/wl128x/fmdrv_v4l2.h   |   33 +
 13 files changed, 4396 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/Kconfig
 create mode 100644 drivers/media/radio/wl128x/Makefile
 create mode 100644 drivers/media/radio/wl128x/fmdrv.h
 create mode 100644 drivers/media/radio/wl128x/fmdrv_common.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_common.h
 create mode 100644 drivers/media/radio/wl128x/fmdrv_rx.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_rx.h
 create mode 100644 drivers/media/radio/wl128x/fmdrv_tx.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_tx.h
 create mode 100644 drivers/media/radio/wl128x/fmdrv_v4l2.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_v4l2.h

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC V9 2/7] drivers:media:radio: wl128x: FM Driver V4L2 sources

2011-01-10 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

This module interfaces V4L2 subsystem and FM common module.
It registers itself with V4L2 as Radio module.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_v4l2.c |  594 +++
 drivers/media/radio/wl128x/fmdrv_v4l2.h |   33 ++
 2 files changed, 627 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/fmdrv_v4l2.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_v4l2.h

diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c 
b/drivers/media/radio/wl128x/fmdrv_v4l2.c
new file mode 100644
index 000..9eb20e9
--- /dev/null
+++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c
@@ -0,0 +1,594 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *  This file provides interfaces to V4L2 subsystem.
+ *
+ *  This module registers with V4L2 subsystem as Radio
+ *  data system interface (/dev/radio). During the registration,
+ *  it will expose two set of function pointers.
+ *
+ *1) File operation related API (open, close, read, write, poll...etc).
+ *2) Set of V4L2 IOCTL complaint API.
+ *
+ *  Copyright (C) 2011 Texas Instruments
+ *  Author: Raja Mani raja_m...@ti.com
+ *  Author: Manjunatha Halli manjunatha_ha...@ti.com
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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 fmdrv.h
+#include fmdrv_v4l2.h
+#include fmdrv_common.h
+#include fmdrv_rx.h
+#include fmdrv_tx.h
+
+static struct video_device *gradio_dev;
+static u8 radio_disconnected;
+
+/* -- V4L2 RADIO (/dev/radioX) device file operation interfaces --- */
+
+/* Read RX RDS data */
+static ssize_t fm_v4l2_fops_read(struct file *file, char __user * buf,
+   size_t count, loff_t *ppos)
+{
+   u8 rds_mode;
+   int ret;
+   struct fmdev *fmdev;
+
+   fmdev = video_drvdata(file);
+
+   if (!radio_disconnected) {
+   fmerr(FM device is already disconnected\n);
+   return -EIO;
+   }
+
+   /* Turn on RDS mode , if it is disabled */
+   ret = fm_rx_get_rds_mode(fmdev, rds_mode);
+   if (ret  0) {
+   fmerr(Unable to read current rds mode\n);
+   return ret;
+   }
+
+   if (rds_mode == FM_RDS_DISABLE) {
+   ret = fmc_set_rds_mode(fmdev, FM_RDS_ENABLE);
+   if (ret  0) {
+   fmerr(Failed to enable rds mode\n);
+   return ret;
+   }
+   }
+
+   /* Copy RDS data from internal buffer to user buffer */
+   ret = fmc_transfer_rds_from_internal_buff(fmdev, file, buf, count);
+
+   return ret;
+}
+
+/* Write TX RDS data */
+static ssize_t fm_v4l2_fops_write(struct file *file, const char __user * buf,
+   size_t count, loff_t *ppos)
+{
+   struct tx_rds rds;
+   int ret;
+   struct fmdev *fmdev;
+
+   ret = copy_from_user(rds, buf, sizeof(rds));
+   fmdbg((%d)type: %d, text %s, af %d\n,
+  ret, rds.text_type, rds.text, rds.af_freq);
+
+   fmdev = video_drvdata(file);
+   fm_tx_set_radio_text(fmdev, rds.text, rds.text_type);
+   fm_tx_set_af(fmdev, rds.af_freq);
+
+   return 0;
+}
+
+static u32 fm_v4l2_fops_poll(struct file *file, struct poll_table_struct *pts)
+{
+   int ret;
+   struct fmdev *fmdev;
+
+   fmdev = video_drvdata(file);
+   ret = fmc_is_rds_data_available(fmdev, file, pts);
+   if (ret  0)
+   return POLLIN | POLLRDNORM;
+
+   return 0;
+}
+
+/*
+ * Handle open request for /dev/radioX device.
+ * Start with FM RX mode as default.
+ */
+static int fm_v4l2_fops_open(struct file *file)
+{
+   int ret;
+   struct fmdev *fmdev = NULL;
+
+   /* Don't allow multiple open */
+   if (radio_disconnected) {
+   fmerr(FM device is already opened\n);
+   return -EBUSY;
+   }
+
+   fmdev = video_drvdata(file);
+
+   ret = fmc_prepare(fmdev);
+   if (ret  0) {
+   fmerr(Unable to prepare FM CORE\n);
+   return ret;
+   }
+
+   fmdbg(Load FM RX firmware..\n);
+
+   ret = fmc_set_mode(fmdev, FM_MODE_RX);
+   if (ret  0) {
+   fmerr(Unable to load FM RX firmware\n);
+   return ret;
+   }
+   radio_disconnected = 1;
+
+   return ret;
+}
+

[RFC V9 4/7] drivers:media:radio: wl128x: FM driver RX sources

2011-01-10 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

This has implementation for FM RX functionality.
It communicates with FM V4l2 module and FM common module

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_rx.c |  876 +
 drivers/media/radio/wl128x/fmdrv_rx.h |   59 +++
 2 files changed, 935 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/fmdrv_rx.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_rx.h

diff --git a/drivers/media/radio/wl128x/fmdrv_rx.c 
b/drivers/media/radio/wl128x/fmdrv_rx.c
new file mode 100644
index 000..c2cb213
--- /dev/null
+++ b/drivers/media/radio/wl128x/fmdrv_rx.c
@@ -0,0 +1,876 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *  This sub-module of FM driver implements FM RX functionality.
+ *
+ *  Copyright (C) 2011 Texas Instruments
+ *  Author: Raja Mani raja_m...@ti.com
+ *  Author: Manjunatha Halli manjunatha_ha...@ti.com
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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 fmdrv.h
+#include fmdrv_common.h
+#include fmdrv_rx.h
+
+void fm_rx_reset_rds_cache(struct fmdev *fmdev)
+{
+   fmdev-rx.rds.flag = FM_RDS_DISABLE;
+   fmdev-rx.rds.last_blk_idx = 0;
+   fmdev-rx.rds.wr_idx = 0;
+   fmdev-rx.rds.rd_idx = 0;
+
+   if (fmdev-rx.af_mode == FM_RX_RDS_AF_SWITCH_MODE_ON)
+   fmdev-irq_info.mask |= FM_LEV_EVENT;
+}
+
+void fm_rx_reset_station_info(struct fmdev *fmdev)
+{
+   fmdev-rx.stat_info.picode = FM_NO_PI_CODE;
+   fmdev-rx.stat_info.afcache_size = 0;
+   fmdev-rx.stat_info.af_list_max = 0;
+}
+
+u32 fm_rx_set_freq(struct fmdev *fmdev, u32 freq)
+{
+   unsigned long timeleft;
+   u16 payload, curr_frq, frq_index, intr_flag;
+   u32 curr_frq_in_khz;
+   u32 ret, resp_len;
+
+   if (fmdev-curr_fmmode != FM_MODE_RX)
+   return -EPERM;
+
+   if (freq  fmdev-rx.region.bot_freq || freq  
fmdev-rx.region.top_freq) {
+   fmerr(Invalid frequency %d\n, freq);
+   return -EINVAL;
+   }
+
+   /* Set audio enable */
+   payload = FM_RX_AUDIO_ENABLE_I2S_AND_ANALOG;
+
+   ret = fmc_send_cmd(fmdev, AUDIO_ENABLE_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Set hilo to automatic selection */
+   payload = FM_RX_IFFREQ_HILO_AUTOMATIC;
+   ret = fmc_send_cmd(fmdev, HILO_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Calculate frequency index to write */
+   frq_index = (freq - fmdev-rx.region.bot_freq) / FM_FREQ_MUL;
+
+   /* Set frequency index */
+   payload = frq_index;
+   ret = fmc_send_cmd(fmdev, FREQ_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Read flags - just to clear any pending interrupts if we had */
+   ret = fmc_send_cmd(fmdev, FLAG_GET, REG_RD, NULL, 2, NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Enable FR, BL interrupts */
+   intr_flag = fmdev-irq_info.mask;
+   fmdev-irq_info.mask = (FM_FR_EVENT | FM_BL_EVENT);
+   payload = fmdev-irq_info.mask;
+   ret = fmc_send_cmd(fmdev, INT_MASK_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Start tune */
+   payload = FM_TUNER_PRESET_MODE;
+   ret = fmc_send_cmd(fmdev, TUNER_MODE_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   goto exit;
+
+   /* Wait for tune ended interrupt */
+   init_completion(fmdev-maintask_comp);
+   timeleft = wait_for_completion_timeout(fmdev-maintask_comp,
+   FM_DRV_TX_TIMEOUT);
+   if (!timeleft) {
+   fmerr(Timeout(%d sec),didn't get tune ended int\n,
+  jiffies_to_msecs(FM_DRV_TX_TIMEOUT) / 1000);
+   ret = -ETIMEDOUT;
+   goto exit;
+   }
+
+   /* Read freq back to confirm */
+   ret = fmc_send_cmd(fmdev, FREQ_SET, REG_RD, NULL, 2, curr_frq, 
resp_len);
+   if (ret  0)
+   goto exit;
+
+   curr_frq = 

[RFC V9 5/7] drivers:media:radio: wl128x: FM driver TX sources

2011-01-10 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

This has implementation for FM TX functionality.
It communicates with FM V4l2 module and FM common module.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_tx.c |  433 +
 drivers/media/radio/wl128x/fmdrv_tx.h |   37 +++
 2 files changed, 470 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/fmdrv_tx.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_tx.h

diff --git a/drivers/media/radio/wl128x/fmdrv_tx.c 
b/drivers/media/radio/wl128x/fmdrv_tx.c
new file mode 100644
index 000..b66f535
--- /dev/null
+++ b/drivers/media/radio/wl128x/fmdrv_tx.c
@@ -0,0 +1,433 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *  This sub-module of FM driver implements FM TX functionality.
+ *
+ *  Copyright (C) 2011 Texas Instruments
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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/delay.h
+#include fmdrv.h
+#include fmdrv_common.h
+#include fmdrv_tx.h
+
+u32 fm_tx_set_stereo_mono(struct fmdev *fmdev, u16 mode)
+{
+   u16 payload;
+   u32 ret = 0;
+
+   if (fmdev-curr_fmmode != FM_MODE_TX)
+   return -EPERM;
+
+   if (fmdev-tx_data.aud_mode == mode)
+   return ret;
+
+   fmdbg(stereo mode: %d\n, mode);
+
+   /* Set Stereo/Mono mode */
+   payload = (1 - mode);
+   ret = fmc_send_cmd(fmdev, MONO_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   fmdev-tx_data.aud_mode = mode;
+
+   return ret;
+}
+
+static u32 set_rds_text(struct fmdev *fmdev, u8 *rds_text)
+{
+   u16 payload;
+   u32 ret;
+
+   ret = fmc_send_cmd(fmdev, RDS_DATA_SET, REG_WR, rds_text,
+   strlen(rds_text), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Scroll mode */
+   payload = (u16)0x1;
+   ret = fmc_send_cmd(fmdev, DISPLAY_MODE, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   return 0;
+}
+
+static u32 set_rds_data_mode(struct fmdev *fmdev, u8 mode)
+{
+   u16 payload;
+   u32 ret;
+
+   /* Setting unique PI TODO: how unique? */
+   payload = (u16)0xcafe;
+   ret = fmc_send_cmd(fmdev, PI_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Set decoder id */
+   payload = (u16)0xa;
+   ret = fmc_send_cmd(fmdev, DI_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* TODO: RDS_MODE_GET? */
+   return 0;
+}
+
+static u32 set_rds_len(struct fmdev *fmdev, u8 type, u16 len)
+{
+   u16 payload;
+   u32 ret;
+
+   len |= type  8;
+   payload = len;
+   ret = fmc_send_cmd(fmdev, RDS_CONFIG_DATA_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* TODO: LENGTH_GET? */
+   return 0;
+}
+
+u32 fm_tx_set_rds_mode(struct fmdev *fmdev, u8 rds_en_dis)
+{
+   u16 payload;
+   u32 ret;
+   u8 rds_text[] = Zoom2\n;
+
+   if (fmdev-curr_fmmode != FM_MODE_TX)
+   return -EPERM;
+
+   fmdbg(rds_en_dis:%d(E:%d, D:%d)\n, rds_en_dis,
+  FM_RDS_ENABLE, FM_RDS_DISABLE);
+
+   if (rds_en_dis == FM_RDS_ENABLE) {
+   /* Set RDS length */
+   set_rds_len(fmdev, 0, strlen(rds_text));
+
+   /* Set RDS text */
+   set_rds_text(fmdev, rds_text);
+
+   /* Set RDS mode */
+   set_rds_data_mode(fmdev, 0x0);
+   }
+
+   /* Send command to enable RDS */
+   if (rds_en_dis == FM_RDS_ENABLE)
+   payload = 0x01;
+   else
+   payload = 0x00;
+
+   ret = fmc_send_cmd(fmdev, RDS_DATA_ENB, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   if (rds_en_dis == FM_RDS_ENABLE) {
+   /* Set RDS length */
+   set_rds_len(fmdev, 0, strlen(rds_text));
+
+   /* Set RDS text */
+   set_rds_text(fmdev, rds_text);
+   

[RFC V9 6/7] drivers:media:radio: wl128x: Kconfig Makefile for wl128x driver

2011-01-10 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/wl128x/Kconfig  |   17 +
 drivers/media/radio/wl128x/Makefile |6 ++
 2 files changed, 23 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/Kconfig
 create mode 100644 drivers/media/radio/wl128x/Makefile

diff --git a/drivers/media/radio/wl128x/Kconfig 
b/drivers/media/radio/wl128x/Kconfig
new file mode 100644
index 000..749f67b
--- /dev/null
+++ b/drivers/media/radio/wl128x/Kconfig
@@ -0,0 +1,17 @@
+#
+# TI's wl128x FM driver based on TI's ST driver.
+#
+menu Texas Instruments WL128x FM driver (ST based)
+config RADIO_WL128X
+   tristate Texas Instruments WL128x FM Radio
+   depends on VIDEO_V4L2  RFKILL
+   select TI_ST
+   help
+   Choose Y here if you have this FM radio chip.
+
+   In order to control your radio card, you will need to use programs
+   that are compatible with the Video For Linux 2 API.  Information on
+   this API and pointers to v4l2 programs may be found at
+   file:Documentation/video4linux/API.html.
+
+endmenu
diff --git a/drivers/media/radio/wl128x/Makefile 
b/drivers/media/radio/wl128x/Makefile
new file mode 100644
index 000..32a0ead
--- /dev/null
+++ b/drivers/media/radio/wl128x/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for TI's shared transport driver based wl128x
+# FM radio.
+#
+obj-$(CONFIG_RADIO_WL128X) += fm_drv.o
+fm_drv-objs:= fmdrv_common.o fmdrv_rx.o fmdrv_tx.o fmdrv_v4l2.o
-- 
1.5.6.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC V9 1/7] drivers:media:radio: wl128x: fmdrv common header file

2011-01-10 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

These are common headers used in FM submodules (FM V4L2,
FM common, FM Rx,and FM TX).

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/wl128x/fmdrv.h |  242 
 1 files changed, 242 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/fmdrv.h

diff --git a/drivers/media/radio/wl128x/fmdrv.h 
b/drivers/media/radio/wl128x/fmdrv.h
new file mode 100644
index 000..4cb527d
--- /dev/null
+++ b/drivers/media/radio/wl128x/fmdrv.h
@@ -0,0 +1,242 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *
+ *  Common header for all FM driver sub-modules.
+ *
+ *  Copyright (C) 2011 Texas Instruments
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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
+ *
+ */
+
+#ifndef _FM_DRV_H
+#define _FM_DRV_H
+
+#include linux/skbuff.h
+#include linux/interrupt.h
+#include sound/core.h
+#include sound/initval.h
+#include linux/timer.h
+#include linux/version.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-common.h
+#include media/v4l2-ctrls.h
+
+#define FM_DRV_VERSION0.09
+/* Should match with FM_DRV_VERSION */
+#define FM_DRV_RADIO_VERSION  KERNEL_VERSION(0, 0, 1)
+#define FM_DRV_NAME   ti_fmdrv
+#define FM_DRV_CARD_SHORT_NAMETI FM Radio
+#define FM_DRV_CARD_LONG_NAME Texas Instruments FM Radio
+
+/* Flag info */
+#define FM_INTTASK_RUNNING0
+#define FM_INTTASK_SCHEDULE_PENDING   1
+#define FM_FW_DW_INPROGRESS 2
+#define FM_CORE_READY 3
+#define FM_CORE_TRANSPORT_READY   4
+#define FM_AF_SWITCH_INPROGRESS  5
+#define FM_CORE_TX_XMITING   6
+
+#define FM_TUNE_COMPLETE 0x1
+#define FM_BAND_LIMIT0x2
+
+#define FM_DRV_TX_TIMEOUT  (5*HZ)  /* 5 seconds */
+#define FM_DRV_RX_SEEK_TIMEOUT (20*HZ) /* 20 seconds */
+
+#define NO_OF_ENTRIES_IN_ARRAY(array) (sizeof(array) / sizeof(array[0]))
+
+#define fmerr(format, ...) \
+printk(KERN_ERR fmdrv:  format,## __VA_ARGS__)
+#ifdef DEBUG
+#define fmdbg(format, ...) \
+printk(KERN_DEBUG fmdrv:  format,## __VA_ARGS__)
+#else /* DEBUG */
+#define fmdbg(format, ...)
+#endif
+enum {
+   FM_MODE_OFF,
+   FM_MODE_TX,
+   FM_MODE_RX,
+   FM_MODE_ENTRY_MAX
+};
+
+#define FM_RX_RDS_INFO_FIELD_MAX   8   /* 4 Group * 2 Bytes */
+
+/* RX RDS data format */
+struct fm_rdsdata_format {
+   union {
+   struct {
+   u8 buff[FM_RX_RDS_INFO_FIELD_MAX];
+   } groupdatabuff;
+   struct {
+   u16 pidata;
+   u8 blk_b[2];
+   u8 blk_c[2];
+   u8 blk_d[2];
+   } groupgeneral;
+   struct {
+   u16 pidata;
+   u8 blk_b[2];
+   u8 af[2];
+   u8 ps[2];
+   } group0A;
+   struct {
+   u16 pi[2];
+   u8 blk_b[2];
+   u8 ps[2];
+   } group0B;
+   } data;
+};
+
+/* FM region (Europe/US, Japan) info */
+struct region_info {
+   u32 chanl_space;
+   u32 bot_freq;
+   u32 top_freq;
+   u8 fm_band;
+};
+struct fmdev;
+typedef void (*int_handler_prototype) (struct fmdev *);
+
+/* FM Interrupt processing related info */
+struct fm_irq {
+   u8 stage;
+   u16 flag;   /* FM interrupt flag */
+   u16 mask;   /* FM interrupt mask */
+   /* Interrupt process timeout handler */
+   struct timer_list timer;
+   u8 retry;
+   int_handler_prototype *handlers;
+};
+
+/* RDS info */
+struct fm_rds {
+   u8 flag;/* RX RDS on/off status */
+   u8 last_blk_idx;/* Last received RDS block */
+
+   /* RDS buffer */
+   wait_queue_head_t read_queue;
+   u32 buf_size;   /* Size is always multiple of 3 */
+   u32 wr_idx;
+   u32 rd_idx;
+   u8 *buff;
+};
+
+#define FM_RDS_MAX_AF_LIST 25
+
+/*
+ * Current RX channel Alternate Frequency cache.
+ * This info is used to switch to other freq (AF)
+ * when current channel signal strengh is below RSSI threshold.
+ */
+struct tuned_station_info {
+   u16 picode;
+   u32 af_cache[FM_RDS_MAX_AF_LIST];
+   u8 afcache_size;
+  

[RFC V8 6/7] drivers:media:radio: wl128x: Kconfig Makefile for wl128x driver

2010-12-30 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/wl128x/Kconfig  |   17 +
 drivers/media/radio/wl128x/Makefile |6 ++
 2 files changed, 23 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/Kconfig
 create mode 100644 drivers/media/radio/wl128x/Makefile

diff --git a/drivers/media/radio/wl128x/Kconfig 
b/drivers/media/radio/wl128x/Kconfig
new file mode 100644
index 000..749f67b
--- /dev/null
+++ b/drivers/media/radio/wl128x/Kconfig
@@ -0,0 +1,17 @@
+#
+# TI's wl128x FM driver based on TI's ST driver.
+#
+menu Texas Instruments WL128x FM driver (ST based)
+config RADIO_WL128X
+   tristate Texas Instruments WL128x FM Radio
+   depends on VIDEO_V4L2  RFKILL
+   select TI_ST
+   help
+   Choose Y here if you have this FM radio chip.
+
+   In order to control your radio card, you will need to use programs
+   that are compatible with the Video For Linux 2 API.  Information on
+   this API and pointers to v4l2 programs may be found at
+   file:Documentation/video4linux/API.html.
+
+endmenu
diff --git a/drivers/media/radio/wl128x/Makefile 
b/drivers/media/radio/wl128x/Makefile
new file mode 100644
index 000..32a0ead
--- /dev/null
+++ b/drivers/media/radio/wl128x/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for TI's shared transport driver based wl128x
+# FM radio.
+#
+obj-$(CONFIG_RADIO_WL128X) += fm_drv.o
+fm_drv-objs:= fmdrv_common.o fmdrv_rx.o fmdrv_tx.o fmdrv_v4l2.o
-- 
1.5.6.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC V8 2/7] drivers:media:radio: wl128x: fmdrv_v4l2 sources

2010-12-30 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

This module interfaces V4L2 subsystem and FM common module.
It registers itself with V4L2 as Radio module.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_v4l2.c |  593 +++
 drivers/media/radio/wl128x/fmdrv_v4l2.h |   33 ++
 2 files changed, 626 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/fmdrv_v4l2.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_v4l2.h

diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c 
b/drivers/media/radio/wl128x/fmdrv_v4l2.c
new file mode 100644
index 000..9154c9d
--- /dev/null
+++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c
@@ -0,0 +1,593 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *  This file provides interfaces to V4L2 subsystem.
+ *
+ *  This module registers with V4L2 subsystem as Radio
+ *  data system interface (/dev/radio). During the registration,
+ *  it will expose two set of function pointers.
+ *
+ *1) File operation related API (open, close, read, write, poll...etc).
+ *2) Set of V4L2 IOCTL complaint API.
+ *
+ *  Copyright (C) 2010 Texas Instruments
+ *  Author: Raja Mani raja_m...@ti.com
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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 fmdrv.h
+#include fmdrv_v4l2.h
+#include fmdrv_common.h
+#include fmdrv_rx.h
+#include fmdrv_tx.h
+
+static struct video_device *gradio_dev;
+static unsigned char radio_disconnected;
+
+/* -- V4L2 RADIO (/dev/radioX) device file operation interfaces --- */
+
+/* Read RX RDS data */
+static ssize_t fm_v4l2_fops_read(struct file *file, char __user * buf,
+   size_t count, loff_t *ppos)
+{
+   unsigned char rds_mode;
+   int ret;
+   struct fmdrv_ops *fmdev;
+
+   fmdev = video_drvdata(file);
+
+   if (!radio_disconnected) {
+   pr_err((fmdrv): FM device is already disconnected\n);
+   return -EIO;
+   }
+
+   /* Turn on RDS mode , if it is disabled */
+   ret = fm_rx_get_rds_mode(fmdev, rds_mode);
+   if (ret  0) {
+   pr_err((fmdrv): Unable to read current rds mode\n);
+   return ret;
+   }
+
+   if (rds_mode == FM_RDS_DISABLE) {
+   ret = fmc_set_rds_mode(fmdev, FM_RDS_ENABLE);
+   if (ret  0) {
+   pr_err((fmdrv): Failed to enable rds mode\n);
+   return ret;
+   }
+   }
+
+   /* Copy RDS data from internal buffer to user buffer */
+   ret = fmc_transfer_rds_from_internal_buff(fmdev, file, buf, count);
+
+   return ret;
+}
+
+/* Write TX RDS data */
+static ssize_t fm_v4l2_fops_write(struct file *file, const char __user * buf,
+   size_t count, loff_t *ppos)
+{
+   struct tx_rds rds;
+   int ret;
+   struct fmdrv_ops *fmdev;
+
+   ret = copy_from_user(rds, buf, sizeof(rds));
+   pr_debug((fmdrv): (%d)type: %d, text %s, af %d\n,
+  ret, rds.text_type, rds.text, rds.af_freq);
+
+   fmdev = video_drvdata(file);
+   fm_tx_set_radio_text(fmdev, rds.text, rds.text_type);
+   fm_tx_set_af(fmdev, rds.af_freq);
+
+   return 0;
+}
+
+static unsigned int fm_v4l2_fops_poll(struct file *file,
+ struct poll_table_struct *pts)
+{
+   int ret;
+   struct fmdrv_ops *fmdev;
+
+   fmdev = video_drvdata(file);
+   ret = fmc_is_rds_data_available(fmdev, file, pts);
+   if (ret  0)
+   return POLLIN | POLLRDNORM;
+
+   return 0;
+}
+
+/*
+ * Handle open request for /dev/radioX device.
+ * Start with FM RX mode as default.
+ */
+static int fm_v4l2_fops_open(struct file *file)
+{
+   int ret;
+   struct fmdrv_ops *fmdev = NULL;
+
+   /* Don't allow multiple open */
+   if (radio_disconnected) {
+   pr_err((fmdrv): FM device is already opened\n);
+   return -EBUSY;
+   }
+
+   fmdev = video_drvdata(file);
+
+   ret = fmc_prepare(fmdev);
+   if (ret  0) {
+   pr_err((fmdrv): Unable to prepare FM CORE\n);
+   return ret;
+   }
+
+   pr_debug((fmdrv): Load FM RX firmware..\n);
+
+   ret = fmc_set_mode(fmdev, FM_MODE_RX);
+   if (ret  0) {
+   

[RFC V8 7/7] drivers:media:radio: Update Kconfig and Makefile for wl128x FM driver.

2010-12-30 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/Kconfig  |3 +++
 drivers/media/radio/Makefile |1 +
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 83567b8..4529bc7 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -452,4 +452,7 @@ config RADIO_TIMBERDALE
  found behind the Timberdale FPGA on the Russellville board.
  Enabling this driver will automatically select the DSP and tuner.
 
+# TI's ST based wl128x FM radio
+source drivers/media/radio/wl128x/Kconfig
+
 endif # RADIO_ADAPTERS
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
index f615583..b71f448 100644
--- a/drivers/media/radio/Makefile
+++ b/drivers/media/radio/Makefile
@@ -26,5 +26,6 @@ obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o
 obj-$(CONFIG_RADIO_SAA7706H) += saa7706h.o
 obj-$(CONFIG_RADIO_TEF6862) += tef6862.o
 obj-$(CONFIG_RADIO_TIMBERDALE) += radio-timb.o
+obj-$(CONFIG_RADIO_WL128X) += wl128x/
 
 EXTRA_CFLAGS += -Isound
-- 
1.5.6.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC V8 1/7] drivers:media:radio: wl128x: fmdrv common header file

2010-12-30 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

These are common headers used in FM submodules (FM V4L2,
FM common, FM Rx,and FM TX).

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/wl128x/fmdrv.h |  248 
 1 files changed, 248 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/fmdrv.h

diff --git a/drivers/media/radio/wl128x/fmdrv.h 
b/drivers/media/radio/wl128x/fmdrv.h
new file mode 100644
index 000..3d73f76
--- /dev/null
+++ b/drivers/media/radio/wl128x/fmdrv.h
@@ -0,0 +1,248 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *
+ *  Common header for all FM driver sub-modules.
+ *
+ *  Copyright (C) 2009 Texas Instruments
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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
+ *
+ */
+
+#ifndef _FM_DRV_H
+#define _FM_DRV_H
+
+#include linux/skbuff.h
+#include linux/interrupt.h
+#include sound/core.h
+#include sound/initval.h
+#include linux/timer.h
+#include linux/version.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-common.h
+#include media/v4l2-ctrls.h
+
+#define FM_DRV_VERSION0.01
+/* Should match with FM_DRV_VERSION */
+#define FM_DRV_RADIO_VERSION  KERNEL_VERSION(0, 0, 1)
+#define FM_DRV_NAME   ti_fmdrv
+#define FM_DRV_CARD_SHORT_NAMETI FM Radio
+#define FM_DRV_CARD_LONG_NAME Texas Instruments FM Radio
+
+/* Flag info */
+#define FM_INTTASK_RUNNING0
+#define FM_INTTASK_SCHEDULE_PENDING   1
+#define FM_FIRMWARE_DW_INPROGRESS 2
+#define FM_CORE_READY 3
+#define FM_CORE_TRANSPORT_READY   4
+#define FM_AF_SWITCH_INPROGRESS  5
+#define FM_CORE_TX_XMITING   6
+
+#define FM_TUNE_COMPLETE 0x1
+#define FM_BAND_LIMIT0x2
+
+#define FM_DRV_TX_TIMEOUT  (5*HZ)  /* 5 seconds */
+#define FM_DRV_RX_SEEK_TIMEOUT (20*HZ) /* 20 seconds */
+
+#define NO_OF_ENTRIES_IN_ARRAY(array) (sizeof(array) / sizeof(array[0]))
+
+enum {
+   FM_MODE_OFF,
+   FM_MODE_TX,
+   FM_MODE_RX,
+   FM_MODE_ENTRY_MAX
+};
+
+#define FM_RX_RDS_INFO_FIELD_MAX   8   /* 4 Group * 2 Bytes */
+
+/*
+ * define private CIDs for V4L2
+ */
+#define V4L2_CID_CHANNEL_SPACING (V4L2_CID_PRIVATE_BASE + 0)
+
+/* RX RDS data format */
+struct fm_rdsdata_format {
+   union {
+   struct {
+   unsigned char rdsbuff[FM_RX_RDS_INFO_FIELD_MAX];
+   } groupdatabuff;
+   struct {
+   unsigned short pidata;
+   unsigned char block_b_byte1;
+   unsigned char block_b_byte2;
+   unsigned char block_c_byte1;
+   unsigned char block_c_byte2;
+   unsigned char block_d_byte1;
+   unsigned char block_d_byte2;
+   } groupgeneral;
+   struct {
+   unsigned short pidata;
+   unsigned char block_b_byte1;
+   unsigned char block_b_byte2;
+   unsigned char firstaf;
+   unsigned char secondaf;
+   unsigned char firstpsbyte;
+   unsigned char secondpsbyte;
+   } group0A;
+
+   struct {
+   unsigned short pidata;
+   unsigned char block_b_byte1;
+   unsigned char block_b_byte2;
+   unsigned short pidata2;
+   unsigned char firstpsbyte;
+   unsigned char secondpsbyte;
+   } group0B;
+   } rdsdata;
+};
+
+/* FM region (Europe/US, Japan) info */
+struct region_info {
+   unsigned int channel_spacing;
+   unsigned int bottom_frequency;
+   unsigned int top_frequency;
+   unsigned char region_index;
+};
+
+typedef void (*int_handler_prototype) (void *);
+
+/* FM Interrupt processing related info */
+struct fm_irq {
+   unsigned char stage_index;
+   unsigned short flag;/* FM interrupt flag */
+   unsigned short mask;/* FM interrupt mask */
+   /* Interrupt process timeout handler */
+   struct timer_list int_timeout_timer;
+   unsigned char irq_service_timeout_retry;
+   int_handler_prototype *fm_int_handlers;
+};
+
+/* RDS info */
+struct fm_rds {
+   

[RFC V8 4/7] drivers:media:radio: wl128x: FM driver RX sources

2010-12-30 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

This has implementation for FM RX functionality.
It communicates with FM V4l2 module and FM common module

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_rx.c |  904 +
 drivers/media/radio/wl128x/fmdrv_rx.h |   59 +++
 2 files changed, 963 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/fmdrv_rx.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_rx.h

diff --git a/drivers/media/radio/wl128x/fmdrv_rx.c 
b/drivers/media/radio/wl128x/fmdrv_rx.c
new file mode 100644
index 000..c0a29e7
--- /dev/null
+++ b/drivers/media/radio/wl128x/fmdrv_rx.c
@@ -0,0 +1,904 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *  This sub-module of FM driver implements FM RX functionality.
+ *
+ *  Copyright (C) 2010 Texas Instruments
+ *  Author: Raja Mani raja_m...@ti.com
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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 fmdrv.h
+#include fmdrv_common.h
+#include fmdrv_rx.h
+
+void fm_rx_reset_rds_cache(struct fmdrv_ops *fmdev)
+{
+   fmdev-rx.rds.flag = FM_RDS_DISABLE;
+   fmdev-rx.rds.last_block_index = 0;
+   fmdev-rx.rds.wr_index = 0;
+   fmdev-rx.rds.rd_index = 0;
+
+   if (fmdev-rx.af_mode == FM_RX_RDS_AF_SWITCH_MODE_ON)
+   fmdev-irq_info.mask |= FM_LEV_EVENT;
+}
+
+void fm_rx_reset_curr_station_info(struct fmdrv_ops *fmdev)
+{
+   fmdev-rx.cur_station_info.picode = FM_NO_PI_CODE;
+   fmdev-rx.cur_station_info.no_of_items_in_afcache = 0;
+   fmdev-rx.cur_station_info.af_list_max = 0;
+}
+
+int fm_rx_set_frequency(struct fmdrv_ops *fmdev, unsigned int freq_to_set)
+{
+   unsigned long timeleft;
+   unsigned short payload, curr_frq, frq_index, intr_flag;
+   unsigned int curr_frq_in_khz;
+   int ret, resp_len;
+
+   if (fmdev-curr_fmmode != FM_MODE_RX)
+   return -EPERM;
+
+   if (freq_to_set  fmdev-rx.region.bottom_frequency ||
+   freq_to_set  fmdev-rx.region.top_frequency) {
+   pr_err((fmdrv): Invalid frequency %d\n, freq_to_set);
+   return -EINVAL;
+   }
+
+   /* Set audio enable */
+   payload = FM_RX_FM_AUDIO_ENABLE_I2S_AND_ANALOG;
+
+   ret = fmc_send_cmd(fmdev, AUDIO_ENABLE_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Set hilo to automatic selection */
+   payload = FM_RX_IFFREQ_HILO_AUTOMATIC;
+   ret = fmc_send_cmd(fmdev, HILO_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Calculate frequency index to write */
+   frq_index = (freq_to_set - fmdev-rx.region.bottom_frequency) /
+   FM_FREQ_MUL;
+
+   /* Set frequency index */
+   payload = frq_index;
+   ret = fmc_send_cmd(fmdev, FREQ_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Read flags - just to clear any pending interrupts if we had */
+   ret = fmc_send_cmd(fmdev, FLAG_GET, REG_RD, NULL, 2,
+   NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Enable FR, BL interrupts */
+   intr_flag = fmdev-irq_info.mask;
+   fmdev-irq_info.mask = (FM_FR_EVENT | FM_BL_EVENT);
+   payload = fmdev-irq_info.mask;
+   ret = fmc_send_cmd(fmdev, INT_MASK_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Start tune */
+   payload = FM_TUNER_PRESET_MODE;
+   ret = fmc_send_cmd(fmdev, TUNER_MODE_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Wait for tune ended interrupt */
+   init_completion(fmdev-maintask_completion);
+   timeleft = wait_for_completion_timeout(fmdev-maintask_completion,
+  FM_DRV_TX_TIMEOUT);
+   if (!timeleft) {
+   pr_err((fmdrv): Timeout(%d sec),didn't get tune ended int\n,
+  jiffies_to_msecs(FM_DRV_TX_TIMEOUT) / 1000);
+   return -ETIMEDOUT;
+   }

[RFC V8 5/7] drivers:media:radio: wl128x: FM driver TX sources

2010-12-30 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

This has implementation for FM TX functionality.
It communicates with FM V4l2 module and FM common module.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_tx.c |  438 +
 drivers/media/radio/wl128x/fmdrv_tx.h |   37 +++
 2 files changed, 475 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/fmdrv_tx.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_tx.h

diff --git a/drivers/media/radio/wl128x/fmdrv_tx.c 
b/drivers/media/radio/wl128x/fmdrv_tx.c
new file mode 100644
index 000..ca8769d
--- /dev/null
+++ b/drivers/media/radio/wl128x/fmdrv_tx.c
@@ -0,0 +1,438 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *  This sub-module of FM driver implements FM TX functionality.
+ *
+ *  Copyright (C) 2010 Texas Instruments
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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/delay.h
+#include fmdrv.h
+#include fmdrv_common.h
+#include fmdrv_tx.h
+
+int fm_tx_set_stereo_mono(struct fmdrv_ops *fmdev, unsigned short mode)
+{
+   unsigned short payload;
+   int ret = 0;
+
+   if (fmdev-curr_fmmode != FM_MODE_TX)
+   return -EPERM;
+
+   if (fmdev-tx_data.aud_mode == mode)
+   return ret;
+
+   pr_debug(stereo mode: %d\n, mode);
+
+   /* Set Stereo/Mono mode */
+   payload = (1 - mode);
+   ret = fmc_send_cmd(fmdev, MONO_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   fmdev-tx_data.aud_mode = mode;
+
+   return ret;
+}
+
+static int __set_rds_text(struct fmdrv_ops *fmdev, unsigned char *rds_text)
+{
+   unsigned short payload;
+   int ret;
+
+   ret = fmc_send_cmd(fmdev, RDS_DATA_SET, REG_WR, rds_text,
+   strlen(rds_text), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Scroll mode */
+   payload = (unsigned short)0x1;
+   ret = fmc_send_cmd(fmdev, DISPLAY_MODE, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   return 0;
+}
+
+static int __set_rds_data_mode(struct fmdrv_ops *fmdev, unsigned char mode)
+{
+   unsigned short payload;
+   int ret;
+
+   /* Setting unique PI TODO: how unique? */
+   payload = (unsigned short)0xcafe;
+   ret = fmc_send_cmd(fmdev, PI_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Set decoder id */
+   payload = (unsigned short)0xa;
+   ret = fmc_send_cmd(fmdev, DI_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* TODO: RDS_MODE_GET? */
+   return 0;
+}
+
+static int __set_rds_len(struct fmdrv_ops *fmdev, unsigned char type,
+   unsigned short len)
+{
+   unsigned short payload;
+   int ret;
+
+   len |= type  8;
+   payload = len;
+   ret = fmc_send_cmd(fmdev, RDS_CONFIG_DATA_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* TODO: LENGTH_GET? */
+   return 0;
+}
+
+int fm_tx_set_rds_mode(struct fmdrv_ops *fmdev, unsigned char rds_en_dis)
+{
+   unsigned short payload;
+   int ret;
+   unsigned char rds_text[] = Zoom2\n;
+
+   if (fmdev-curr_fmmode != FM_MODE_TX)
+   return -EPERM;
+
+   pr_debug(rds_en_dis:%d(E:%d, D:%d)\n, rds_en_dis,
+  FM_RDS_ENABLE, FM_RDS_DISABLE);
+
+   if (rds_en_dis == FM_RDS_ENABLE) {
+   /* Set RDS length */
+   __set_rds_len(fmdev, 0, strlen(rds_text));
+
+   /* Set RDS text */
+   __set_rds_text(fmdev, rds_text);
+
+   /* Set RDS mode */
+   __set_rds_data_mode(fmdev, 0x0);
+   }
+
+   /* Send command to enable RDS */
+   if (rds_en_dis == FM_RDS_ENABLE)
+   payload = 0x01;
+   else
+   payload = 0x00;
+
+   ret = fmc_send_cmd(fmdev, RDS_DATA_ENB, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return 

[RFC V8 0/7] FM V4L2 drivers for WL128x

2010-12-30 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Mauro and the list,

This is the v8 version of the TI WL128x FM V4L2 drivers patchset.
This introduces wl128x folder under the drivers/media/radio which cater
to FM core on Texas Instrument's WL128x (also compatible with WL127x)
WiLink chipsets.
WL128x's FM can work in either Rx or Tx mode, and V4L2 interfaces are
provided for both.

** patch description **

Texas Instrument's WL128x chipset packs BT, FM, GPS and WLAN in a single
die with BT, FM and GPS being interfaced over a single UART.
This driver works on top of the shared transport line discipline driver.
This driver can also be made use for the WL127x version of the chip which packs
BT, FM and WLAN only.

Comments on the last version of the patches have been taken care,
such as,
- Using .unlocked_ioctl instead of .ioctl in fmdrv_v4l2.c

Thanks  Regards,
Manjunatha Halli

Manjunatha Halli (7):
  drivers:media:radio: wl128x: fmdrv common header file
  drivers:media:radio: wl128x: fmdrv_v4l2 sources
  drivers:media:radio: wl128x: fmdrv_common sources
  drivers:media:radio: wl128x: FM driver RX sources
  drivers:media:radio: wl128x: FM driver TX sources
  drivers:media:radio: wl128x: Kconfig  Makefile for wl128x driver
  drivers:media:radio: Update Kconfig and Makefile for wl128x FM
driver.

 drivers/media/radio/Kconfig   |3 +
 drivers/media/radio/Makefile  |1 +
 drivers/media/radio/wl128x/Kconfig|   17 +
 drivers/media/radio/wl128x/Makefile   |6 +
 drivers/media/radio/wl128x/fmdrv.h|  248 
 drivers/media/radio/wl128x/fmdrv_common.c | 1970 +
 drivers/media/radio/wl128x/fmdrv_common.h |  402 ++
 drivers/media/radio/wl128x/fmdrv_rx.c |  904 +
 drivers/media/radio/wl128x/fmdrv_rx.h |   59 +
 drivers/media/radio/wl128x/fmdrv_tx.c |  438 +++
 drivers/media/radio/wl128x/fmdrv_tx.h |   37 +
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |  593 +
 drivers/media/radio/wl128x/fmdrv_v4l2.h   |   33 +
 13 files changed, 4711 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/Kconfig
 create mode 100644 drivers/media/radio/wl128x/Makefile
 create mode 100644 drivers/media/radio/wl128x/fmdrv.h
 create mode 100644 drivers/media/radio/wl128x/fmdrv_common.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_common.h
 create mode 100644 drivers/media/radio/wl128x/fmdrv_rx.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_rx.h
 create mode 100644 drivers/media/radio/wl128x/fmdrv_tx.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_tx.h
 create mode 100644 drivers/media/radio/wl128x/fmdrv_v4l2.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_v4l2.h

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 0/7] FM V4L2 drivers for WL128x

2010-12-17 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Mauro and the list,

This is the v7 version of the TI WL128x FM V4L2 drivers patchset.
This introduces wl128x folder under the drivers/media/radio which cater
to FM core on Texas Instrument's WL128x (also compatible with WL127x)
WiLink chipsets.
WL128x's FM can work in either Rx or Tx mode, and V4L2 interfaces are
provided for both.

** patch description **

Texas Instrument's WL128x chipset packs BT, FM, GPS and WLAN in a single
die with BT, FM and GPS being interfaced over a single UART.
This driver works on top of the shared transport line discipline driver.
This driver can also be made use for the WL127x version of the chip which packs
BT, FM and WLAN only.

Comments on the last version of the patches have been taken care,
such as,
- Now using the v4l2 control framework to support all the v4l2 controls.
- re-arranged the error handling in IRQ handlers.

Thanks  Regards,
Manjunatha Halli

Manjunatha Halli (7):
  drivers:media:radio: wl128x: fmdrv common header file
  drivers:media:radio: wl128x: fmdrv_v4l2 sources
  drivers:media:radio: wl128x: fmdrv_common sources
  drivers:media:radio: wl128x: FM driver RX sources
  drivers:media:radio: wl128x: FM driver TX sources
  drivers:media:radio: wl128x: Kconfig  Makefile added for wl128x
driver
  drivers:media:radio: Update Kconfig and Makefile for supporting
wl128x

 drivers/media/radio/Kconfig   |3 +
 drivers/media/radio/Makefile  |1 +
 drivers/media/radio/wl128x/Kconfig|   17 +
 drivers/media/radio/wl128x/Makefile   |6 +
 drivers/media/radio/wl128x/fmdrv.h|  245 
 drivers/media/radio/wl128x/fmdrv_common.c | 1970 +
 drivers/media/radio/wl128x/fmdrv_common.h |  402 ++
 drivers/media/radio/wl128x/fmdrv_rx.c |  904 +
 drivers/media/radio/wl128x/fmdrv_rx.h |   59 +
 drivers/media/radio/wl128x/fmdrv_tx.c |  438 +++
 drivers/media/radio/wl128x/fmdrv_tx.h |   37 +
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |  588 +
 drivers/media/radio/wl128x/fmdrv_v4l2.h   |   33 +
 13 files changed, 4703 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/Kconfig
 create mode 100644 drivers/media/radio/wl128x/Makefile
 create mode 100644 drivers/media/radio/wl128x/fmdrv.h
 create mode 100644 drivers/media/radio/wl128x/fmdrv_common.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_common.h
 create mode 100644 drivers/media/radio/wl128x/fmdrv_rx.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_rx.h
 create mode 100644 drivers/media/radio/wl128x/fmdrv_tx.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_tx.h
 create mode 100644 drivers/media/radio/wl128x/fmdrv_v4l2.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_v4l2.h

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 7/7] drivers:media:radio: Update Kconfig and Makefile for supporting wl128x

2010-12-17 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/Kconfig  |3 +++
 drivers/media/radio/Makefile |1 +
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 83567b8..4529bc7 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -452,4 +452,7 @@ config RADIO_TIMBERDALE
  found behind the Timberdale FPGA on the Russellville board.
  Enabling this driver will automatically select the DSP and tuner.
 
+# TI's ST based wl128x FM radio
+source drivers/media/radio/wl128x/Kconfig
+
 endif # RADIO_ADAPTERS
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
index f615583..b71f448 100644
--- a/drivers/media/radio/Makefile
+++ b/drivers/media/radio/Makefile
@@ -26,5 +26,6 @@ obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o
 obj-$(CONFIG_RADIO_SAA7706H) += saa7706h.o
 obj-$(CONFIG_RADIO_TEF6862) += tef6862.o
 obj-$(CONFIG_RADIO_TIMBERDALE) += radio-timb.o
+obj-$(CONFIG_RADIO_WL128X) += wl128x/
 
 EXTRA_CFLAGS += -Isound
-- 
1.5.6.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 4/7] drivers:media:radio: wl128x: FM driver RX sources

2010-12-17 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

This has implementation for FM RX functionality.
It communicates with FM V4l2 module and FM common module.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_rx.c |  904 +
 drivers/media/radio/wl128x/fmdrv_rx.h |   59 +++
 2 files changed, 963 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/fmdrv_rx.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_rx.h

diff --git a/drivers/media/radio/wl128x/fmdrv_rx.c 
b/drivers/media/radio/wl128x/fmdrv_rx.c
new file mode 100644
index 000..c0a29e7
--- /dev/null
+++ b/drivers/media/radio/wl128x/fmdrv_rx.c
@@ -0,0 +1,904 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *  This sub-module of FM driver implements FM RX functionality.
+ *
+ *  Copyright (C) 2010 Texas Instruments
+ *  Author: Raja Mani raja_m...@ti.com
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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 fmdrv.h
+#include fmdrv_common.h
+#include fmdrv_rx.h
+
+void fm_rx_reset_rds_cache(struct fmdrv_ops *fmdev)
+{
+   fmdev-rx.rds.flag = FM_RDS_DISABLE;
+   fmdev-rx.rds.last_block_index = 0;
+   fmdev-rx.rds.wr_index = 0;
+   fmdev-rx.rds.rd_index = 0;
+
+   if (fmdev-rx.af_mode == FM_RX_RDS_AF_SWITCH_MODE_ON)
+   fmdev-irq_info.mask |= FM_LEV_EVENT;
+}
+
+void fm_rx_reset_curr_station_info(struct fmdrv_ops *fmdev)
+{
+   fmdev-rx.cur_station_info.picode = FM_NO_PI_CODE;
+   fmdev-rx.cur_station_info.no_of_items_in_afcache = 0;
+   fmdev-rx.cur_station_info.af_list_max = 0;
+}
+
+int fm_rx_set_frequency(struct fmdrv_ops *fmdev, unsigned int freq_to_set)
+{
+   unsigned long timeleft;
+   unsigned short payload, curr_frq, frq_index, intr_flag;
+   unsigned int curr_frq_in_khz;
+   int ret, resp_len;
+
+   if (fmdev-curr_fmmode != FM_MODE_RX)
+   return -EPERM;
+
+   if (freq_to_set  fmdev-rx.region.bottom_frequency ||
+   freq_to_set  fmdev-rx.region.top_frequency) {
+   pr_err((fmdrv): Invalid frequency %d\n, freq_to_set);
+   return -EINVAL;
+   }
+
+   /* Set audio enable */
+   payload = FM_RX_FM_AUDIO_ENABLE_I2S_AND_ANALOG;
+
+   ret = fmc_send_cmd(fmdev, AUDIO_ENABLE_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Set hilo to automatic selection */
+   payload = FM_RX_IFFREQ_HILO_AUTOMATIC;
+   ret = fmc_send_cmd(fmdev, HILO_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Calculate frequency index to write */
+   frq_index = (freq_to_set - fmdev-rx.region.bottom_frequency) /
+   FM_FREQ_MUL;
+
+   /* Set frequency index */
+   payload = frq_index;
+   ret = fmc_send_cmd(fmdev, FREQ_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Read flags - just to clear any pending interrupts if we had */
+   ret = fmc_send_cmd(fmdev, FLAG_GET, REG_RD, NULL, 2,
+   NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Enable FR, BL interrupts */
+   intr_flag = fmdev-irq_info.mask;
+   fmdev-irq_info.mask = (FM_FR_EVENT | FM_BL_EVENT);
+   payload = fmdev-irq_info.mask;
+   ret = fmc_send_cmd(fmdev, INT_MASK_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Start tune */
+   payload = FM_TUNER_PRESET_MODE;
+   ret = fmc_send_cmd(fmdev, TUNER_MODE_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Wait for tune ended interrupt */
+   init_completion(fmdev-maintask_completion);
+   timeleft = wait_for_completion_timeout(fmdev-maintask_completion,
+  FM_DRV_TX_TIMEOUT);
+   if (!timeleft) {
+   pr_err((fmdrv): Timeout(%d sec),didn't get tune ended int\n,
+  jiffies_to_msecs(FM_DRV_TX_TIMEOUT) / 1000);
+   return -ETIMEDOUT;
+   

[PATCH v7 5/7] drivers:media:radio: wl128x: FM driver TX sources

2010-12-17 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

This has implementation for FM TX functionality.
It communicates with FM V4l2 module and FM common module.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_tx.c |  438 +
 drivers/media/radio/wl128x/fmdrv_tx.h |   37 +++
 2 files changed, 475 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/fmdrv_tx.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_tx.h

diff --git a/drivers/media/radio/wl128x/fmdrv_tx.c 
b/drivers/media/radio/wl128x/fmdrv_tx.c
new file mode 100644
index 000..ca8769d
--- /dev/null
+++ b/drivers/media/radio/wl128x/fmdrv_tx.c
@@ -0,0 +1,438 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *  This sub-module of FM driver implements FM TX functionality.
+ *
+ *  Copyright (C) 2010 Texas Instruments
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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/delay.h
+#include fmdrv.h
+#include fmdrv_common.h
+#include fmdrv_tx.h
+
+int fm_tx_set_stereo_mono(struct fmdrv_ops *fmdev, unsigned short mode)
+{
+   unsigned short payload;
+   int ret = 0;
+
+   if (fmdev-curr_fmmode != FM_MODE_TX)
+   return -EPERM;
+
+   if (fmdev-tx_data.aud_mode == mode)
+   return ret;
+
+   pr_debug(stereo mode: %d\n, mode);
+
+   /* Set Stereo/Mono mode */
+   payload = (1 - mode);
+   ret = fmc_send_cmd(fmdev, MONO_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   fmdev-tx_data.aud_mode = mode;
+
+   return ret;
+}
+
+static int __set_rds_text(struct fmdrv_ops *fmdev, unsigned char *rds_text)
+{
+   unsigned short payload;
+   int ret;
+
+   ret = fmc_send_cmd(fmdev, RDS_DATA_SET, REG_WR, rds_text,
+   strlen(rds_text), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Scroll mode */
+   payload = (unsigned short)0x1;
+   ret = fmc_send_cmd(fmdev, DISPLAY_MODE, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   return 0;
+}
+
+static int __set_rds_data_mode(struct fmdrv_ops *fmdev, unsigned char mode)
+{
+   unsigned short payload;
+   int ret;
+
+   /* Setting unique PI TODO: how unique? */
+   payload = (unsigned short)0xcafe;
+   ret = fmc_send_cmd(fmdev, PI_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Set decoder id */
+   payload = (unsigned short)0xa;
+   ret = fmc_send_cmd(fmdev, DI_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* TODO: RDS_MODE_GET? */
+   return 0;
+}
+
+static int __set_rds_len(struct fmdrv_ops *fmdev, unsigned char type,
+   unsigned short len)
+{
+   unsigned short payload;
+   int ret;
+
+   len |= type  8;
+   payload = len;
+   ret = fmc_send_cmd(fmdev, RDS_CONFIG_DATA_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* TODO: LENGTH_GET? */
+   return 0;
+}
+
+int fm_tx_set_rds_mode(struct fmdrv_ops *fmdev, unsigned char rds_en_dis)
+{
+   unsigned short payload;
+   int ret;
+   unsigned char rds_text[] = Zoom2\n;
+
+   if (fmdev-curr_fmmode != FM_MODE_TX)
+   return -EPERM;
+
+   pr_debug(rds_en_dis:%d(E:%d, D:%d)\n, rds_en_dis,
+  FM_RDS_ENABLE, FM_RDS_DISABLE);
+
+   if (rds_en_dis == FM_RDS_ENABLE) {
+   /* Set RDS length */
+   __set_rds_len(fmdev, 0, strlen(rds_text));
+
+   /* Set RDS text */
+   __set_rds_text(fmdev, rds_text);
+
+   /* Set RDS mode */
+   __set_rds_data_mode(fmdev, 0x0);
+   }
+
+   /* Send command to enable RDS */
+   if (rds_en_dis == FM_RDS_ENABLE)
+   payload = 0x01;
+   else
+   payload = 0x00;
+
+   ret = fmc_send_cmd(fmdev, RDS_DATA_ENB, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return 

[PATCH v7 1/7] drivers:media:radio: wl128x: fmdrv common header file

2010-12-17 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

These are common headers used in FM submodules (FM V4L2,
FM common, FM Rx,and FM TX).

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/wl128x/fmdrv.h |  245 
 1 files changed, 245 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/fmdrv.h

diff --git a/drivers/media/radio/wl128x/fmdrv.h 
b/drivers/media/radio/wl128x/fmdrv.h
new file mode 100644
index 000..96106b1
--- /dev/null
+++ b/drivers/media/radio/wl128x/fmdrv.h
@@ -0,0 +1,245 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *
+ *  Common header for all FM driver sub-modules.
+ *
+ *  Copyright (C) 2009 Texas Instruments
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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
+ *
+ */
+
+#ifndef _FM_DRV_H
+#define _FM_DRV_H
+
+#include linux/skbuff.h
+#include linux/interrupt.h
+#include sound/core.h
+#include sound/initval.h
+#include linux/timer.h
+#include linux/version.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-common.h
+#include media/v4l2-ctrls.h
+
+#define FM_DRV_VERSION0.01
+/* Should match with FM_DRV_VERSION */
+#define FM_DRV_RADIO_VERSION  KERNEL_VERSION(0, 0, 1)
+#define FM_DRV_NAME   ti_fmdrv
+#define FM_DRV_CARD_SHORT_NAMETI FM Radio
+#define FM_DRV_CARD_LONG_NAME Texas Instruments FM Radio
+
+/* Flag info */
+#define FM_INTTASK_RUNNING0
+#define FM_INTTASK_SCHEDULE_PENDING   1
+#define FM_FIRMWARE_DW_INPROGRESS 2
+#define FM_CORE_READY 3
+#define FM_CORE_TRANSPORT_READY   4
+#define FM_AF_SWITCH_INPROGRESS  5
+#define FM_CORE_TX_XMITING   6
+
+#define FM_TUNE_COMPLETE 0x1
+#define FM_BAND_LIMIT0x2
+
+#define FM_DRV_TX_TIMEOUT  (5*HZ)  /* 5 seconds */
+#define FM_DRV_RX_SEEK_TIMEOUT (20*HZ) /* 20 seconds */
+
+#define NO_OF_ENTRIES_IN_ARRAY(array) (sizeof(array) / sizeof(array[0]))
+
+enum {
+   FM_MODE_OFF,
+   FM_MODE_TX,
+   FM_MODE_RX,
+   FM_MODE_ENTRY_MAX
+};
+
+#define FM_RX_RDS_INFO_FIELD_MAX   8   /* 4 Group * 2 Bytes */
+
+/*
+ * define private CIDs for V4L2
+ */
+#define V4L2_CID_CHANNEL_SPACING (V4L2_CID_PRIVATE_BASE + 0)
+
+/* RX RDS data format */
+struct fm_rdsdata_format {
+   union {
+   struct {
+   unsigned char rdsbuff[FM_RX_RDS_INFO_FIELD_MAX];
+   } groupdatabuff;
+   struct {
+   unsigned short pidata;
+   unsigned char block_b_byte1;
+   unsigned char block_b_byte2;
+   unsigned char block_c_byte1;
+   unsigned char block_c_byte2;
+   unsigned char block_d_byte1;
+   unsigned char block_d_byte2;
+   } groupgeneral;
+   struct {
+   unsigned short pidata;
+   unsigned char block_b_byte1;
+   unsigned char block_b_byte2;
+   unsigned char firstaf;
+   unsigned char secondaf;
+   unsigned char firstpsbyte;
+   unsigned char secondpsbyte;
+   } group0A;
+
+   struct {
+   unsigned short pidata;
+   unsigned char block_b_byte1;
+   unsigned char block_b_byte2;
+   unsigned short pidata2;
+   unsigned char firstpsbyte;
+   unsigned char secondpsbyte;
+   } group0B;
+   } rdsdata;
+};
+
+/* FM region (Europe/US, Japan) info */
+struct region_info {
+   unsigned int channel_spacing;
+   unsigned int bottom_frequency;
+   unsigned int top_frequency;
+   unsigned char region_index;
+};
+
+typedef void (*int_handler_prototype) (void *);
+
+/* FM Interrupt processing related info */
+struct fm_irq {
+   unsigned char stage_index;
+   unsigned short flag;/* FM interrupt flag */
+   unsigned short mask;/* FM interrupt mask */
+   /* Interrupt process timeout handler */
+   struct timer_list int_timeout_timer;
+   unsigned char irq_service_timeout_retry;
+   int_handler_prototype *fm_int_handlers;
+};
+
+/* RDS info */
+struct fm_rds {
+   

[PATCH v7 2/7] drivers:media:radio: wl128x: fmdrv_v4l2 sources

2010-12-17 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

This module interfaces V4L2 subsystem and FM common module.
It registers itself with V4L2 as Radio module.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/wl128x/fmdrv_v4l2.c |  588 +++
 drivers/media/radio/wl128x/fmdrv_v4l2.h |   33 ++
 2 files changed, 621 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/fmdrv_v4l2.c
 create mode 100644 drivers/media/radio/wl128x/fmdrv_v4l2.h

diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c 
b/drivers/media/radio/wl128x/fmdrv_v4l2.c
new file mode 100644
index 000..623102f
--- /dev/null
+++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c
@@ -0,0 +1,588 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *  This file provides interfaces to V4L2 subsystem.
+ *
+ *  This module registers with V4L2 subsystem as Radio
+ *  data system interface (/dev/radio). During the registration,
+ *  it will expose two set of function pointers.
+ *
+ *1) File operation related API (open, close, read, write, poll...etc).
+ *2) Set of V4L2 IOCTL complaint API.
+ *
+ *  Copyright (C) 2010 Texas Instruments
+ *  Author: Raja Mani raja_m...@ti.com
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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 fmdrv.h
+#include fmdrv_v4l2.h
+#include fmdrv_common.h
+#include fmdrv_rx.h
+#include fmdrv_tx.h
+
+static struct video_device *gradio_dev;
+static unsigned char radio_disconnected;
+
+/* -- V4L2 RADIO (/dev/radioX) device file operation interfaces --- */
+
+/* Read RX RDS data */
+static ssize_t fm_v4l2_fops_read(struct file *file, char __user * buf,
+   size_t count, loff_t *ppos)
+{
+   unsigned char rds_mode;
+   int ret;
+   struct fmdrv_ops *fmdev;
+
+   fmdev = video_drvdata(file);
+
+   if (!radio_disconnected) {
+   pr_err((fmdrv): FM device is already disconnected\n);
+   return -EIO;
+   }
+
+   /* Turn on RDS mode , if it is disabled */
+   ret = fm_rx_get_rds_mode(fmdev, rds_mode);
+   if (ret  0) {
+   pr_err((fmdrv): Unable to read current rds mode\n);
+   return ret;
+   }
+
+   if (rds_mode == FM_RDS_DISABLE) {
+   ret = fmc_set_rds_mode(fmdev, FM_RDS_ENABLE);
+   if (ret  0) {
+   pr_err((fmdrv): Failed to enable rds mode\n);
+   return ret;
+   }
+   }
+
+   /* Copy RDS data from internal buffer to user buffer */
+   ret = fmc_transfer_rds_from_internal_buff(fmdev, file, buf, count);
+
+   return ret;
+}
+
+/* Write TX RDS data */
+static ssize_t fm_v4l2_fops_write(struct file *file, const char __user * buf,
+   size_t count, loff_t *ppos)
+{
+   struct tx_rds rds;
+   int ret;
+   struct fmdrv_ops *fmdev;
+
+   ret = copy_from_user(rds, buf, sizeof(rds));
+   pr_debug((fmdrv): (%d)type: %d, text %s, af %d\n,
+  ret, rds.text_type, rds.text, rds.af_freq);
+
+   fmdev = video_drvdata(file);
+   fm_tx_set_radio_text(fmdev, rds.text, rds.text_type);
+   fm_tx_set_af(fmdev, rds.af_freq);
+
+   return 0;
+}
+
+static unsigned int fm_v4l2_fops_poll(struct file *file,
+ struct poll_table_struct *pts)
+{
+   int ret;
+   struct fmdrv_ops *fmdev;
+
+   fmdev = video_drvdata(file);
+   ret = fmc_is_rds_data_available(fmdev, file, pts);
+   if (ret  0)
+   return POLLIN | POLLRDNORM;
+
+   return 0;
+}
+
+/*
+ * Handle open request for /dev/radioX device.
+ * Start with FM RX mode as default.
+ */
+static int fm_v4l2_fops_open(struct file *file)
+{
+   int ret;
+   struct fmdrv_ops *fmdev = NULL;
+
+   /* Don't allow multiple open */
+   if (radio_disconnected) {
+   pr_err((fmdrv): FM device is already opened\n);
+   return -EBUSY;
+   }
+
+   fmdev = video_drvdata(file);
+
+   ret = fmc_prepare(fmdev);
+   if (ret  0) {
+   pr_err((fmdrv): Unable to prepare FM CORE\n);
+   return ret;
+   }
+
+   pr_debug((fmdrv): Load FM RX firmware..\n);
+
+   ret = fmc_set_mode(fmdev, FM_MODE_RX);
+   if (ret  0) {
+   

[PATCH v7 6/7] drivers:media:radio: wl128x: Kconfig Makefile added for wl128x driver

2010-12-17 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/media/radio/wl128x/Kconfig  |   17 +
 drivers/media/radio/wl128x/Makefile |6 ++
 2 files changed, 23 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/wl128x/Kconfig
 create mode 100644 drivers/media/radio/wl128x/Makefile

diff --git a/drivers/media/radio/wl128x/Kconfig 
b/drivers/media/radio/wl128x/Kconfig
new file mode 100644
index 000..749f67b
--- /dev/null
+++ b/drivers/media/radio/wl128x/Kconfig
@@ -0,0 +1,17 @@
+#
+# TI's wl128x FM driver based on TI's ST driver.
+#
+menu Texas Instruments WL128x FM driver (ST based)
+config RADIO_WL128X
+   tristate Texas Instruments WL128x FM Radio
+   depends on VIDEO_V4L2  RFKILL
+   select TI_ST
+   help
+   Choose Y here if you have this FM radio chip.
+
+   In order to control your radio card, you will need to use programs
+   that are compatible with the Video For Linux 2 API.  Information on
+   this API and pointers to v4l2 programs may be found at
+   file:Documentation/video4linux/API.html.
+
+endmenu
diff --git a/drivers/media/radio/wl128x/Makefile 
b/drivers/media/radio/wl128x/Makefile
new file mode 100644
index 000..32a0ead
--- /dev/null
+++ b/drivers/media/radio/wl128x/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for TI's shared transport driver based wl128x
+# FM radio.
+#
+obj-$(CONFIG_RADIO_WL128X) += fm_drv.o
+fm_drv-objs:= fmdrv_common.o fmdrv_rx.o fmdrv_tx.o fmdrv_v4l2.o
-- 
1.5.6.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC v6 0/9] FM V4L2 drivers for WL128x

2010-12-03 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Mauro and the list,

This is the v6 version of the TI WL128x FM V4L2 drivers patchset.
Texas Instrument's WL128x chipset packs BT, FM, GPS and WLAN in a single
die with BT, FM and GPS being interfaced over a single UART.
This driver works on top of the shared transport line discipline driver.
This driver can also be made use for the WL127x version of the chip which packs
BT, FM and WLAN only.

Comments on the last version of the patches have been taken care,
such asi
- Removed use of new V4L2 CID to set the BAND (US/JAPAN). Instead handle it
in driver.
- Removed the new private CID defined for channel spacing instead handle it
in ioctl VIDIOC_S_HW_FREQ_SEEK.

Also,
Can you please also stage this version? Since the files are becoming big
to be posted as patches?

Thanks  Regards,
Manjunatha Halli

Manjunatha Halli (9):
  include:linux: videodev2.h: FM Rx control class
  Documentation:DocBook:v4l: Update the controls.xml for TI FM driver
  drivers:staging: ti-st: fmdrv common header file
  drivers:staging: ti-st: fmdrv_v4l2 sources
  drivers:staging: ti-st: fmdrv_common sources
  drivers:staging: ti-st: FM driver RX sources
  drivers:staging: ti-st: FM driver TX sources
  drivers:staging: ti-st: Kconfig  Makefile change
  driver:staging:ti-st: Update TODO for FM V4L2 driver.

 Documentation/DocBook/v4l/controls.xml |   12 +
 drivers/staging/ti-st/Kconfig  |   10 +
 drivers/staging/ti-st/Makefile |2 +
 drivers/staging/ti-st/TODO |   10 +-
 drivers/staging/ti-st/fmdrv.h  |  239 
 drivers/staging/ti-st/fmdrv_common.c   | 2003 
 drivers/staging/ti-st/fmdrv_common.h   |  402 +++
 drivers/staging/ti-st/fmdrv_rx.c   |  902 ++
 drivers/staging/ti-st/fmdrv_rx.h   |   59 +
 drivers/staging/ti-st/fmdrv_tx.c   |  420 +++
 drivers/staging/ti-st/fmdrv_tx.h   |   37 +
 drivers/staging/ti-st/fmdrv_v4l2.c |  720 
 drivers/staging/ti-st/fmdrv_v4l2.h |   32 +
 include/linux/videodev2.h  |8 +
 14 files changed, 4855 insertions(+), 1 deletions(-)
 create mode 100644 drivers/staging/ti-st/fmdrv.h
 create mode 100644 drivers/staging/ti-st/fmdrv_common.c
 create mode 100644 drivers/staging/ti-st/fmdrv_common.h
 create mode 100644 drivers/staging/ti-st/fmdrv_rx.c
 create mode 100644 drivers/staging/ti-st/fmdrv_rx.h
 create mode 100644 drivers/staging/ti-st/fmdrv_tx.c
 create mode 100644 drivers/staging/ti-st/fmdrv_tx.h
 create mode 100644 drivers/staging/ti-st/fmdrv_v4l2.c
 create mode 100644 drivers/staging/ti-st/fmdrv_v4l2.h

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC v6 3/9] drivers:staging: ti-st: fmdrv common header file

2010-12-03 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

These are common headers used in FM submodules (FM V4L2, FM common,
FM Rx,and FM TX).

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/staging/ti-st/fmdrv.h |  239 +
 1 files changed, 239 insertions(+), 0 deletions(-)
 create mode 100644 drivers/staging/ti-st/fmdrv.h

diff --git a/drivers/staging/ti-st/fmdrv.h b/drivers/staging/ti-st/fmdrv.h
new file mode 100644
index 000..0df3118
--- /dev/null
+++ b/drivers/staging/ti-st/fmdrv.h
@@ -0,0 +1,239 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *
+ *  Common header for all FM driver sub-modules.
+ *
+ *  Copyright (C) 2009 Texas Instruments
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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
+ *
+ */
+
+#ifndef _FM_DRV_H
+#define _FM_DRV_H
+
+#include linux/skbuff.h
+#include linux/interrupt.h
+#include sound/core.h
+#include sound/initval.h
+#include linux/timer.h
+#include linux/version.h
+
+#define FM_DRV_VERSION0.01
+/* Should match with FM_DRV_VERSION */
+#define FM_DRV_RADIO_VERSION  KERNEL_VERSION(0, 0, 1)
+#define FM_DRV_NAME   ti_fmdrv
+#define FM_DRV_CARD_SHORT_NAMETI FM Radio
+#define FM_DRV_CARD_LONG_NAME Texas Instruments FM Radio
+
+/* Flag info */
+#define FM_INTTASK_RUNNING0
+#define FM_INTTASK_SCHEDULE_PENDING   1
+#define FM_FIRMWARE_DW_INPROGRESS 2
+#define FM_CORE_READY 3
+#define FM_CORE_TRANSPORT_READY   4
+#define FM_AF_SWITCH_INPROGRESS  5
+#define FM_CORE_TX_XMITING   6
+
+#define FM_TUNE_COMPLETE 0x1
+#define FM_BAND_LIMIT0x2
+
+#define FM_DRV_TX_TIMEOUT  (5*HZ)  /* 5 seconds */
+#define FM_DRV_RX_SEEK_TIMEOUT (20*HZ) /* 20 seconds */
+
+#define NO_OF_ENTRIES_IN_ARRAY(array) (sizeof(array) / sizeof(array[0]))
+
+enum {
+   FM_MODE_OFF,
+   FM_MODE_TX,
+   FM_MODE_RX,
+   FM_MODE_ENTRY_MAX
+};
+
+#define FM_RX_RDS_INFO_FIELD_MAX   8   /* 4 Group * 2 Bytes */
+
+/*
+ * define private CIDs for V4L2
+ */
+#define V4L2_CID_CHANNEL_SPACING (V4L2_CID_PRIVATE_BASE + 0)
+
+/* RX RDS data format */
+struct fm_rdsdata_format {
+   union {
+   struct {
+   unsigned char rdsbuff[FM_RX_RDS_INFO_FIELD_MAX];
+   } groupdatabuff;
+   struct {
+   unsigned short pidata;
+   unsigned char block_b_byte1;
+   unsigned char block_b_byte2;
+   unsigned char block_c_byte1;
+   unsigned char block_c_byte2;
+   unsigned char block_d_byte1;
+   unsigned char block_d_byte2;
+   } groupgeneral;
+   struct {
+   unsigned short pidata;
+   unsigned char block_b_byte1;
+   unsigned char block_b_byte2;
+   unsigned char firstaf;
+   unsigned char secondaf;
+   unsigned char firstpsbyte;
+   unsigned char secondpsbyte;
+   } group0A;
+
+   struct {
+   unsigned short pidata;
+   unsigned char block_b_byte1;
+   unsigned char block_b_byte2;
+   unsigned short pidata2;
+   unsigned char firstpsbyte;
+   unsigned char secondpsbyte;
+   } group0B;
+   } rdsdata;
+};
+
+/* FM region (Europe/US, Japan) info */
+struct region_info {
+   unsigned int channel_spacing;
+   unsigned int bottom_frequency;
+   unsigned int top_frequency;
+   unsigned char region_index;
+};
+
+typedef void (*int_handler_prototype) (void *);
+
+/* FM Interrupt processing related info */
+struct fm_irq {
+   unsigned char stage_index;
+   unsigned short flag;/* FM interrupt flag */
+   unsigned short mask;/* FM interrupt mask */
+   /* Interrupt process timeout handler */
+   struct timer_list int_timeout_timer;
+   unsigned char irq_service_timeout_retry;
+   int_handler_prototype *fm_int_handlers;
+};
+
+/* RDS info */
+struct fm_rds {
+   unsigned char flag; /* RX RDS on/off status */
+   unsigned char last_block_index; /* Last 

[RFC v6 2/9] Documentation:DocBook:v4l: Update the controls.xml for TI FM driver

2010-12-03 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Added entries for following 2 new CID's which are added for TI FM
driver:
- V4L2_CID_RSSI_THRESHOLD
- V4L2_CID_TUNE_AF

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 Documentation/DocBook/v4l/controls.xml |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/Documentation/DocBook/v4l/controls.xml 
b/Documentation/DocBook/v4l/controls.xml
index 2fae3e8..b560953 100644
--- a/Documentation/DocBook/v4l/controls.xml
+++ b/Documentation/DocBook/v4l/controls.xml
@@ -132,6 +132,18 @@ consumption state./entry
entryLoudness mode (bass boost)./entry
  /row
  row
+   entryconstantV4L2_CID_RSSI_THRESHOLD/constant/entry
+   entryinteger/entry
+   entrySet RSSI threshold level. Change the default threshold
+level used to select valid frequencies during vidioc_s_hw_freq_seek./entry
+ /row
+ row
+   entryconstantV4L2_CID_TUNE_AF/constant/entry
+   entryinteger/entry
+   entrySet Alternative Frequency mode. Enable or disable
+alternative frequency mode./entry
+ /row
+ row
entryconstantV4L2_CID_BLACK_LEVEL/constant/entry
entryinteger/entry
entryAnother name for brightness (not a synonym of
-- 
1.5.6.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC v6 7/9] drivers:staging: ti-st: FM driver TX sources

2010-12-03 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

This has implementation for FM TX functionality.
It communicates with FM V4l2 module and FM common module.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/staging/ti-st/fmdrv_tx.c |  420 ++
 drivers/staging/ti-st/fmdrv_tx.h |   37 
 2 files changed, 457 insertions(+), 0 deletions(-)
 create mode 100644 drivers/staging/ti-st/fmdrv_tx.c
 create mode 100644 drivers/staging/ti-st/fmdrv_tx.h

diff --git a/drivers/staging/ti-st/fmdrv_tx.c b/drivers/staging/ti-st/fmdrv_tx.c
new file mode 100644
index 000..c9e738e
--- /dev/null
+++ b/drivers/staging/ti-st/fmdrv_tx.c
@@ -0,0 +1,420 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *  This sub-module of FM driver implements FM TX functionality.
+ *
+ *  Copyright (C) 2010 Texas Instruments
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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/delay.h
+#include fmdrv.h
+#include fmdrv_common.h
+#include fmdrv_tx.h
+
+int fm_tx_set_stereo_mono(struct fmdrv_ops *fmdev, unsigned short mode)
+{
+   unsigned short payload;
+   int ret = 0;
+
+   if (fmdev-curr_fmmode != FM_MODE_TX)
+   return -EPERM;
+
+   if (fmdev-tx_data.aud_mode == mode)
+   return ret;
+
+   pr_debug(stereo mode: %d\n, mode);
+
+   /* Set Stereo/Mono mode */
+   payload = (1 - mode);
+   ret = fmc_send_cmd(fmdev, MONO_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   fmdev-tx_data.aud_mode = mode;
+
+   return ret;
+}
+
+static int __set_rds_text(struct fmdrv_ops *fmdev, unsigned char *rds_text)
+{
+   unsigned short payload;
+   int ret;
+
+   ret = fmc_send_cmd(fmdev, RDS_DATA_SET, REG_WR, rds_text,
+   strlen(rds_text), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Scroll mode */
+   payload = (unsigned short)0x1;
+   ret = fmc_send_cmd(fmdev, DISPLAY_MODE, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   return 0;
+}
+
+static int __set_rds_data_mode(struct fmdrv_ops *fmdev, unsigned char mode)
+{
+   unsigned short payload;
+   int ret;
+
+   /* Setting unique PI TODO: how unique? */
+   payload = (unsigned short)0xcafe;
+   ret = fmc_send_cmd(fmdev, PI_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Set decoder id */
+   payload = (unsigned short)0xa;
+   ret = fmc_send_cmd(fmdev, DI_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* TODO: RDS_MODE_GET? */
+   return 0;
+}
+
+static int __set_rds_len(struct fmdrv_ops *fmdev, unsigned char type,
+   unsigned short len)
+{
+   unsigned short payload;
+   int ret;
+
+   len |= type  8;
+   payload = len;
+   ret = fmc_send_cmd(fmdev, RDS_CONFIG_DATA_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* TODO: LENGTH_GET? */
+   return 0;
+}
+
+int fm_tx_set_rds_mode(struct fmdrv_ops *fmdev, unsigned char rds_en_dis)
+{
+   unsigned short payload;
+   int ret;
+   unsigned char rds_text[] = Zoom2\n;
+
+   if (fmdev-curr_fmmode != FM_MODE_TX)
+   return -EPERM;
+
+   pr_debug(rds_en_dis:%d(E:%d, D:%d)\n, rds_en_dis,
+  FM_RDS_ENABLE, FM_RDS_DISABLE);
+
+   if (rds_en_dis == FM_RDS_ENABLE) {
+   /* Set RDS length */
+   __set_rds_len(fmdev, 0, strlen(rds_text));
+
+   /* Set RDS text */
+   __set_rds_text(fmdev, rds_text);
+
+   /* Set RDS mode */
+   __set_rds_data_mode(fmdev, 0x0);
+   }
+
+   /* Send command to enable RDS */
+   if (rds_en_dis == FM_RDS_ENABLE)
+   payload = 0x01;
+   else
+   payload = 0x00;
+
+   ret = fmc_send_cmd(fmdev, RDS_DATA_ENB, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   if (rds_en_dis 

[RFC v6 1/9] include:linux: videodev2.h: FM Rx control class

2010-12-03 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Introduce V4L2_CTRL_CLASS_FM_RX for FM receivers similar to
V4L2_CTRL_CLASS_FM_TX.
Few controls such as RSSI threshold, Alternate Frequency are for
now under this class.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 include/linux/videodev2.h |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 5f6f470..5ab66a9 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -932,6 +932,7 @@ struct v4l2_ext_controls {
 #define V4L2_CTRL_CLASS_MPEG 0x0099/* MPEG-compression controls */
 #define V4L2_CTRL_CLASS_CAMERA 0x009a  /* Camera class controls */
 #define V4L2_CTRL_CLASS_FM_TX 0x009b   /* FM Modulator control class */
+#define V4L2_CTRL_CLASS_FM_RX 0x009c   /* FM Tuner control class */
 
 #define V4L2_CTRL_ID_MASK(0x0fff)
 #define V4L2_CTRL_ID2CLASS(id)((id)  0x0fffUL)
@@ -1304,6 +1305,10 @@ enum  v4l2_exposure_auto_type {
 #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)
 
+/* FM Tuner class control IDs */
+#define V4L2_CID_FM_RX_CLASS_BASE(V4L2_CTRL_CLASS_FM_RX | 0x900)
+#define V4L2_CID_FM_RX_CLASS (V4L2_CTRL_CLASS_FM_RX | 1)
+
 #define V4L2_CID_RDS_TX_DEVIATION  (V4L2_CID_FM_TX_CLASS_BASE + 1)
 #define V4L2_CID_RDS_TX_PI (V4L2_CID_FM_TX_CLASS_BASE + 2)
 #define V4L2_CID_RDS_TX_PTY(V4L2_CID_FM_TX_CLASS_BASE + 3)
@@ -1333,6 +1338,9 @@ enum v4l2_preemphasis {
 #define V4L2_CID_TUNE_POWER_LEVEL  (V4L2_CID_FM_TX_CLASS_BASE + 
113)
 #define V4L2_CID_TUNE_ANTENNA_CAPACITOR
(V4L2_CID_FM_TX_CLASS_BASE + 114)
 
+#define V4L2_CID_RSSI_THRESHOLD(V4L2_CID_FM_RX_CLASS_BASE + 2)
+#define V4L2_CID_TUNE_AF   (V4L2_CID_FM_RX_CLASS_BASE + 3)
+
 /*
  * T U N I N G
  */
-- 
1.5.6.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC v6 9/9] driver:staging:ti-st: Update TODO for FM V4L2 driver.

2010-12-03 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/staging/ti-st/TODO |   10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/ti-st/TODO b/drivers/staging/ti-st/TODO
index ebfd6bb..002635d 100644
--- a/drivers/staging/ti-st/TODO
+++ b/drivers/staging/ti-st/TODO
@@ -1,6 +1,14 @@
 TODO:
 
-1. Step up and maintain this driver to ensure that it continues
+1. Upstreaming BT driver
+
+2. Upstreaming FM driver
+
+   a. Use the new V4L2 control framework for all the V4L2 controls 
supported.
+
+   b. Change the interrupt handling mechanism as per comments by 'Hans 
Verkuil'.
+
+3. Step up and maintain this driver to ensure that it continues
 to work.  Having the hardware for this is pretty much a
 requirement.  If this does not happen, the will be removed in
 the 2.6.35 kernel release.
-- 
1.5.6.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC v6 8/9] drivers:staging: ti-st: Kconfig Makefile change

2010-12-03 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Add new menu option in Kconfig and compilation option in Makefile
for TI FM driver.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/staging/ti-st/Kconfig  |   10 ++
 drivers/staging/ti-st/Makefile |2 ++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/ti-st/Kconfig b/drivers/staging/ti-st/Kconfig
index 074b8e8..43b6dea 100644
--- a/drivers/staging/ti-st/Kconfig
+++ b/drivers/staging/ti-st/Kconfig
@@ -11,4 +11,14 @@ config ST_BT
  This enables the Bluetooth driver for TI BT/FM/GPS combo devices.
  This makes use of shared transport line discipline core driver to
  communicate with the BT core of the combo chip.
+
+config ST_FM
+tristate fm driver for ST
+depends on VIDEO_DEV  RFKILL
+select TI_ST
+help
+  This enables the FM driver for TI BT/FM/GPS combo devices.
+  This makes use of shared transport line discipline core driver to
+  communicate with the FM core of the combo chip.
+
 endmenu
diff --git a/drivers/staging/ti-st/Makefile b/drivers/staging/ti-st/Makefile
index 5f11b82..330f95b 100644
--- a/drivers/staging/ti-st/Makefile
+++ b/drivers/staging/ti-st/Makefile
@@ -3,3 +3,5 @@
 # and its protocol drivers (BT, FM, GPS)
 #
 obj-$(CONFIG_ST_BT)+= bt_drv.o
+obj-$(CONFIG_ST_FM)+= fm_drv.o
+fm_drv-objs:= fmdrv_common.o fmdrv_rx.o fmdrv_tx.o 
fmdrv_v4l2.o
-- 
1.5.6.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC v6 4/9] drivers:staging: ti-st: fmdrv_v4l2 sources

2010-12-03 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

This module interfaces V4L2 subsystem and FM common
module. It registers itself with V4L2 as Radio module.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/staging/ti-st/fmdrv_v4l2.c |  720 
 drivers/staging/ti-st/fmdrv_v4l2.h |   32 ++
 2 files changed, 752 insertions(+), 0 deletions(-)
 create mode 100644 drivers/staging/ti-st/fmdrv_v4l2.c
 create mode 100644 drivers/staging/ti-st/fmdrv_v4l2.h

diff --git a/drivers/staging/ti-st/fmdrv_v4l2.c 
b/drivers/staging/ti-st/fmdrv_v4l2.c
new file mode 100644
index 000..8435d5a
--- /dev/null
+++ b/drivers/staging/ti-st/fmdrv_v4l2.c
@@ -0,0 +1,720 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *  This file provides interfaces to V4L2 subsystem.
+ *
+ *  This module registers with V4L2 subsystem as Radio
+ *  data system interface (/dev/radio). During the registration,
+ *  it will expose two set of function pointers.
+ *
+ *1) File operation related API (open, close, read, write, poll...etc).
+ *2) Set of V4L2 IOCTL complaint API.
+ *
+ *  Copyright (C) 2010 Texas Instruments
+ *  Author: Raja Mani raja_m...@ti.com
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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 fmdrv.h
+#include fmdrv_v4l2.h
+#include fmdrv_common.h
+#include fmdrv_rx.h
+#include fmdrv_tx.h
+
+static struct video_device *gradio_dev;
+static unsigned char radio_disconnected;
+
+/* Query control */
+static struct v4l2_queryctrl fmdrv_v4l2_queryctrl[] = {
+   {
+.id = V4L2_CID_AUDIO_VOLUME,
+.type = V4L2_CTRL_TYPE_INTEGER,
+.name = Volume,
+.minimum = FM_RX_VOLUME_MIN,
+.maximum = FM_RX_VOLUME_MAX,
+.step = 1,
+.default_value = FM_DEFAULT_RX_VOLUME,
+},
+   {
+.id = V4L2_CID_AUDIO_BALANCE,
+.flags = V4L2_CTRL_FLAG_DISABLED,
+},
+   {
+.id = V4L2_CID_AUDIO_BASS,
+.flags = V4L2_CTRL_FLAG_DISABLED,
+},
+   {
+.id = V4L2_CID_AUDIO_TREBLE,
+.flags = V4L2_CTRL_FLAG_DISABLED,
+},
+   {
+.id = V4L2_CID_AUDIO_MUTE,
+.type = V4L2_CTRL_TYPE_BOOLEAN,
+.name = Mute,
+.minimum = 0,
+.maximum = 2,
+.step = 1,
+.default_value = FM_MUTE_OFF,
+},
+   {
+.id = V4L2_CID_AUDIO_LOUDNESS,
+.flags = V4L2_CTRL_FLAG_DISABLED,
+},
+};
+
+/* -- V4L2 RADIO (/dev/radioX) device file operation interfaces --- */
+
+/* Read RX RDS data */
+static ssize_t fm_v4l2_fops_read(struct file *file, char __user * buf,
+   size_t count, loff_t *ppos)
+{
+   unsigned char rds_mode;
+   int ret;
+   struct fmdrv_ops *fmdev;
+
+   fmdev = video_drvdata(file);
+
+   if (!radio_disconnected) {
+   pr_err((fmdrv): FM device is already disconnected\n);
+   return -EIO;
+   }
+
+   /* Turn on RDS mode , if it is disabled */
+   ret = fm_rx_get_rds_mode(fmdev, rds_mode);
+   if (ret  0) {
+   pr_err((fmdrv): Unable to read current rds mode\n);
+   return ret;
+   }
+
+   if (rds_mode == FM_RDS_DISABLE) {
+   ret = fmc_set_rds_mode(fmdev, FM_RDS_ENABLE);
+   if (ret  0) {
+   pr_err((fmdrv): Failed to enable rds mode\n);
+   return ret;
+   }
+   }
+
+   /* Copy RDS data from internal buffer to user buffer */
+   ret = fmc_transfer_rds_from_internal_buff(fmdev, file, buf, count);
+
+   return ret;
+}
+
+/* Write TX RDS data */
+static ssize_t fm_v4l2_fops_write(struct file *file, const char __user * buf,
+   size_t count, loff_t *ppos)
+{
+   struct tx_rds rds;
+   int ret;
+   struct fmdrv_ops *fmdev;
+
+   ret = copy_from_user(rds, buf, sizeof(rds));
+   pr_debug((fmdrv): (%d)type: %d, text %s, af %d\n,
+  ret, rds.text_type, rds.text, rds.af_freq);
+
+   fmdev = video_drvdata(file);
+   fm_tx_set_radio_text(fmdev, rds.text, rds.text_type);
+   fm_tx_set_af(fmdev, rds.af_freq);
+
+   return 0;
+}
+
+static unsigned int fm_v4l2_fops_poll(struct file *file,
+ struct poll_table_struct *pts)
+{
+   

[RFC v5 0/9] FM V4L2 drivers for WL128x

2010-11-29 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Mauro and the list,

This is the v5 version of the TI WL128x FM V4L2 drivers patchset.
Texas Instrument's WL128x chipset packs BT, FM, GPS and WLAN in a single
die with BT, FM and GPS being interfaced over a single UART.
This driver works on top of the shared transport line discipline driver.
This driver can also be made use for the WL127x version of the chip which packs
BT, FM and WLAN only.

Comments on the last version of the patches have been taken care,
such as
- Removed the array for opcode handling, instead defined them as macro's.
- Moved the error message to fmc_senc_cmd() instead of printing it from all
the caller functions.
- Use of 'cpu_to_be16' macro instead of using custom macro.

Also,
Can you please also stage this version? Since the files are becoming big
to be posted as patches?

Thanks  Regards,
Manjunatha.


Manjunatha Halli (9):
  include:linux: videodev2.h: FM Rx control class
  Documentation:DocBook:v4l: Update the controls.xml for TI FM driver
  drivers:staging: ti-st: fmdrv common header file
  drivers:staging: ti-st: fmdrv_v4l2 sources
  drivers:staging: ti-st: fmdrv_common sources
  drivers:staging: ti-st: fmdrv_rx sources
  drivers:staging: ti-st: fmdrv_tx sources
  drivers:staging: ti-st: Kconfig  Makefile change
  driver:staging:ti-st: Update TODO for FM V4L2 driver.

 Documentation/DocBook/v4l/controls.xml |   12 +
 drivers/staging/ti-st/Kconfig  |   10 +
 drivers/staging/ti-st/Makefile |2 +
 drivers/staging/ti-st/TODO |   17 +-
 drivers/staging/ti-st/fmdrv.h  |  247 
 drivers/staging/ti-st/fmdrv_common.c   | 2005 
 drivers/staging/ti-st/fmdrv_common.h   |  412 +++
 drivers/staging/ti-st/fmdrv_rx.c   |  903 ++
 drivers/staging/ti-st/fmdrv_rx.h   |   59 +
 drivers/staging/ti-st/fmdrv_tx.c   |  420 +++
 drivers/staging/ti-st/fmdrv_tx.h   |   37 +
 drivers/staging/ti-st/fmdrv_v4l2.c |  755 
 drivers/staging/ti-st/fmdrv_v4l2.h |   32 +
 include/linux/videodev2.h  |8 +
 14 files changed, 4918 insertions(+), 1 deletions(-)
 create mode 100644 drivers/staging/ti-st/fmdrv.h
 create mode 100644 drivers/staging/ti-st/fmdrv_common.c
 create mode 100644 drivers/staging/ti-st/fmdrv_common.h
 create mode 100644 drivers/staging/ti-st/fmdrv_rx.c
 create mode 100644 drivers/staging/ti-st/fmdrv_rx.h
 create mode 100644 drivers/staging/ti-st/fmdrv_tx.c
 create mode 100644 drivers/staging/ti-st/fmdrv_tx.h
 create mode 100644 drivers/staging/ti-st/fmdrv_v4l2.c
 create mode 100644 drivers/staging/ti-st/fmdrv_v4l2.h

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC v5 1/9] include:linux: videodev2.h: FM Rx control class

2010-11-29 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Introduce V4L2_CTRL_CLASS_FM_RX for FM receivers similar to
V4L2_CTRL_CLASS_FM_TX.
Few controls such as RSSI threshold, Alternate Frequency are for
now under this class.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 include/linux/videodev2.h |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 5f6f470..5ab66a9 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -932,6 +932,7 @@ struct v4l2_ext_controls {
 #define V4L2_CTRL_CLASS_MPEG 0x0099/* MPEG-compression controls */
 #define V4L2_CTRL_CLASS_CAMERA 0x009a  /* Camera class controls */
 #define V4L2_CTRL_CLASS_FM_TX 0x009b   /* FM Modulator control class */
+#define V4L2_CTRL_CLASS_FM_RX 0x009c   /* FM Tuner control class */
 
 #define V4L2_CTRL_ID_MASK(0x0fff)
 #define V4L2_CTRL_ID2CLASS(id)((id)  0x0fffUL)
@@ -1304,6 +1305,10 @@ enum  v4l2_exposure_auto_type {
 #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)
 
+/* FM Tuner class control IDs */
+#define V4L2_CID_FM_RX_CLASS_BASE(V4L2_CTRL_CLASS_FM_RX | 0x900)
+#define V4L2_CID_FM_RX_CLASS (V4L2_CTRL_CLASS_FM_RX | 1)
+
 #define V4L2_CID_RDS_TX_DEVIATION  (V4L2_CID_FM_TX_CLASS_BASE + 1)
 #define V4L2_CID_RDS_TX_PI (V4L2_CID_FM_TX_CLASS_BASE + 2)
 #define V4L2_CID_RDS_TX_PTY(V4L2_CID_FM_TX_CLASS_BASE + 3)
@@ -1333,6 +1338,9 @@ enum v4l2_preemphasis {
 #define V4L2_CID_TUNE_POWER_LEVEL  (V4L2_CID_FM_TX_CLASS_BASE + 
113)
 #define V4L2_CID_TUNE_ANTENNA_CAPACITOR
(V4L2_CID_FM_TX_CLASS_BASE + 114)
 
+#define V4L2_CID_RSSI_THRESHOLD(V4L2_CID_FM_RX_CLASS_BASE + 2)
+#define V4L2_CID_TUNE_AF   (V4L2_CID_FM_RX_CLASS_BASE + 3)
+
 /*
  * T U N I N G
  */
-- 
1.5.6.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC v5 2/9] Documentation:DocBook:v4l: Update the controls.xml for TI FM driver

2010-11-29 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Added entries for following 2 new CID's which are added for TI FM
driver:
- V4L2_CID_RSSI_THRESHOLD
- V4L2_CID_TUNE_AF

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 Documentation/DocBook/v4l/controls.xml |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/Documentation/DocBook/v4l/controls.xml 
b/Documentation/DocBook/v4l/controls.xml
index 2fae3e8..b560953 100644
--- a/Documentation/DocBook/v4l/controls.xml
+++ b/Documentation/DocBook/v4l/controls.xml
@@ -132,6 +132,18 @@ consumption state./entry
entryLoudness mode (bass boost)./entry
  /row
  row
+   entryconstantV4L2_CID_RSSI_THRESHOLD/constant/entry
+   entryinteger/entry
+   entrySet RSSI threshold level. Change the default threshold
+level used to select valid frequencies during vidioc_s_hw_freq_seek./entry
+ /row
+ row
+   entryconstantV4L2_CID_TUNE_AF/constant/entry
+   entryinteger/entry
+   entrySet Alternative Frequency mode. Enable or disable
+alternative frequency mode./entry
+ /row
+ row
entryconstantV4L2_CID_BLACK_LEVEL/constant/entry
entryinteger/entry
entryAnother name for brightness (not a synonym of
-- 
1.5.6.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC v5 3/9] drivers:staging: ti-st: fmdrv common header file

2010-11-29 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

These are common headers used in FM submodules (FM V4L2, FM common,
FM Rx,and FM TX).

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/staging/ti-st/fmdrv.h |  247 +
 1 files changed, 247 insertions(+), 0 deletions(-)
 create mode 100644 drivers/staging/ti-st/fmdrv.h

diff --git a/drivers/staging/ti-st/fmdrv.h b/drivers/staging/ti-st/fmdrv.h
new file mode 100644
index 000..080561f
--- /dev/null
+++ b/drivers/staging/ti-st/fmdrv.h
@@ -0,0 +1,247 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *
+ *  Common header for all FM driver sub-modules.
+ *
+ *  Copyright (C) 2009 Texas Instruments
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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
+ *
+ */
+
+#ifndef _FM_DRV_H
+#define _FM_DRV_H
+
+#include linux/skbuff.h
+#include linux/interrupt.h
+#include sound/core.h
+#include sound/initval.h
+#include linux/timer.h
+#include linux/version.h
+
+#define FM_DRV_VERSION0.01
+/* Should match with FM_DRV_VERSION */
+#define FM_DRV_RADIO_VERSION  KERNEL_VERSION(0, 0, 1)
+#define FM_DRV_NAME   ti_fmdrv
+#define FM_DRV_CARD_SHORT_NAMETI FM Radio
+#define FM_DRV_CARD_LONG_NAME Texas Instruments FM Radio
+
+/* Flag info */
+#define FM_INTTASK_RUNNING0
+#define FM_INTTASK_SCHEDULE_PENDING   1
+#define FM_FIRMWARE_DW_INPROGRESS 2
+#define FM_CORE_READY 3
+#define FM_CORE_TRANSPORT_READY   4
+#define FM_AF_SWITCH_INPROGRESS  5
+#define FM_CORE_TX_XMITING   6
+
+#define FM_TUNE_COMPLETE 0x1
+#define FM_BAND_LIMIT0x2
+
+#define FM_DRV_TX_TIMEOUT  (5*HZ)  /* 5 seconds */
+#define FM_DRV_RX_SEEK_TIMEOUT (20*HZ) /* 20 seconds */
+
+#define NO_OF_ENTRIES_IN_ARRAY(array) (sizeof(array) / sizeof(array[0]))
+
+enum {
+   FM_MODE_OFF,
+   FM_MODE_TX,
+   FM_MODE_RX,
+   FM_MODE_ENTRY_MAX
+};
+
+#define FM_RX_RDS_INFO_FIELD_MAX   8   /* 4 Group * 2 Bytes */
+
+/*
+ * define private CIDs for V4L2
+ */
+#define V4L2_CID_CHANNEL_SPACING (V4L2_CID_PRIVATE_BASE + 0)
+
+/* RX RDS data format */
+struct fm_rdsdata_format {
+   union {
+   struct {
+   unsigned char rdsbuff[FM_RX_RDS_INFO_FIELD_MAX];
+   } groupdatabuff;
+   struct {
+   unsigned short pidata;
+   unsigned char block_b_byte1;
+   unsigned char block_b_byte2;
+   unsigned char block_c_byte1;
+   unsigned char block_c_byte2;
+   unsigned char block_d_byte1;
+   unsigned char block_d_byte2;
+   } groupgeneral;
+   struct {
+   unsigned short pidata;
+   unsigned char block_b_byte1;
+   unsigned char block_b_byte2;
+   unsigned char firstaf;
+   unsigned char secondaf;
+   unsigned char firstpsbyte;
+   unsigned char secondpsbyte;
+   } group0A;
+
+   struct {
+   unsigned short pidata;
+   unsigned char block_b_byte1;
+   unsigned char block_b_byte2;
+   unsigned short pidata2;
+   unsigned char firstpsbyte;
+   unsigned char secondpsbyte;
+   } group0B;
+   } rdsdata;
+};
+
+/* FM region (Europe/US, Japan) info */
+struct region_info {
+   unsigned int channel_spacing;
+   unsigned int bottom_frequency;
+   unsigned int top_frequency;
+   unsigned char region_index;
+};
+
+typedef void (*int_handler_prototype) (void *);
+
+/* FM Interrupt processing related info */
+struct fm_irq {
+   unsigned char stage_index;
+   unsigned short flag;/* FM interrupt flag */
+   unsigned short mask;/* FM interrupt mask */
+   /* Interrupt process timeout handler */
+   struct timer_list int_timeout_timer;
+   unsigned char irq_service_timeout_retry;
+   int_handler_prototype *fm_int_handlers;
+};
+
+/* RDS info */
+struct fm_rds {
+   unsigned char flag; /* RX RDS on/off status */
+   unsigned char last_block_index; /* Last 

[RFC v5 4/9] drivers:staging: ti-st: fmdrv_v4l2 sources

2010-11-29 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

This module interfaces V4L2 subsystem and FM common
module. It registers itself with V4L2 as Radio module.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
Signed-off-by: Bheemsen Kulkarni bheemsen_kulka...@ti.com
---
 drivers/staging/ti-st/fmdrv_v4l2.c |  755 
 drivers/staging/ti-st/fmdrv_v4l2.h |   32 ++
 2 files changed, 787 insertions(+), 0 deletions(-)
 create mode 100644 drivers/staging/ti-st/fmdrv_v4l2.c
 create mode 100644 drivers/staging/ti-st/fmdrv_v4l2.h

diff --git a/drivers/staging/ti-st/fmdrv_v4l2.c 
b/drivers/staging/ti-st/fmdrv_v4l2.c
new file mode 100644
index 000..c993290
--- /dev/null
+++ b/drivers/staging/ti-st/fmdrv_v4l2.c
@@ -0,0 +1,755 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *  This file provides interfaces to V4L2 subsystem.
+ *
+ *  This module registers with V4L2 subsystem as Radio
+ *  data system interface (/dev/radio). During the registration,
+ *  it will expose two set of function pointers.
+ *
+ *1) File operation related API (open, close, read, write, poll...etc).
+ *2) Set of V4L2 IOCTL complaint API.
+ *
+ *  Copyright (C) 2010 Texas Instruments
+ *  Author: Raja Mani raja_m...@ti.com
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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 fmdrv.h
+#include fmdrv_v4l2.h
+#include fmdrv_common.h
+#include fmdrv_rx.h
+#include fmdrv_tx.h
+
+static struct video_device *gradio_dev;
+static unsigned char radio_disconnected;
+
+/* Query control */
+static struct v4l2_queryctrl fmdrv_v4l2_queryctrl[] = {
+   {
+.id = V4L2_CID_AUDIO_VOLUME,
+.type = V4L2_CTRL_TYPE_INTEGER,
+.name = Volume,
+.minimum = FM_RX_VOLUME_MIN,
+.maximum = FM_RX_VOLUME_MAX,
+.step = 1,
+.default_value = FM_DEFAULT_RX_VOLUME,
+},
+   {
+.id = V4L2_CID_AUDIO_BALANCE,
+.flags = V4L2_CTRL_FLAG_DISABLED,
+},
+   {
+.id = V4L2_CID_AUDIO_BASS,
+.flags = V4L2_CTRL_FLAG_DISABLED,
+},
+   {
+.id = V4L2_CID_AUDIO_TREBLE,
+.flags = V4L2_CTRL_FLAG_DISABLED,
+},
+   {
+.id = V4L2_CID_AUDIO_MUTE,
+.type = V4L2_CTRL_TYPE_BOOLEAN,
+.name = Mute,
+.minimum = 0,
+.maximum = 2,
+.step = 1,
+.default_value = FM_MUTE_OFF,
+},
+   {
+.id = V4L2_CID_AUDIO_LOUDNESS,
+.flags = V4L2_CTRL_FLAG_DISABLED,
+},
+};
+
+/* -- V4L2 RADIO (/dev/radioX) device file operation interfaces --- */
+
+/* Read RX RDS data */
+static ssize_t fm_v4l2_fops_read(struct file *file, char __user * buf,
+   size_t count, loff_t *ppos)
+{
+   unsigned char rds_mode;
+   int ret;
+   struct fmdrv_ops *fmdev;
+
+   fmdev = video_drvdata(file);
+
+   if (!radio_disconnected) {
+   pr_err((fmdrv): FM device is already disconnected\n);
+   return -EIO;
+   }
+
+   /* Turn on RDS mode , if it is disabled */
+   ret = fm_rx_get_rds_mode(fmdev, rds_mode);
+   if (ret  0) {
+   pr_err((fmdrv): Unable to read current rds mode\n);
+   return ret;
+   }
+
+   if (rds_mode == FM_RDS_DISABLE) {
+   ret = fmc_set_rds_mode(fmdev, FM_RDS_ENABLE);
+   if (ret  0) {
+   pr_err((fmdrv): Failed to enable rds mode\n);
+   return ret;
+   }
+   }
+
+   /* Copy RDS data from internal buffer to user buffer */
+   ret = fmc_transfer_rds_from_internal_buff(fmdev, file, buf, count);
+
+   return ret;
+}
+
+/* Write TX RDS data */
+static ssize_t fm_v4l2_fops_write(struct file *file, const char __user * buf,
+   size_t count, loff_t *ppos)
+{
+   struct tx_rds rds;
+   int ret;
+   struct fmdrv_ops *fmdev;
+
+   ret = copy_from_user(rds, buf, sizeof(rds));
+   pr_debug((fmdrv): (%d)type: %d, text %s, af %d\n,
+  ret, rds.text_type, rds.text, rds.af_freq);
+
+   fmdev = video_drvdata(file);
+   fm_tx_set_radio_text(fmdev, rds.text, rds.text_type);
+   fm_tx_set_af(fmdev, rds.af_freq);
+
+   return 0;
+}
+
+static unsigned int fm_v4l2_fops_poll(struct file *file,
+  

[RFC v5 6/9] drivers:staging: ti-st: fmdrv_rx sources

2010-11-29 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

This has implementation for FM RX functionality.
It communicates with FM V4l2 module and FM common module.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
Signed-off-by: Bheemsen Kulkarni bheemsen_kulka...@ti.com
---
 drivers/staging/ti-st/fmdrv_rx.c |  903 ++
 drivers/staging/ti-st/fmdrv_rx.h |   59 +++
 2 files changed, 962 insertions(+), 0 deletions(-)
 create mode 100644 drivers/staging/ti-st/fmdrv_rx.c
 create mode 100644 drivers/staging/ti-st/fmdrv_rx.h

diff --git a/drivers/staging/ti-st/fmdrv_rx.c b/drivers/staging/ti-st/fmdrv_rx.c
new file mode 100644
index 000..cdf3385
--- /dev/null
+++ b/drivers/staging/ti-st/fmdrv_rx.c
@@ -0,0 +1,903 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *  This sub-module of FM driver implements FM RX functionality.
+ *
+ *  Copyright (C) 2010 Texas Instruments
+ *  Author: Raja Mani raja_m...@ti.com
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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 fmdrv.h
+#include fmdrv_common.h
+#include fmdrv_rx.h
+
+void fm_rx_reset_rds_cache(struct fmdrv_ops *fmdev)
+{
+   fmdev-rx.rds.flag = FM_RDS_DISABLE;
+   fmdev-rx.rds.last_block_index = 0;
+   fmdev-rx.rds.wr_index = 0;
+   fmdev-rx.rds.rd_index = 0;
+
+   if (fmdev-rx.af_mode == FM_RX_RDS_AF_SWITCH_MODE_ON)
+   fmdev-irq_info.mask |= FM_LEV_EVENT;
+}
+
+void fm_rx_reset_curr_station_info(struct fmdrv_ops *fmdev)
+{
+   fmdev-rx.cur_station_info.picode = FM_NO_PI_CODE;
+   fmdev-rx.cur_station_info.no_of_items_in_afcache = 0;
+   fmdev-rx.cur_station_info.af_list_max = 0;
+}
+
+int fm_rx_set_frequency(struct fmdrv_ops *fmdev, unsigned int freq_to_set)
+{
+   unsigned long timeleft;
+   unsigned short payload, curr_frq, frq_index;
+   unsigned int curr_frq_in_khz;
+   int ret, resp_len;
+
+   if (fmdev-curr_fmmode != FM_MODE_RX)
+   return -EPERM;
+
+   if (freq_to_set  fmdev-rx.region.bottom_frequency ||
+   freq_to_set  fmdev-rx.region.top_frequency) {
+   pr_err((fmdrv): Invalid frequency %d\n, freq_to_set);
+   return -EINVAL;
+   }
+
+   /* Set audio enable */
+   payload = FM_RX_FM_AUDIO_ENABLE_I2S_AND_ANALOG;
+
+   ret = fmc_send_cmd(fmdev, AUDIO_ENABLE_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Set hilo to automatic selection */
+   payload = FM_RX_IFFREQ_HILO_AUTOMATIC;
+   ret = fmc_send_cmd(fmdev, HILO_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Calculate frequency index to write */
+   frq_index = (freq_to_set - fmdev-rx.region.bottom_frequency) /
+   FM_FREQ_MUL;
+
+   /* Set frequency index */
+   payload = frq_index;
+   ret = fmc_send_cmd(fmdev, FREQ_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Read flags - just to clear any pending interrupts if we had */
+   ret = fmc_send_cmd(fmdev, FLAG_GET, REG_RD, NULL, 2,
+   NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Enable FR, BL interrupts */
+   fmdev-irq_info.mask |= (FM_FR_EVENT | FM_BL_EVENT);
+   payload = fmdev-irq_info.mask;
+   ret = fmc_send_cmd(fmdev, INT_MASK_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Start tune */
+   payload = FM_TUNER_PRESET_MODE;
+   ret = fmc_send_cmd(fmdev, TUNER_MODE_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Wait for tune ended interrupt */
+   init_completion(fmdev-maintask_completion);
+   timeleft = wait_for_completion_timeout(fmdev-maintask_completion,
+  FM_DRV_TX_TIMEOUT);
+   if (!timeleft) {
+   pr_err((fmdrv): Timeout(%d sec),didn't get tune ended int\n,
+  jiffies_to_msecs(FM_DRV_TX_TIMEOUT) / 1000);
+   return -ETIMEDOUT;
+   }
+
+   /* Read freq 

[RFC v5 7/9] drivers:staging: ti-st: fmdrv_tx sources

2010-11-29 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

This has implementation for FM TX functionality.
It communicates with FM V4l2 module and FM common module.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
Signed-off-by: Bheemsen Kulkarni bheemsen_kulka...@ti.com
---
 drivers/staging/ti-st/fmdrv_tx.c |  420 ++
 drivers/staging/ti-st/fmdrv_tx.h |   37 
 2 files changed, 457 insertions(+), 0 deletions(-)
 create mode 100644 drivers/staging/ti-st/fmdrv_tx.c
 create mode 100644 drivers/staging/ti-st/fmdrv_tx.h

diff --git a/drivers/staging/ti-st/fmdrv_tx.c b/drivers/staging/ti-st/fmdrv_tx.c
new file mode 100644
index 000..c9e738e
--- /dev/null
+++ b/drivers/staging/ti-st/fmdrv_tx.c
@@ -0,0 +1,420 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *  This sub-module of FM driver implements FM TX functionality.
+ *
+ *  Copyright (C) 2010 Texas Instruments
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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/delay.h
+#include fmdrv.h
+#include fmdrv_common.h
+#include fmdrv_tx.h
+
+int fm_tx_set_stereo_mono(struct fmdrv_ops *fmdev, unsigned short mode)
+{
+   unsigned short payload;
+   int ret = 0;
+
+   if (fmdev-curr_fmmode != FM_MODE_TX)
+   return -EPERM;
+
+   if (fmdev-tx_data.aud_mode == mode)
+   return ret;
+
+   pr_debug(stereo mode: %d\n, mode);
+
+   /* Set Stereo/Mono mode */
+   payload = (1 - mode);
+   ret = fmc_send_cmd(fmdev, MONO_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   fmdev-tx_data.aud_mode = mode;
+
+   return ret;
+}
+
+static int __set_rds_text(struct fmdrv_ops *fmdev, unsigned char *rds_text)
+{
+   unsigned short payload;
+   int ret;
+
+   ret = fmc_send_cmd(fmdev, RDS_DATA_SET, REG_WR, rds_text,
+   strlen(rds_text), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Scroll mode */
+   payload = (unsigned short)0x1;
+   ret = fmc_send_cmd(fmdev, DISPLAY_MODE, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   return 0;
+}
+
+static int __set_rds_data_mode(struct fmdrv_ops *fmdev, unsigned char mode)
+{
+   unsigned short payload;
+   int ret;
+
+   /* Setting unique PI TODO: how unique? */
+   payload = (unsigned short)0xcafe;
+   ret = fmc_send_cmd(fmdev, PI_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* Set decoder id */
+   payload = (unsigned short)0xa;
+   ret = fmc_send_cmd(fmdev, DI_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* TODO: RDS_MODE_GET? */
+   return 0;
+}
+
+static int __set_rds_len(struct fmdrv_ops *fmdev, unsigned char type,
+   unsigned short len)
+{
+   unsigned short payload;
+   int ret;
+
+   len |= type  8;
+   payload = len;
+   ret = fmc_send_cmd(fmdev, RDS_CONFIG_DATA_SET, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  0)
+   return ret;
+
+   /* TODO: LENGTH_GET? */
+   return 0;
+}
+
+int fm_tx_set_rds_mode(struct fmdrv_ops *fmdev, unsigned char rds_en_dis)
+{
+   unsigned short payload;
+   int ret;
+   unsigned char rds_text[] = Zoom2\n;
+
+   if (fmdev-curr_fmmode != FM_MODE_TX)
+   return -EPERM;
+
+   pr_debug(rds_en_dis:%d(E:%d, D:%d)\n, rds_en_dis,
+  FM_RDS_ENABLE, FM_RDS_DISABLE);
+
+   if (rds_en_dis == FM_RDS_ENABLE) {
+   /* Set RDS length */
+   __set_rds_len(fmdev, 0, strlen(rds_text));
+
+   /* Set RDS text */
+   __set_rds_text(fmdev, rds_text);
+
+   /* Set RDS mode */
+   __set_rds_data_mode(fmdev, 0x0);
+   }
+
+   /* Send command to enable RDS */
+   if (rds_en_dis == FM_RDS_ENABLE)
+   payload = 0x01;
+   else
+   payload = 0x00;
+
+   ret = fmc_send_cmd(fmdev, RDS_DATA_ENB, REG_WR, payload,
+   sizeof(payload), NULL, NULL);
+   if (ret  

[RFC v5 9/9] driver:staging:ti-st: Update TODO for FM V4L2 driver.

2010-11-29 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/staging/ti-st/TODO |   17 -
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/ti-st/TODO b/drivers/staging/ti-st/TODO
index ebfd6bb..1d004cb 100644
--- a/drivers/staging/ti-st/TODO
+++ b/drivers/staging/ti-st/TODO
@@ -1,6 +1,21 @@
 TODO:
 
-1. Step up and maintain this driver to ensure that it continues
+1. Upstreaming BT driver
+
+2. Upstreaming FM driver
+
+   a. Use the new V4L2 control framework for all the V4L2 controls 
supported.
+
+   b. Change the interrupt handling mechanism as per comments by 'Hans 
Verkuil'.
+
+   c. Remove use of new V4L2 CID to set the BAND (US/JAPAN). Instead 
handle it
+   in driver.
+
+   d. Remove the new private CID defined for channel spacing instead 
handle it
+   in ioctl VIDIOC_S_HW_FREQ_SEEK.
+
+
+3. Step up and maintain this driver to ensure that it continues
 to work.  Having the hardware for this is pretty much a
 requirement.  If this does not happen, the will be removed in
 the 2.6.35 kernel release.
-- 
1.5.6.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC v5 8/9] drivers:staging: ti-st: Kconfig Makefile change

2010-11-29 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Add new menu option in Kconfig and compilation option in Makefile
for TI FM driver.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/staging/ti-st/Kconfig  |   10 ++
 drivers/staging/ti-st/Makefile |2 ++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/ti-st/Kconfig b/drivers/staging/ti-st/Kconfig
index 074b8e8..43b6dea 100644
--- a/drivers/staging/ti-st/Kconfig
+++ b/drivers/staging/ti-st/Kconfig
@@ -11,4 +11,14 @@ config ST_BT
  This enables the Bluetooth driver for TI BT/FM/GPS combo devices.
  This makes use of shared transport line discipline core driver to
  communicate with the BT core of the combo chip.
+
+config ST_FM
+tristate fm driver for ST
+depends on VIDEO_DEV  RFKILL
+select TI_ST
+help
+  This enables the FM driver for TI BT/FM/GPS combo devices.
+  This makes use of shared transport line discipline core driver to
+  communicate with the FM core of the combo chip.
+
 endmenu
diff --git a/drivers/staging/ti-st/Makefile b/drivers/staging/ti-st/Makefile
index 5f11b82..330f95b 100644
--- a/drivers/staging/ti-st/Makefile
+++ b/drivers/staging/ti-st/Makefile
@@ -3,3 +3,5 @@
 # and its protocol drivers (BT, FM, GPS)
 #
 obj-$(CONFIG_ST_BT)+= bt_drv.o
+obj-$(CONFIG_ST_FM)+= fm_drv.o
+fm_drv-objs:= fmdrv_common.o fmdrv_rx.o fmdrv_tx.o 
fmdrv_v4l2.o
-- 
1.5.6.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 0/6] FM V4L2 drivers for WL128x

2010-11-16 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

Mauro, Hans and the list,

This is the v4 version of the TI WL128x FM V4L2 drivers patchset.
Texas Instrument's WL128x chipset packs BT, FM, GPS and WLAN in a single
die with BT, FM and GPS being interfaced over a single UART.
This driver works on top of the shared transport line discipline driver.
This driver can also be made use for the WL127x version of the chip which packs
BT, FM and WLAN only.

Comments on the last version of the patches have been taken care,
such as
- New private CID for Channel Spacing added.
- FM Seek Wrap around support is also added.
- Few other style issues also taken care of.

Also,
Can you please also stage this version? Since the files are becoming big
to be posted as patches?
Currently there are few modifications which are supposed to go into videodev2.h
which have been added to generic header file to make it self-contained.

Thanks  Regards,
Manjunatha.

Manjunatha Halli (6):
  drivers:staging: ti-st: fmdrv common header file
  drivers:staging: ti-st: fmdrv_v4l2 sources
  drivers:staging: ti-st: fmdrv_common sources
  drivers:staging: ti-st: fmdrv_rx sources
  drivers:staging: ti-st: fmdrv_tx sources
  drivers:staging: ti-st: Kconfig  Makefile change

 drivers/staging/ti-st/Kconfig|   10 +
 drivers/staging/ti-st/Makefile   |2 +
 drivers/staging/ti-st/fmdrv.h|  259 
 drivers/staging/ti-st/fmdrv_common.c | 2141 ++
 drivers/staging/ti-st/fmdrv_common.h |  458 
 drivers/staging/ti-st/fmdrv_rx.c |  979 
 drivers/staging/ti-st/fmdrv_rx.h |   59 +
 drivers/staging/ti-st/fmdrv_tx.c |  461 
 drivers/staging/ti-st/fmdrv_tx.h |   37 +
 drivers/staging/ti-st/fmdrv_v4l2.c   |  757 
 drivers/staging/ti-st/fmdrv_v4l2.h   |   32 +
 11 files changed, 5195 insertions(+), 0 deletions(-)
 create mode 100644 drivers/staging/ti-st/fmdrv.h
 create mode 100644 drivers/staging/ti-st/fmdrv_common.c
 create mode 100644 drivers/staging/ti-st/fmdrv_common.h
 create mode 100644 drivers/staging/ti-st/fmdrv_rx.c
 create mode 100644 drivers/staging/ti-st/fmdrv_rx.h
 create mode 100644 drivers/staging/ti-st/fmdrv_tx.c
 create mode 100644 drivers/staging/ti-st/fmdrv_tx.h
 create mode 100644 drivers/staging/ti-st/fmdrv_v4l2.c
 create mode 100644 drivers/staging/ti-st/fmdrv_v4l2.h

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 5/6] drivers:staging: ti-st: fmdrv_tx sources

2010-11-16 Thread manjunatha_halli
From: Manjunatha Halli manjunatha_ha...@ti.com

This has implementation for FM TX functionality.
It communicates with FM V4l2 module and FM common module.

Signed-off-by: Manjunatha Halli manjunatha_ha...@ti.com
---
 drivers/staging/ti-st/fmdrv_tx.c |  461 ++
 drivers/staging/ti-st/fmdrv_tx.h |   37 +++
 2 files changed, 498 insertions(+), 0 deletions(-)
 create mode 100644 drivers/staging/ti-st/fmdrv_tx.c
 create mode 100644 drivers/staging/ti-st/fmdrv_tx.h

diff --git a/drivers/staging/ti-st/fmdrv_tx.c b/drivers/staging/ti-st/fmdrv_tx.c
new file mode 100644
index 000..7850d19
--- /dev/null
+++ b/drivers/staging/ti-st/fmdrv_tx.c
@@ -0,0 +1,461 @@
+/*
+ *  FM Driver for Connectivity chip of Texas Instruments.
+ *  This sub-module of FM driver implements FM TX functionality.
+ *
+ *  Copyright (C) 2010 Texas Instruments
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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/delay.h
+#include fmdrv.h
+#include fmdrv_common.h
+#include fmdrv_tx.h
+
+int fm_tx_set_stereo_mono(struct fmdrv_ops *fmdev, unsigned short mode)
+{
+   unsigned short payload;
+   int ret = 0;
+
+   if (fmdev-curr_fmmode != FM_MODE_TX)
+   return -EPERM;
+
+   if (fmdev-tx_data.aud_mode == mode)
+   return ret;
+
+   pr_debug(stereo mode: %d\n, mode);
+
+   /* Set Stereo/Mono mode */
+   FM_STORE_LE16_TO_BE16(payload, (1 - mode));
+   ret = fmc_send_cmd(fmdev, MONO_SET, payload, sizeof(payload),
+   fmdev-maintask_completion, NULL, NULL);
+   if (ret  0) {
+   pr_err((fmdrv): Failed to set TX stereo/mono mode - %d\n,
+   ret);
+   return ret;
+   }
+
+   fmdev-tx_data.aud_mode = mode;
+
+   return ret;
+}
+
+static int __set_rds_text(struct fmdrv_ops *fmdev, unsigned char *rds_text)
+{
+   unsigned short payload;
+   int ret;
+
+   ret = fmc_send_cmd(fmdev, RDS_DATA_SET, rds_text, strlen(rds_text),
+   fmdev-maintask_completion, NULL, NULL);
+   if (ret  0) {
+   pr_err((fmdrv): Failed to set TX RDS data - %d\n, ret);
+   return ret;
+   }
+
+   /* Scroll mode */
+   FM_STORE_LE16_TO_BE16(payload, (unsigned short)0x1);
+   ret = fmc_send_cmd(fmdev, DISPLAY_MODE_SET, payload, sizeof(payload),
+   fmdev-maintask_completion, NULL, NULL);
+   if (ret  0) {
+   pr_err((fmdrv): Failed to set RDS display mode - %d\n, ret);
+   return ret;
+   }
+
+   return 0;
+}
+
+static int __set_rds_data_mode(struct fmdrv_ops *fmdev, unsigned char mode)
+{
+   unsigned short payload;
+   int ret;
+
+   /* Setting unique PI TODO: how unique? */
+   FM_STORE_LE16_TO_BE16(payload, (unsigned short)0xcafe);
+   ret = fmc_send_cmd(fmdev, PI_SET, payload, sizeof(payload),
+   fmdev-maintask_completion, NULL, NULL);
+   if (ret  0) {
+   pr_err((fmdrv): Failed to set PI - %d\n, ret);
+   return ret;
+   }
+
+   /* Set decoder id */
+   FM_STORE_LE16_TO_BE16(payload, (unsigned short)0xa);
+   ret = fmc_send_cmd(fmdev, DI_SET, payload, sizeof(payload),
+   fmdev-maintask_completion, NULL, NULL);
+   if (ret  0) {
+   pr_err((fmdrv): Failed to set DI - %d\n, ret);
+   return ret;
+   }
+
+   /* TODO: RDS_MODE_GET? */
+   return 0;
+}
+
+static int __set_rds_len(struct fmdrv_ops *fmdev, unsigned char type,
+   unsigned short len)
+{
+   unsigned short payload;
+   int ret;
+
+   len |= type  8;
+   FM_STORE_LE16_TO_BE16(payload, len);
+   ret = fmc_send_cmd(fmdev, LENGTH_SET, payload, sizeof(payload),
+   fmdev-maintask_completion, NULL, NULL);
+   if (ret  0) {
+   pr_err((fmdrv): Failed to set RDS data length - %d\n, ret);
+   return ret;
+   }
+
+   /* TODO: LENGTH_GET? */
+   return 0;
+}
+
+int fm_tx_set_rds_mode(struct fmdrv_ops *fmdev, unsigned char rds_en_dis)
+{
+   unsigned short payload;
+   int ret;
+   unsigned char rds_text[] = Zoom2\n;
+
+   if (fmdev-curr_fmmode != FM_MODE_TX)
+   return 

  1   2   >