Commit c05c0462 authored by Mike Isely's avatar Mike Isely Committed by Mauro Carvalho Chehab

V4L/DVB (4236): Rearrange things in pvrusb2 driver in preparation for using cx2341x module

Signed-off-by: default avatarMike Isely <isely@pobox.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 3948199e
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include <linux/device.h> // for linux/firmware.h #include <linux/device.h> // for linux/firmware.h
#include <linux/firmware.h> #include <linux/firmware.h>
#include <linux/videodev2.h>
#include <media/cx2341x.h>
#include "pvrusb2-util.h" #include "pvrusb2-util.h"
#include "pvrusb2-encoder.h" #include "pvrusb2-encoder.h"
#include "pvrusb2-hdw-internal.h" #include "pvrusb2-hdw-internal.h"
...@@ -166,6 +164,7 @@ static int pvr2_encoder_cmd(void *ctxt, ...@@ -166,6 +164,7 @@ static int pvr2_encoder_cmd(void *ctxt,
u32 rdData[16]; u32 rdData[16];
struct pvr2_hdw *hdw = (struct pvr2_hdw *)ctxt; struct pvr2_hdw *hdw = (struct pvr2_hdw *)ctxt;
/* /*
The encoder seems to speak entirely using blocks 32 bit words. The encoder seems to speak entirely using blocks 32 bit words.
...@@ -339,7 +338,7 @@ int pvr2_encoder_configure(struct pvr2_hdw *hdw) ...@@ -339,7 +338,7 @@ int pvr2_encoder_configure(struct pvr2_hdw *hdw)
is_30fps=0; is_30fps=0;
} }
pvr2_trace(PVR2_TRACE_ENCODER,"pvr2_encoder_configure"); pvr2_trace(PVR2_TRACE_ENCODER,"pvr2_encoder_configure (native)");
/* set stream output port. Some notes here: The ivtv-derived /* set stream output port. Some notes here: The ivtv-derived
encoder documentation says that this command only gets a encoder documentation says that this command only gets a
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <linux/mutex.h> #include <linux/mutex.h>
#include "pvrusb2-hdw.h" #include "pvrusb2-hdw.h"
#include "pvrusb2-io.h" #include "pvrusb2-io.h"
#include <media/cx2341x.h>
/* Legal values for the SRATE state variable */ /* Legal values for the SRATE state variable */
#define PVR2_CVAL_SRATE_48 0 #define PVR2_CVAL_SRATE_48 0
...@@ -144,6 +145,13 @@ struct pvr2_ctl_info { ...@@ -144,6 +145,13 @@ struct pvr2_ctl_info {
}; };
/* Same as pvr2_ctl_info, but includes storage for the control description */
#define PVR2_CTLD_INFO_DESC_SIZE 32
struct pvr2_ctld_info {
struct pvr2_ctl_info info;
char desc[PVR2_CTLD_INFO_DESC_SIZE];
};
struct pvr2_ctrl { struct pvr2_ctrl {
const struct pvr2_ctl_info *info; const struct pvr2_ctl_info *info;
struct pvr2_hdw *hdw; struct pvr2_hdw *hdw;
...@@ -312,6 +320,7 @@ struct pvr2_hdw { ...@@ -312,6 +320,7 @@ struct pvr2_hdw {
int flag_bilingual; int flag_bilingual;
struct pvr2_audio_stat *audio_stat; struct pvr2_audio_stat *audio_stat;
/* Control state */ /* Control state */
#define VCREATE_DATA(lab) int lab##_val; int lab##_dirty #define VCREATE_DATA(lab) int lab##_val; int lab##_dirty
VCREATE_DATA(brightness); VCREATE_DATA(brightness);
...@@ -323,6 +332,10 @@ struct pvr2_hdw { ...@@ -323,6 +332,10 @@ struct pvr2_hdw {
VCREATE_DATA(bass); VCREATE_DATA(bass);
VCREATE_DATA(treble); VCREATE_DATA(treble);
VCREATE_DATA(mute); VCREATE_DATA(mute);
VCREATE_DATA(input);
VCREATE_DATA(audiomode);
VCREATE_DATA(res_hor);
VCREATE_DATA(res_ver);
VCREATE_DATA(srate); VCREATE_DATA(srate);
VCREATE_DATA(audiobitrate); VCREATE_DATA(audiobitrate);
VCREATE_DATA(audiocrc); VCREATE_DATA(audiocrc);
...@@ -330,15 +343,13 @@ struct pvr2_hdw { ...@@ -330,15 +343,13 @@ struct pvr2_hdw {
VCREATE_DATA(vbr); VCREATE_DATA(vbr);
VCREATE_DATA(videobitrate); VCREATE_DATA(videobitrate);
VCREATE_DATA(videopeak); VCREATE_DATA(videopeak);
VCREATE_DATA(input);
VCREATE_DATA(audiomode);
VCREATE_DATA(res_hor);
VCREATE_DATA(res_ver);
VCREATE_DATA(interlace); VCREATE_DATA(interlace);
VCREATE_DATA(audiolayer); VCREATE_DATA(audiolayer);
#undef VCREATE_DATA #undef VCREATE_DATA
struct pvr2_ctrl *controls; struct pvr2_ctrl *controls;
unsigned int control_cnt;
}; };
int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw); int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw);
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include <linux/firmware.h> #include <linux/firmware.h>
#include <linux/videodev2.h> #include <linux/videodev2.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <media/cx2341x.h>
#include "pvrusb2.h" #include "pvrusb2.h"
#include "pvrusb2-std.h" #include "pvrusb2-std.h"
#include "pvrusb2-util.h" #include "pvrusb2-util.h"
...@@ -131,6 +130,7 @@ MODULE_PARM_DESC(tolerance,"specify stream error tolerance"); ...@@ -131,6 +130,7 @@ MODULE_PARM_DESC(tolerance,"specify stream error tolerance");
/* size of a firmware chunk */ /* size of a firmware chunk */
#define FIRMWARE_CHUNK_SIZE 0x2000 #define FIRMWARE_CHUNK_SIZE 0x2000
static const char *control_values_srate[] = { static const char *control_values_srate[] = {
[PVR2_CVAL_SRATE_48] = "48KHz", [PVR2_CVAL_SRATE_48] = "48KHz",
[PVR2_CVAL_SRATE_44_1] = "44.1KHz", [PVR2_CVAL_SRATE_44_1] = "44.1KHz",
...@@ -467,6 +467,10 @@ VCREATE_FUNCS(balance) ...@@ -467,6 +467,10 @@ VCREATE_FUNCS(balance)
VCREATE_FUNCS(bass) VCREATE_FUNCS(bass)
VCREATE_FUNCS(treble) VCREATE_FUNCS(treble)
VCREATE_FUNCS(mute) VCREATE_FUNCS(mute)
VCREATE_FUNCS(input)
VCREATE_FUNCS(audiomode)
VCREATE_FUNCS(res_hor)
VCREATE_FUNCS(res_ver)
VCREATE_FUNCS(srate) VCREATE_FUNCS(srate)
VCREATE_FUNCS(audiobitrate) VCREATE_FUNCS(audiobitrate)
VCREATE_FUNCS(audiocrc) VCREATE_FUNCS(audiocrc)
...@@ -474,10 +478,6 @@ VCREATE_FUNCS(audioemphasis) ...@@ -474,10 +478,6 @@ VCREATE_FUNCS(audioemphasis)
VCREATE_FUNCS(vbr) VCREATE_FUNCS(vbr)
VCREATE_FUNCS(videobitrate) VCREATE_FUNCS(videobitrate)
VCREATE_FUNCS(videopeak) VCREATE_FUNCS(videopeak)
VCREATE_FUNCS(input)
VCREATE_FUNCS(audiomode)
VCREATE_FUNCS(res_hor)
VCREATE_FUNCS(res_ver)
VCREATE_FUNCS(interlace) VCREATE_FUNCS(interlace)
VCREATE_FUNCS(audiolayer) VCREATE_FUNCS(audiolayer)
...@@ -549,6 +549,34 @@ static const struct pvr2_ctl_info control_defs[] = { ...@@ -549,6 +549,34 @@ static const struct pvr2_ctl_info control_defs[] = {
.default_value = 0, .default_value = 0,
DEFREF(mute), DEFREF(mute),
DEFINT(0,1), DEFINT(0,1),
},{
.desc = "Video Source",
.name = "input",
.internal_id = PVR2_CID_INPUT,
.default_value = PVR2_CVAL_INPUT_TV,
DEFREF(input),
DEFENUM(control_values_input),
},{
.desc = "Audio Mode",
.name = "audio_mode",
.internal_id = PVR2_CID_AUDIOMODE,
.default_value = V4L2_TUNER_MODE_STEREO,
DEFREF(audiomode),
DEFENUM(control_values_audiomode),
},{
.desc = "Horizontal capture resolution",
.name = "resolution_hor",
.internal_id = PVR2_CID_HRES,
.default_value = 720,
DEFREF(res_hor),
DEFINT(320,720),
},{
.desc = "Vertical capture resolution",
.name = "resolution_ver",
.internal_id = PVR2_CID_VRES,
.default_value = 480,
DEFREF(res_ver),
DEFINT(200,625),
},{ },{
.v4l_id = V4L2_CID_PVR_SRATE, .v4l_id = V4L2_CID_PVR_SRATE,
.desc = "Sample rate", .desc = "Sample rate",
...@@ -570,12 +598,6 @@ static const struct pvr2_ctl_info control_defs[] = { ...@@ -570,12 +598,6 @@ static const struct pvr2_ctl_info control_defs[] = {
.default_value = 1, .default_value = 1,
DEFREF(audiocrc), DEFREF(audiocrc),
DEFINT(0,1), DEFINT(0,1),
},{
.desc = "Audio Layer",
.name = "audio_layer",
.default_value = 2,
DEFREF(audiolayer),
DEFINT(0,3),
},{ },{
.v4l_id = V4L2_CID_PVR_AUDIOEMPHASIS, .v4l_id = V4L2_CID_PVR_AUDIOEMPHASIS,
.desc = "Audio Emphasis", .desc = "Audio Emphasis",
...@@ -583,13 +605,6 @@ static const struct pvr2_ctl_info control_defs[] = { ...@@ -583,13 +605,6 @@ static const struct pvr2_ctl_info control_defs[] = {
.default_value = PVR2_CVAL_AUDIOEMPHASIS_NONE, .default_value = PVR2_CVAL_AUDIOEMPHASIS_NONE,
DEFREF(audioemphasis), DEFREF(audioemphasis),
DEFENUM(control_values_audioemphasis), DEFENUM(control_values_audioemphasis),
},{
.desc = "Interlace mode",
.name = "interlace",
.internal_id = PVR2_CID_INTERLACE,
.default_value = 0,
DEFREF(interlace),
DEFINT(0,1),
},{ },{
.v4l_id = V4L2_CID_PVR_VBR, .v4l_id = V4L2_CID_PVR_VBR,
.desc = "Variable video bitrate", .desc = "Variable video bitrate",
...@@ -612,19 +627,18 @@ static const struct pvr2_ctl_info control_defs[] = { ...@@ -612,19 +627,18 @@ static const struct pvr2_ctl_info control_defs[] = {
DEFREF(videopeak), DEFREF(videopeak),
DEFINT(500000,20000000), DEFINT(500000,20000000),
},{ },{
.desc = "Video Source", .desc = "Interlace mode",
.name = "input", .name = "interlace",
.internal_id = PVR2_CID_INPUT, .internal_id = PVR2_CID_INTERLACE,
.default_value = PVR2_CVAL_INPUT_TV, .default_value = 0,
DEFREF(input), DEFREF(interlace),
DEFENUM(control_values_input), DEFINT(0,1),
},{ },{
.desc = "Audio Mode", .desc = "Audio Layer",
.name = "audio_mode", .name = "audio_layer",
.internal_id = PVR2_CID_AUDIOMODE, .default_value = 2,
.default_value = V4L2_TUNER_MODE_STEREO, DEFREF(audiolayer),
DEFREF(audiomode), DEFINT(0,3),
DEFENUM(control_values_audiomode),
},{ },{
.desc = "Tuner Frequency (Hz)", .desc = "Tuner Frequency (Hz)",
.name = "frequency", .name = "frequency",
...@@ -653,20 +667,6 @@ static const struct pvr2_ctl_info control_defs[] = { ...@@ -653,20 +667,6 @@ static const struct pvr2_ctl_info control_defs[] = {
.set_value = ctrl_channelprog_set, .set_value = ctrl_channelprog_set,
.get_value = ctrl_channelprog_get, .get_value = ctrl_channelprog_get,
DEFINT(0,FREQTABLE_SIZE), DEFINT(0,FREQTABLE_SIZE),
},{
.desc = "Horizontal capture resolution",
.name = "resolution_hor",
.internal_id = PVR2_CID_HRES,
.default_value = 720,
DEFREF(res_hor),
DEFINT(320,720),
},{
.desc = "Vertical capture resolution",
.name = "resolution_ver",
.internal_id = PVR2_CID_VRES,
.default_value = 480,
DEFREF(res_ver),
DEFINT(200,625),
},{ },{
.desc = "Streaming Enabled", .desc = "Streaming Enabled",
.name = "streaming_enabled", .name = "streaming_enabled",
...@@ -731,7 +731,7 @@ static const struct pvr2_ctl_info control_defs[] = { ...@@ -731,7 +731,7 @@ static const struct pvr2_ctl_info control_defs[] = {
} }
}; };
#define CTRL_COUNT (sizeof(control_defs)/sizeof(control_defs[0])) #define CTRLDEF_COUNT (sizeof(control_defs)/sizeof(control_defs[0]))
const char *pvr2_config_get_name(enum pvr2_config cfg) const char *pvr2_config_get_name(enum pvr2_config cfg)
...@@ -1508,7 +1508,7 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw) ...@@ -1508,7 +1508,7 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
pvr2_i2c_core_init(hdw); pvr2_i2c_core_init(hdw);
if (!pvr2_hdw_dev_ok(hdw)) return; if (!pvr2_hdw_dev_ok(hdw)) return;
for (idx = 0; idx < CTRL_COUNT; idx++) { for (idx = 0; idx < CTRLDEF_COUNT; idx++) {
cptr = hdw->controls + idx; cptr = hdw->controls + idx;
if (cptr->info->skip_init) continue; if (cptr->info->skip_init) continue;
if (!cptr->info->set_value) continue; if (!cptr->info->set_value) continue;
...@@ -1665,19 +1665,21 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, ...@@ -1665,19 +1665,21 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
if (!hdw) goto fail; if (!hdw) goto fail;
memset(hdw,0,sizeof(*hdw)); memset(hdw,0,sizeof(*hdw));
hdw->controls = kmalloc(sizeof(struct pvr2_ctrl) * CTRL_COUNT, hdw->control_cnt = CTRLDEF_COUNT;
hdw->controls = kmalloc(sizeof(struct pvr2_ctrl) * hdw->control_cnt,
GFP_KERNEL); GFP_KERNEL);
if (!hdw->controls) goto fail; if (!hdw->controls) goto fail;
memset(hdw->controls,0,sizeof(struct pvr2_ctrl) * CTRL_COUNT); memset(hdw->controls,0,sizeof(struct pvr2_ctrl) * hdw->control_cnt);
hdw->hdw_type = hdw_type; hdw->hdw_type = hdw_type;
for (idx = 0; idx < hdw->control_cnt; idx++) {
cptr = hdw->controls + idx;
cptr->hdw = hdw;
}
for (idx = 0; idx < 32; idx++) { for (idx = 0; idx < 32; idx++) {
hdw->std_mask_ptrs[idx] = hdw->std_mask_names[idx]; hdw->std_mask_ptrs[idx] = hdw->std_mask_names[idx];
} }
for (idx = 0; idx < CTRLDEF_COUNT; idx++) {
for (idx = 0; idx < CTRL_COUNT; idx++) {
cptr = hdw->controls + idx; cptr = hdw->controls + idx;
cptr->hdw = hdw;
cptr->info = control_defs+idx; cptr->info = control_defs+idx;
} }
...@@ -1846,7 +1848,7 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw) ...@@ -1846,7 +1848,7 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw)
unit_pointers[hdw->unit_number] = 0; unit_pointers[hdw->unit_number] = 0;
} }
} while (0); up(&pvr2_unit_sem); } while (0); up(&pvr2_unit_sem);
kfree(hdw->controls); if (hdw->controls) kfree(hdw->controls);
if (hdw->std_defs) kfree(hdw->std_defs); if (hdw->std_defs) kfree(hdw->std_defs);
if (hdw->std_enum_names) kfree(hdw->std_enum_names); if (hdw->std_enum_names) kfree(hdw->std_enum_names);
kfree(hdw); kfree(hdw);
...@@ -1952,7 +1954,7 @@ int pvr2_hdw_get_stdenum_value(struct pvr2_hdw *hdw, ...@@ -1952,7 +1954,7 @@ int pvr2_hdw_get_stdenum_value(struct pvr2_hdw *hdw,
/* Get the number of defined controls */ /* Get the number of defined controls */
unsigned int pvr2_hdw_get_ctrl_count(struct pvr2_hdw *hdw) unsigned int pvr2_hdw_get_ctrl_count(struct pvr2_hdw *hdw)
{ {
return CTRL_COUNT; return hdw->control_cnt;
} }
...@@ -1960,7 +1962,7 @@ unsigned int pvr2_hdw_get_ctrl_count(struct pvr2_hdw *hdw) ...@@ -1960,7 +1962,7 @@ unsigned int pvr2_hdw_get_ctrl_count(struct pvr2_hdw *hdw)
struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_index(struct pvr2_hdw *hdw, struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_index(struct pvr2_hdw *hdw,
unsigned int idx) unsigned int idx)
{ {
if (idx >= CTRL_COUNT) return 0; if (idx >= hdw->control_cnt) return 0;
return hdw->controls + idx; return hdw->controls + idx;
} }
...@@ -1974,7 +1976,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_id(struct pvr2_hdw *hdw, ...@@ -1974,7 +1976,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_id(struct pvr2_hdw *hdw,
int i; int i;
/* This could be made a lot more efficient, but for now... */ /* This could be made a lot more efficient, but for now... */
for (idx = 0; idx < CTRL_COUNT; idx++) { for (idx = 0; idx < hdw->control_cnt; idx++) {
cptr = hdw->controls + idx; cptr = hdw->controls + idx;
i = cptr->info->internal_id; i = cptr->info->internal_id;
if (i && (i == ctl_id)) return cptr; if (i && (i == ctl_id)) return cptr;
...@@ -1991,7 +1993,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_v4l(struct pvr2_hdw *hdw,unsigned int ctl_id ...@@ -1991,7 +1993,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_v4l(struct pvr2_hdw *hdw,unsigned int ctl_id
int i; int i;
/* This could be made a lot more efficient, but for now... */ /* This could be made a lot more efficient, but for now... */
for (idx = 0; idx < CTRL_COUNT; idx++) { for (idx = 0; idx < hdw->control_cnt; idx++) {
cptr = hdw->controls + idx; cptr = hdw->controls + idx;
i = cptr->info->v4l_id; i = cptr->info->v4l_id;
if (i && (i == ctl_id)) return cptr; if (i && (i == ctl_id)) return cptr;
...@@ -2029,7 +2031,7 @@ int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw) ...@@ -2029,7 +2031,7 @@ int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw)
char buf[100]; char buf[100];
unsigned int bcnt,ccnt; unsigned int bcnt,ccnt;
for (idx = 0; idx < CTRL_COUNT; idx++) { for (idx = 0; idx < hdw->control_cnt; idx++) {
cptr = hdw->controls + idx; cptr = hdw->controls + idx;
if (cptr->info->is_dirty == 0) continue; if (cptr->info->is_dirty == 0) continue;
if (!cptr->info->is_dirty(cptr)) continue; if (!cptr->info->is_dirty(cptr)) continue;
...@@ -2080,30 +2082,31 @@ int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw) ...@@ -2080,30 +2082,31 @@ int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw)
} }
if (hdw->std_dirty || if (hdw->std_dirty ||
hdw->res_ver_dirty ||
hdw->res_hor_dirty ||
hdw->interlace_dirty || hdw->interlace_dirty ||
hdw->vbr_dirty || hdw->vbr_dirty ||
hdw->videobitrate_dirty || hdw->videobitrate_dirty ||
hdw->videopeak_dirty || hdw->videopeak_dirty ||
hdw->audiobitrate_dirty || hdw->audiobitrate_dirty ||
hdw->srate_dirty ||
hdw->audiolayer_dirty || hdw->audiolayer_dirty ||
hdw->audiocrc_dirty || hdw->audiocrc_dirty ||
hdw->audioemphasis_dirty) { hdw->audioemphasis_dirty ||
hdw->srate_dirty ||
hdw->res_ver_dirty ||
hdw->res_hor_dirty) {
/* If any of this changes, then the encoder needs to be /* If any of this changes, then the encoder needs to be
reconfigured, and we need to reset the stream. */ reconfigured, and we need to reset the stream. */
stale_subsys_mask |= (1<<PVR2_SUBSYS_B_ENC_CFG); stale_subsys_mask |= (1<<PVR2_SUBSYS_B_ENC_CFG);
stale_subsys_mask |= hdw->subsys_stream_mask; stale_subsys_mask |= hdw->subsys_stream_mask;
} }
/* Scan i2c core at this point - before we clear all the dirty /* Scan i2c core at this point - before we clear all the dirty
bits. Various parts of the i2c core will notice dirty bits as bits. Various parts of the i2c core will notice dirty bits as
appropriate and arrange to broadcast or directly send updates to appropriate and arrange to broadcast or directly send updates to
the client drivers in order to keep everything in sync */ the client drivers in order to keep everything in sync */
pvr2_i2c_core_check_stale(hdw); pvr2_i2c_core_check_stale(hdw);
for (idx = 0; idx < CTRL_COUNT; idx++) { for (idx = 0; idx < hdw->control_cnt; idx++) {
cptr = hdw->controls + idx; cptr = hdw->controls + idx;
if (!cptr->info->clear_dirty) continue; if (!cptr->info->clear_dirty) continue;
cptr->info->clear_dirty(cptr); cptr->info->clear_dirty(cptr);
......
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