Commit 03aa1bcd authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] radio-si4713: convert to the control framework

Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Acked-by: default avatarEduardo Valentin <edubezval@gmail.com>
Tested-by: default avatarEduardo Valentin <edubezval@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent b387754d
...@@ -76,61 +76,6 @@ static int radio_si4713_querycap(struct file *file, void *priv, ...@@ -76,61 +76,6 @@ static int radio_si4713_querycap(struct file *file, void *priv,
return 0; return 0;
} }
/* radio_si4713_queryctrl - enumerate control items */
static int radio_si4713_queryctrl(struct file *file, void *priv,
struct v4l2_queryctrl *qc)
{
/* Must be sorted from low to high control ID! */
static const u32 user_ctrls[] = {
V4L2_CID_USER_CLASS,
V4L2_CID_AUDIO_MUTE,
0
};
/* Must be sorted from low to high control ID! */
static const u32 fmtx_ctrls[] = {
V4L2_CID_FM_TX_CLASS,
V4L2_CID_RDS_TX_DEVIATION,
V4L2_CID_RDS_TX_PI,
V4L2_CID_RDS_TX_PTY,
V4L2_CID_RDS_TX_PS_NAME,
V4L2_CID_RDS_TX_RADIO_TEXT,
V4L2_CID_AUDIO_LIMITER_ENABLED,
V4L2_CID_AUDIO_LIMITER_RELEASE_TIME,
V4L2_CID_AUDIO_LIMITER_DEVIATION,
V4L2_CID_AUDIO_COMPRESSION_ENABLED,
V4L2_CID_AUDIO_COMPRESSION_GAIN,
V4L2_CID_AUDIO_COMPRESSION_THRESHOLD,
V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME,
V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME,
V4L2_CID_PILOT_TONE_ENABLED,
V4L2_CID_PILOT_TONE_DEVIATION,
V4L2_CID_PILOT_TONE_FREQUENCY,
V4L2_CID_TUNE_PREEMPHASIS,
V4L2_CID_TUNE_POWER_LEVEL,
V4L2_CID_TUNE_ANTENNA_CAPACITOR,
0
};
static const u32 *ctrl_classes[] = {
user_ctrls,
fmtx_ctrls,
NULL
};
struct radio_si4713_device *rsdev;
rsdev = video_get_drvdata(video_devdata(file));
qc->id = v4l2_ctrl_next(ctrl_classes, qc->id);
if (qc->id == 0)
return -EINVAL;
if (qc->id == V4L2_CID_USER_CLASS || qc->id == V4L2_CID_FM_TX_CLASS)
return v4l2_ctrl_query_fill(qc, 0, 0, 0, 0);
return v4l2_device_call_until_err(&rsdev->v4l2_dev, 0, core,
queryctrl, qc);
}
/* /*
* v4l2 ioctl call backs. * v4l2 ioctl call backs.
* we are just a wrapper for v4l2_sub_devs. * we are just a wrapper for v4l2_sub_devs.
...@@ -140,34 +85,6 @@ static inline struct v4l2_device *get_v4l2_dev(struct file *file) ...@@ -140,34 +85,6 @@ static inline struct v4l2_device *get_v4l2_dev(struct file *file)
return &((struct radio_si4713_device *)video_drvdata(file))->v4l2_dev; return &((struct radio_si4713_device *)video_drvdata(file))->v4l2_dev;
} }
static int radio_si4713_g_ext_ctrls(struct file *file, void *p,
struct v4l2_ext_controls *vecs)
{
return v4l2_device_call_until_err(get_v4l2_dev(file), 0, core,
g_ext_ctrls, vecs);
}
static int radio_si4713_s_ext_ctrls(struct file *file, void *p,
struct v4l2_ext_controls *vecs)
{
return v4l2_device_call_until_err(get_v4l2_dev(file), 0, core,
s_ext_ctrls, vecs);
}
static int radio_si4713_g_ctrl(struct file *file, void *p,
struct v4l2_control *vc)
{
return v4l2_device_call_until_err(get_v4l2_dev(file), 0, core,
g_ctrl, vc);
}
static int radio_si4713_s_ctrl(struct file *file, void *p,
struct v4l2_control *vc)
{
return v4l2_device_call_until_err(get_v4l2_dev(file), 0, core,
s_ctrl, vc);
}
static int radio_si4713_g_modulator(struct file *file, void *p, static int radio_si4713_g_modulator(struct file *file, void *p,
struct v4l2_modulator *vm) struct v4l2_modulator *vm)
{ {
...@@ -205,11 +122,6 @@ static long radio_si4713_default(struct file *file, void *p, ...@@ -205,11 +122,6 @@ static long radio_si4713_default(struct file *file, void *p,
static struct v4l2_ioctl_ops radio_si4713_ioctl_ops = { static struct v4l2_ioctl_ops radio_si4713_ioctl_ops = {
.vidioc_querycap = radio_si4713_querycap, .vidioc_querycap = radio_si4713_querycap,
.vidioc_queryctrl = radio_si4713_queryctrl,
.vidioc_g_ext_ctrls = radio_si4713_g_ext_ctrls,
.vidioc_s_ext_ctrls = radio_si4713_s_ext_ctrls,
.vidioc_g_ctrl = radio_si4713_g_ctrl,
.vidioc_s_ctrl = radio_si4713_s_ctrl,
.vidioc_g_modulator = radio_si4713_g_modulator, .vidioc_g_modulator = radio_si4713_g_modulator,
.vidioc_s_modulator = radio_si4713_s_modulator, .vidioc_s_modulator = radio_si4713_s_modulator,
.vidioc_g_frequency = radio_si4713_g_frequency, .vidioc_g_frequency = radio_si4713_g_frequency,
...@@ -274,6 +186,7 @@ static int radio_si4713_pdriver_probe(struct platform_device *pdev) ...@@ -274,6 +186,7 @@ static int radio_si4713_pdriver_probe(struct platform_device *pdev)
rsdev->radio_dev = radio_si4713_vdev_template; rsdev->radio_dev = radio_si4713_vdev_template;
rsdev->radio_dev.v4l2_dev = &rsdev->v4l2_dev; rsdev->radio_dev.v4l2_dev = &rsdev->v4l2_dev;
rsdev->radio_dev.ctrl_handler = sd->ctrl_handler;
/* Serialize all access to the si4713 */ /* Serialize all access to the si4713 */
rsdev->radio_dev.lock = &rsdev->lock; rsdev->radio_dev.lock = &rsdev->lock;
video_set_drvdata(&rsdev->radio_dev, rsdev); video_set_drvdata(&rsdev->radio_dev, rsdev);
......
This diff is collapsed.
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#define SI4713_I2C_H #define SI4713_I2C_H
#include <media/v4l2-subdev.h> #include <media/v4l2-subdev.h>
#include <media/v4l2-ctrls.h>
#include <media/si4713.h> #include <media/si4713.h>
#define SI4713_PRODUCT_NUMBER 0x0D #define SI4713_PRODUCT_NUMBER 0x0D
...@@ -160,56 +161,33 @@ ...@@ -160,56 +161,33 @@
#define POWER_UP 0x01 #define POWER_UP 0x01
#define POWER_DOWN 0x00 #define POWER_DOWN 0x00
struct rds_info {
u32 pi;
#define MAX_RDS_PTY 31 #define MAX_RDS_PTY 31
u32 pty;
#define MAX_RDS_DEVIATION 90000 #define MAX_RDS_DEVIATION 90000
u32 deviation;
/* /*
* PSNAME is known to be defined as 8 character sized (RDS Spec). * PSNAME is known to be defined as 8 character sized (RDS Spec).
* However, there is receivers which scroll PSNAME 8xN sized. * However, there is receivers which scroll PSNAME 8xN sized.
*/ */
#define MAX_RDS_PS_NAME 96 #define MAX_RDS_PS_NAME 96
u8 ps_name[MAX_RDS_PS_NAME + 1];
/* /*
* MAX_RDS_RADIO_TEXT is known to be defined as 32 (2A group) or 64 (2B group) * MAX_RDS_RADIO_TEXT is known to be defined as 32 (2A group) or 64 (2B group)
* character sized (RDS Spec). * character sized (RDS Spec).
* However, there is receivers which scroll them as well. * However, there is receivers which scroll them as well.
*/ */
#define MAX_RDS_RADIO_TEXT 384 #define MAX_RDS_RADIO_TEXT 384
u8 radio_text[MAX_RDS_RADIO_TEXT + 1];
u32 enabled;
};
struct limiter_info {
#define MAX_LIMITER_RELEASE_TIME 102390 #define MAX_LIMITER_RELEASE_TIME 102390
u32 release_time;
#define MAX_LIMITER_DEVIATION 90000 #define MAX_LIMITER_DEVIATION 90000
u32 deviation;
u32 enabled;
};
struct pilot_info {
#define MAX_PILOT_DEVIATION 90000 #define MAX_PILOT_DEVIATION 90000
u32 deviation;
#define MAX_PILOT_FREQUENCY 19000 #define MAX_PILOT_FREQUENCY 19000
u32 frequency;
u32 enabled;
};
struct acomp_info {
#define MAX_ACOMP_RELEASE_TIME 1000000 #define MAX_ACOMP_RELEASE_TIME 1000000
u32 release_time;
#define MAX_ACOMP_ATTACK_TIME 5000 #define MAX_ACOMP_ATTACK_TIME 5000
u32 attack_time;
#define MAX_ACOMP_THRESHOLD 0 #define MAX_ACOMP_THRESHOLD 0
#define MIN_ACOMP_THRESHOLD (-40) #define MIN_ACOMP_THRESHOLD (-40)
s32 threshold;
#define MAX_ACOMP_GAIN 20 #define MAX_ACOMP_GAIN 20
u32 gain;
u32 enabled;
};
#define SI4713_NUM_SUPPLIES 2 #define SI4713_NUM_SUPPLIES 2
...@@ -219,20 +197,41 @@ struct acomp_info { ...@@ -219,20 +197,41 @@ struct acomp_info {
struct si4713_device { struct si4713_device {
/* v4l2_subdev and i2c reference (v4l2_subdev priv data) */ /* v4l2_subdev and i2c reference (v4l2_subdev priv data) */
struct v4l2_subdev sd; struct v4l2_subdev sd;
struct v4l2_ctrl_handler ctrl_handler;
/* private data structures */ /* private data structures */
struct { /* si4713 control cluster */
/* This is one big cluster since the mute control
* powers off the device and after unmuting again all
* controls need to be set at once. The only way of doing
* that is by making it one big cluster. */
struct v4l2_ctrl *mute;
struct v4l2_ctrl *rds_ps_name;
struct v4l2_ctrl *rds_radio_text;
struct v4l2_ctrl *rds_pi;
struct v4l2_ctrl *rds_deviation;
struct v4l2_ctrl *rds_pty;
struct v4l2_ctrl *compression_enabled;
struct v4l2_ctrl *compression_threshold;
struct v4l2_ctrl *compression_gain;
struct v4l2_ctrl *compression_attack_time;
struct v4l2_ctrl *compression_release_time;
struct v4l2_ctrl *pilot_tone_enabled;
struct v4l2_ctrl *pilot_tone_freq;
struct v4l2_ctrl *pilot_tone_deviation;
struct v4l2_ctrl *limiter_enabled;
struct v4l2_ctrl *limiter_deviation;
struct v4l2_ctrl *limiter_release_time;
struct v4l2_ctrl *tune_preemphasis;
struct v4l2_ctrl *tune_pwr_level;
struct v4l2_ctrl *tune_ant_cap;
};
struct completion work; struct completion work;
struct rds_info rds_info;
struct limiter_info limiter_info;
struct pilot_info pilot_info;
struct acomp_info acomp_info;
struct regulator_bulk_data supplies[SI4713_NUM_SUPPLIES]; struct regulator_bulk_data supplies[SI4713_NUM_SUPPLIES];
int gpio_reset; int gpio_reset;
u32 power_state;
u32 rds_enabled;
u32 frequency; u32 frequency;
u32 preemphasis; u32 preemphasis;
u32 mute;
u32 power_level;
u32 power_state;
u32 antenna_capacitor;
u32 stereo; u32 stereo;
u32 tune_rnl; u32 tune_rnl;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment