Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 30835
b: refs/heads/master
c: c05c046
h: refs/heads/master
i:
  30833: 0cb5aed
  30831: 690ad7a
v: v3
  • Loading branch information
Mike Isely authored and Mauro Carvalho Chehab committed Jun 27, 2006
1 parent 9ea50af commit 070277f
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 71 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3948199e8aff71b1ebe3c1ff2749f42add17a41e
refs/heads/master: c05c0462da0e3aac70ec5316ea500f9a7499cca7
5 changes: 2 additions & 3 deletions trunk/drivers/media/video/pvrusb2/pvrusb2-encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

#include <linux/device.h> // for linux/firmware.h
#include <linux/firmware.h>
#include <linux/videodev2.h>
#include <media/cx2341x.h>
#include "pvrusb2-util.h"
#include "pvrusb2-encoder.h"
#include "pvrusb2-hdw-internal.h"
Expand Down Expand Up @@ -166,6 +164,7 @@ static int pvr2_encoder_cmd(void *ctxt,
u32 rdData[16];
struct pvr2_hdw *hdw = (struct pvr2_hdw *)ctxt;


/*
The encoder seems to speak entirely using blocks 32 bit words.
Expand Down Expand Up @@ -339,7 +338,7 @@ int pvr2_encoder_configure(struct pvr2_hdw *hdw)
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
encoder documentation says that this command only gets a
Expand Down
19 changes: 15 additions & 4 deletions trunk/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <linux/mutex.h>
#include "pvrusb2-hdw.h"
#include "pvrusb2-io.h"
#include <media/cx2341x.h>

/* Legal values for the SRATE state variable */
#define PVR2_CVAL_SRATE_48 0
Expand Down Expand Up @@ -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 {
const struct pvr2_ctl_info *info;
struct pvr2_hdw *hdw;
Expand Down Expand Up @@ -312,6 +320,7 @@ struct pvr2_hdw {
int flag_bilingual;
struct pvr2_audio_stat *audio_stat;


/* Control state */
#define VCREATE_DATA(lab) int lab##_val; int lab##_dirty
VCREATE_DATA(brightness);
Expand All @@ -323,22 +332,24 @@ struct pvr2_hdw {
VCREATE_DATA(bass);
VCREATE_DATA(treble);
VCREATE_DATA(mute);
VCREATE_DATA(input);
VCREATE_DATA(audiomode);
VCREATE_DATA(res_hor);
VCREATE_DATA(res_ver);
VCREATE_DATA(srate);
VCREATE_DATA(audiobitrate);
VCREATE_DATA(audiocrc);
VCREATE_DATA(audioemphasis);
VCREATE_DATA(vbr);
VCREATE_DATA(videobitrate);
VCREATE_DATA(videopeak);
VCREATE_DATA(input);
VCREATE_DATA(audiomode);
VCREATE_DATA(res_hor);
VCREATE_DATA(res_ver);
VCREATE_DATA(interlace);
VCREATE_DATA(audiolayer);
#undef VCREATE_DATA


struct pvr2_ctrl *controls;
unsigned int control_cnt;
};

int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw);
Expand Down
129 changes: 66 additions & 63 deletions trunk/drivers/media/video/pvrusb2/pvrusb2-hdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <linux/firmware.h>
#include <linux/videodev2.h>
#include <asm/semaphore.h>
#include <media/cx2341x.h>
#include "pvrusb2.h"
#include "pvrusb2-std.h"
#include "pvrusb2-util.h"
Expand Down Expand Up @@ -131,6 +130,7 @@ MODULE_PARM_DESC(tolerance,"specify stream error tolerance");
/* size of a firmware chunk */
#define FIRMWARE_CHUNK_SIZE 0x2000


static const char *control_values_srate[] = {
[PVR2_CVAL_SRATE_48] = "48KHz",
[PVR2_CVAL_SRATE_44_1] = "44.1KHz",
Expand Down Expand Up @@ -467,17 +467,17 @@ VCREATE_FUNCS(balance)
VCREATE_FUNCS(bass)
VCREATE_FUNCS(treble)
VCREATE_FUNCS(mute)
VCREATE_FUNCS(input)
VCREATE_FUNCS(audiomode)
VCREATE_FUNCS(res_hor)
VCREATE_FUNCS(res_ver)
VCREATE_FUNCS(srate)
VCREATE_FUNCS(audiobitrate)
VCREATE_FUNCS(audiocrc)
VCREATE_FUNCS(audioemphasis)
VCREATE_FUNCS(vbr)
VCREATE_FUNCS(videobitrate)
VCREATE_FUNCS(videopeak)
VCREATE_FUNCS(input)
VCREATE_FUNCS(audiomode)
VCREATE_FUNCS(res_hor)
VCREATE_FUNCS(res_ver)
VCREATE_FUNCS(interlace)
VCREATE_FUNCS(audiolayer)

Expand Down Expand Up @@ -549,6 +549,34 @@ static const struct pvr2_ctl_info control_defs[] = {
.default_value = 0,
DEFREF(mute),
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,
.desc = "Sample rate",
Expand All @@ -570,26 +598,13 @@ static const struct pvr2_ctl_info control_defs[] = {
.default_value = 1,
DEFREF(audiocrc),
DEFINT(0,1),
},{
.desc = "Audio Layer",
.name = "audio_layer",
.default_value = 2,
DEFREF(audiolayer),
DEFINT(0,3),
},{
.v4l_id = V4L2_CID_PVR_AUDIOEMPHASIS,
.desc = "Audio Emphasis",
.name = "audio_emphasis",
.default_value = PVR2_CVAL_AUDIOEMPHASIS_NONE,
DEFREF(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,
.desc = "Variable video bitrate",
Expand All @@ -612,19 +627,18 @@ static const struct pvr2_ctl_info control_defs[] = {
DEFREF(videopeak),
DEFINT(500000,20000000),
},{
.desc = "Video Source",
.name = "input",
.internal_id = PVR2_CID_INPUT,
.default_value = PVR2_CVAL_INPUT_TV,
DEFREF(input),
DEFENUM(control_values_input),
.desc = "Interlace mode",
.name = "interlace",
.internal_id = PVR2_CID_INTERLACE,
.default_value = 0,
DEFREF(interlace),
DEFINT(0,1),
},{
.desc = "Audio Mode",
.name = "audio_mode",
.internal_id = PVR2_CID_AUDIOMODE,
.default_value = V4L2_TUNER_MODE_STEREO,
DEFREF(audiomode),
DEFENUM(control_values_audiomode),
.desc = "Audio Layer",
.name = "audio_layer",
.default_value = 2,
DEFREF(audiolayer),
DEFINT(0,3),
},{
.desc = "Tuner Frequency (Hz)",
.name = "frequency",
Expand Down Expand Up @@ -653,20 +667,6 @@ static const struct pvr2_ctl_info control_defs[] = {
.set_value = ctrl_channelprog_set,
.get_value = ctrl_channelprog_get,
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",
.name = "streaming_enabled",
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1508,7 +1508,7 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
pvr2_i2c_core_init(hdw);
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;
if (cptr->info->skip_init) continue;
if (!cptr->info->set_value) continue;
Expand Down Expand Up @@ -1665,19 +1665,21 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
if (!hdw) goto fail;
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);
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;

for (idx = 0; idx < hdw->control_cnt; idx++) {
cptr = hdw->controls + idx;
cptr->hdw = hdw;
}
for (idx = 0; idx < 32; idx++) {
hdw->std_mask_ptrs[idx] = hdw->std_mask_names[idx];
}

for (idx = 0; idx < CTRL_COUNT; idx++) {
for (idx = 0; idx < CTRLDEF_COUNT; idx++) {
cptr = hdw->controls + idx;
cptr->hdw = hdw;
cptr->info = control_defs+idx;
}

Expand Down Expand Up @@ -1846,7 +1848,7 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw)
unit_pointers[hdw->unit_number] = 0;
}
} 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_enum_names) kfree(hdw->std_enum_names);
kfree(hdw);
Expand Down Expand Up @@ -1952,15 +1954,15 @@ int pvr2_hdw_get_stdenum_value(struct pvr2_hdw *hdw,
/* Get the number of defined controls */
unsigned int pvr2_hdw_get_ctrl_count(struct pvr2_hdw *hdw)
{
return CTRL_COUNT;
return hdw->control_cnt;
}


/* Retrieve a control handle given its index (0..count-1) */
struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_index(struct pvr2_hdw *hdw,
unsigned int idx)
{
if (idx >= CTRL_COUNT) return 0;
if (idx >= hdw->control_cnt) return 0;
return hdw->controls + idx;
}

Expand All @@ -1974,7 +1976,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_id(struct pvr2_hdw *hdw,
int i;

/* 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;
i = cptr->info->internal_id;
if (i && (i == ctl_id)) return cptr;
Expand All @@ -1991,7 +1993,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_v4l(struct pvr2_hdw *hdw,unsigned int ctl_id
int i;

/* 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;
i = cptr->info->v4l_id;
if (i && (i == ctl_id)) return cptr;
Expand Down Expand Up @@ -2029,7 +2031,7 @@ int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw)
char buf[100];
unsigned int bcnt,ccnt;

for (idx = 0; idx < CTRL_COUNT; idx++) {
for (idx = 0; idx < hdw->control_cnt; idx++) {
cptr = hdw->controls + idx;
if (cptr->info->is_dirty == 0) continue;
if (!cptr->info->is_dirty(cptr)) continue;
Expand Down Expand Up @@ -2080,30 +2082,31 @@ int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw)
}

if (hdw->std_dirty ||
hdw->res_ver_dirty ||
hdw->res_hor_dirty ||
hdw->interlace_dirty ||
hdw->vbr_dirty ||
hdw->videobitrate_dirty ||
hdw->videopeak_dirty ||
hdw->audiobitrate_dirty ||
hdw->srate_dirty ||
hdw->audiolayer_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
reconfigured, and we need to reset the stream. */
stale_subsys_mask |= (1<<PVR2_SUBSYS_B_ENC_CFG);
stale_subsys_mask |= hdw->subsys_stream_mask;
}


/* Scan i2c core at this point - before we clear all the dirty
bits. Various parts of the i2c core will notice dirty bits as
appropriate and arrange to broadcast or directly send updates to
the client drivers in order to keep everything in sync */
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;
if (!cptr->info->clear_dirty) continue;
cptr->info->clear_dirty(cptr);
Expand Down

0 comments on commit 070277f

Please sign in to comment.