aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pvrusb2/pvrusb2-hdw.c
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2006-06-25 19:04:25 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-06-26 23:17:23 -0400
commitc05c0462da0e3aac70ec5316ea500f9a7499cca7 (patch)
tree2879ef0856de3301cbb4bdc1ada44e433f7100cc /drivers/media/video/pvrusb2/pvrusb2-hdw.c
parent3948199e8aff71b1ebe3c1ff2749f42add17a41e (diff)
V4L/DVB (4236): Rearrange things in pvrusb2 driver in preparation for using cx2341x module
Signed-off-by: Mike Isely <isely@pobox.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-hdw.c')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c129
1 files changed, 66 insertions, 63 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index c1a2447d3ef7..e8ea472fe2d0 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -25,7 +25,6 @@
25#include <linux/firmware.h> 25#include <linux/firmware.h>
26#include <linux/videodev2.h> 26#include <linux/videodev2.h>
27#include <asm/semaphore.h> 27#include <asm/semaphore.h>
28#include <media/cx2341x.h>
29#include "pvrusb2.h" 28#include "pvrusb2.h"
30#include "pvrusb2-std.h" 29#include "pvrusb2-std.h"
31#include "pvrusb2-util.h" 30#include "pvrusb2-util.h"
@@ -131,6 +130,7 @@ MODULE_PARM_DESC(tolerance,"specify stream error tolerance");
131/* size of a firmware chunk */ 130/* size of a firmware chunk */
132#define FIRMWARE_CHUNK_SIZE 0x2000 131#define FIRMWARE_CHUNK_SIZE 0x2000
133 132
133
134static const char *control_values_srate[] = { 134static const char *control_values_srate[] = {
135 [PVR2_CVAL_SRATE_48] = "48KHz", 135 [PVR2_CVAL_SRATE_48] = "48KHz",
136 [PVR2_CVAL_SRATE_44_1] = "44.1KHz", 136 [PVR2_CVAL_SRATE_44_1] = "44.1KHz",
@@ -467,6 +467,10 @@ VCREATE_FUNCS(balance)
467VCREATE_FUNCS(bass) 467VCREATE_FUNCS(bass)
468VCREATE_FUNCS(treble) 468VCREATE_FUNCS(treble)
469VCREATE_FUNCS(mute) 469VCREATE_FUNCS(mute)
470VCREATE_FUNCS(input)
471VCREATE_FUNCS(audiomode)
472VCREATE_FUNCS(res_hor)
473VCREATE_FUNCS(res_ver)
470VCREATE_FUNCS(srate) 474VCREATE_FUNCS(srate)
471VCREATE_FUNCS(audiobitrate) 475VCREATE_FUNCS(audiobitrate)
472VCREATE_FUNCS(audiocrc) 476VCREATE_FUNCS(audiocrc)
@@ -474,10 +478,6 @@ VCREATE_FUNCS(audioemphasis)
474VCREATE_FUNCS(vbr) 478VCREATE_FUNCS(vbr)
475VCREATE_FUNCS(videobitrate) 479VCREATE_FUNCS(videobitrate)
476VCREATE_FUNCS(videopeak) 480VCREATE_FUNCS(videopeak)
477VCREATE_FUNCS(input)
478VCREATE_FUNCS(audiomode)
479VCREATE_FUNCS(res_hor)
480VCREATE_FUNCS(res_ver)
481VCREATE_FUNCS(interlace) 481VCREATE_FUNCS(interlace)
482VCREATE_FUNCS(audiolayer) 482VCREATE_FUNCS(audiolayer)
483 483
@@ -550,6 +550,34 @@ static const struct pvr2_ctl_info control_defs[] = {
550 DEFREF(mute), 550 DEFREF(mute),
551 DEFINT(0,1), 551 DEFINT(0,1),
552 },{ 552 },{
553 .desc = "Video Source",
554 .name = "input",
555 .internal_id = PVR2_CID_INPUT,
556 .default_value = PVR2_CVAL_INPUT_TV,
557 DEFREF(input),
558 DEFENUM(control_values_input),
559 },{
560 .desc = "Audio Mode",
561 .name = "audio_mode",
562 .internal_id = PVR2_CID_AUDIOMODE,
563 .default_value = V4L2_TUNER_MODE_STEREO,
564 DEFREF(audiomode),
565 DEFENUM(control_values_audiomode),
566 },{
567 .desc = "Horizontal capture resolution",
568 .name = "resolution_hor",
569 .internal_id = PVR2_CID_HRES,
570 .default_value = 720,
571 DEFREF(res_hor),
572 DEFINT(320,720),
573 },{
574 .desc = "Vertical capture resolution",
575 .name = "resolution_ver",
576 .internal_id = PVR2_CID_VRES,
577 .default_value = 480,
578 DEFREF(res_ver),
579 DEFINT(200,625),
580 },{
553 .v4l_id = V4L2_CID_PVR_SRATE, 581 .v4l_id = V4L2_CID_PVR_SRATE,
554 .desc = "Sample rate", 582 .desc = "Sample rate",
555 .name = "srate", 583 .name = "srate",
@@ -571,12 +599,6 @@ static const struct pvr2_ctl_info control_defs[] = {
571 DEFREF(audiocrc), 599 DEFREF(audiocrc),
572 DEFINT(0,1), 600 DEFINT(0,1),
573 },{ 601 },{
574 .desc = "Audio Layer",
575 .name = "audio_layer",
576 .default_value = 2,
577 DEFREF(audiolayer),
578 DEFINT(0,3),
579 },{
580 .v4l_id = V4L2_CID_PVR_AUDIOEMPHASIS, 602 .v4l_id = V4L2_CID_PVR_AUDIOEMPHASIS,
581 .desc = "Audio Emphasis", 603 .desc = "Audio Emphasis",
582 .name = "audio_emphasis", 604 .name = "audio_emphasis",
@@ -584,13 +606,6 @@ static const struct pvr2_ctl_info control_defs[] = {
584 DEFREF(audioemphasis), 606 DEFREF(audioemphasis),
585 DEFENUM(control_values_audioemphasis), 607 DEFENUM(control_values_audioemphasis),
586 },{ 608 },{
587 .desc = "Interlace mode",
588 .name = "interlace",
589 .internal_id = PVR2_CID_INTERLACE,
590 .default_value = 0,
591 DEFREF(interlace),
592 DEFINT(0,1),
593 },{
594 .v4l_id = V4L2_CID_PVR_VBR, 609 .v4l_id = V4L2_CID_PVR_VBR,
595 .desc = "Variable video bitrate", 610 .desc = "Variable video bitrate",
596 .name = "vbr", 611 .name = "vbr",
@@ -612,19 +627,18 @@ static const struct pvr2_ctl_info control_defs[] = {
612 DEFREF(videopeak), 627 DEFREF(videopeak),
613 DEFINT(500000,20000000), 628 DEFINT(500000,20000000),
614 },{ 629 },{
615 .desc = "Video Source", 630 .desc = "Interlace mode",
616 .name = "input", 631 .name = "interlace",
617 .internal_id = PVR2_CID_INPUT, 632 .internal_id = PVR2_CID_INTERLACE,
618 .default_value = PVR2_CVAL_INPUT_TV, 633 .default_value = 0,
619 DEFREF(input), 634 DEFREF(interlace),
620 DEFENUM(control_values_input), 635 DEFINT(0,1),
621 },{ 636 },{
622 .desc = "Audio Mode", 637 .desc = "Audio Layer",
623 .name = "audio_mode", 638 .name = "audio_layer",
624 .internal_id = PVR2_CID_AUDIOMODE, 639 .default_value = 2,
625 .default_value = V4L2_TUNER_MODE_STEREO, 640 DEFREF(audiolayer),
626 DEFREF(audiomode), 641 DEFINT(0,3),
627 DEFENUM(control_values_audiomode),
628 },{ 642 },{
629 .desc = "Tuner Frequency (Hz)", 643 .desc = "Tuner Frequency (Hz)",
630 .name = "frequency", 644 .name = "frequency",
@@ -654,20 +668,6 @@ static const struct pvr2_ctl_info control_defs[] = {
654 .get_value = ctrl_channelprog_get, 668 .get_value = ctrl_channelprog_get,
655 DEFINT(0,FREQTABLE_SIZE), 669 DEFINT(0,FREQTABLE_SIZE),
656 },{ 670 },{
657 .desc = "Horizontal capture resolution",
658 .name = "resolution_hor",
659 .internal_id = PVR2_CID_HRES,
660 .default_value = 720,
661 DEFREF(res_hor),
662 DEFINT(320,720),
663 },{
664 .desc = "Vertical capture resolution",
665 .name = "resolution_ver",
666 .internal_id = PVR2_CID_VRES,
667 .default_value = 480,
668 DEFREF(res_ver),
669 DEFINT(200,625),
670 },{
671 .desc = "Streaming Enabled", 671 .desc = "Streaming Enabled",
672 .name = "streaming_enabled", 672 .name = "streaming_enabled",
673 .get_value = ctrl_streamingenabled_get, 673 .get_value = ctrl_streamingenabled_get,
@@ -731,7 +731,7 @@ static const struct pvr2_ctl_info control_defs[] = {
731 } 731 }
732}; 732};
733 733
734#define CTRL_COUNT (sizeof(control_defs)/sizeof(control_defs[0])) 734#define CTRLDEF_COUNT (sizeof(control_defs)/sizeof(control_defs[0]))
735 735
736 736
737const char *pvr2_config_get_name(enum pvr2_config cfg) 737const char *pvr2_config_get_name(enum pvr2_config cfg)
@@ -1508,7 +1508,7 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
1508 pvr2_i2c_core_init(hdw); 1508 pvr2_i2c_core_init(hdw);
1509 if (!pvr2_hdw_dev_ok(hdw)) return; 1509 if (!pvr2_hdw_dev_ok(hdw)) return;
1510 1510
1511 for (idx = 0; idx < CTRL_COUNT; idx++) { 1511 for (idx = 0; idx < CTRLDEF_COUNT; idx++) {
1512 cptr = hdw->controls + idx; 1512 cptr = hdw->controls + idx;
1513 if (cptr->info->skip_init) continue; 1513 if (cptr->info->skip_init) continue;
1514 if (!cptr->info->set_value) continue; 1514 if (!cptr->info->set_value) continue;
@@ -1665,19 +1665,21 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
1665 if (!hdw) goto fail; 1665 if (!hdw) goto fail;
1666 memset(hdw,0,sizeof(*hdw)); 1666 memset(hdw,0,sizeof(*hdw));
1667 1667
1668 hdw->controls = kmalloc(sizeof(struct pvr2_ctrl) * CTRL_COUNT, 1668 hdw->control_cnt = CTRLDEF_COUNT;
1669 hdw->controls = kmalloc(sizeof(struct pvr2_ctrl) * hdw->control_cnt,
1669 GFP_KERNEL); 1670 GFP_KERNEL);
1670 if (!hdw->controls) goto fail; 1671 if (!hdw->controls) goto fail;
1671 memset(hdw->controls,0,sizeof(struct pvr2_ctrl) * CTRL_COUNT); 1672 memset(hdw->controls,0,sizeof(struct pvr2_ctrl) * hdw->control_cnt);
1672 hdw->hdw_type = hdw_type; 1673 hdw->hdw_type = hdw_type;
1673 1674 for (idx = 0; idx < hdw->control_cnt; idx++) {
1675 cptr = hdw->controls + idx;
1676 cptr->hdw = hdw;
1677 }
1674 for (idx = 0; idx < 32; idx++) { 1678 for (idx = 0; idx < 32; idx++) {
1675 hdw->std_mask_ptrs[idx] = hdw->std_mask_names[idx]; 1679 hdw->std_mask_ptrs[idx] = hdw->std_mask_names[idx];
1676 } 1680 }
1677 1681 for (idx = 0; idx < CTRLDEF_COUNT; idx++) {
1678 for (idx = 0; idx < CTRL_COUNT; idx++) {
1679 cptr = hdw->controls + idx; 1682 cptr = hdw->controls + idx;
1680 cptr->hdw = hdw;
1681 cptr->info = control_defs+idx; 1683 cptr->info = control_defs+idx;
1682 } 1684 }
1683 1685
@@ -1846,7 +1848,7 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw)
1846 unit_pointers[hdw->unit_number] = 0; 1848 unit_pointers[hdw->unit_number] = 0;
1847 } 1849 }
1848 } while (0); up(&pvr2_unit_sem); 1850 } while (0); up(&pvr2_unit_sem);
1849 kfree(hdw->controls); 1851 if (hdw->controls) kfree(hdw->controls);
1850 if (hdw->std_defs) kfree(hdw->std_defs); 1852 if (hdw->std_defs) kfree(hdw->std_defs);
1851 if (hdw->std_enum_names) kfree(hdw->std_enum_names); 1853 if (hdw->std_enum_names) kfree(hdw->std_enum_names);
1852 kfree(hdw); 1854 kfree(hdw);
@@ -1952,7 +1954,7 @@ int pvr2_hdw_get_stdenum_value(struct pvr2_hdw *hdw,
1952/* Get the number of defined controls */ 1954/* Get the number of defined controls */
1953unsigned int pvr2_hdw_get_ctrl_count(struct pvr2_hdw *hdw) 1955unsigned int pvr2_hdw_get_ctrl_count(struct pvr2_hdw *hdw)
1954{ 1956{
1955 return CTRL_COUNT; 1957 return hdw->control_cnt;
1956} 1958}
1957 1959
1958 1960
@@ -1960,7 +1962,7 @@ unsigned int pvr2_hdw_get_ctrl_count(struct pvr2_hdw *hdw)
1960struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_index(struct pvr2_hdw *hdw, 1962struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_index(struct pvr2_hdw *hdw,
1961 unsigned int idx) 1963 unsigned int idx)
1962{ 1964{
1963 if (idx >= CTRL_COUNT) return 0; 1965 if (idx >= hdw->control_cnt) return 0;
1964 return hdw->controls + idx; 1966 return hdw->controls + idx;
1965} 1967}
1966 1968
@@ -1974,7 +1976,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_id(struct pvr2_hdw *hdw,
1974 int i; 1976 int i;
1975 1977
1976 /* This could be made a lot more efficient, but for now... */ 1978 /* This could be made a lot more efficient, but for now... */
1977 for (idx = 0; idx < CTRL_COUNT; idx++) { 1979 for (idx = 0; idx < hdw->control_cnt; idx++) {
1978 cptr = hdw->controls + idx; 1980 cptr = hdw->controls + idx;
1979 i = cptr->info->internal_id; 1981 i = cptr->info->internal_id;
1980 if (i && (i == ctl_id)) return cptr; 1982 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 int i; 1993 int i;
1992 1994
1993 /* This could be made a lot more efficient, but for now... */ 1995 /* This could be made a lot more efficient, but for now... */
1994 for (idx = 0; idx < CTRL_COUNT; idx++) { 1996 for (idx = 0; idx < hdw->control_cnt; idx++) {
1995 cptr = hdw->controls + idx; 1997 cptr = hdw->controls + idx;
1996 i = cptr->info->v4l_id; 1998 i = cptr->info->v4l_id;
1997 if (i && (i == ctl_id)) return cptr; 1999 if (i && (i == ctl_id)) return cptr;
@@ -2029,7 +2031,7 @@ int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw)
2029 char buf[100]; 2031 char buf[100];
2030 unsigned int bcnt,ccnt; 2032 unsigned int bcnt,ccnt;
2031 2033
2032 for (idx = 0; idx < CTRL_COUNT; idx++) { 2034 for (idx = 0; idx < hdw->control_cnt; idx++) {
2033 cptr = hdw->controls + idx; 2035 cptr = hdw->controls + idx;
2034 if (cptr->info->is_dirty == 0) continue; 2036 if (cptr->info->is_dirty == 0) continue;
2035 if (!cptr->info->is_dirty(cptr)) continue; 2037 if (!cptr->info->is_dirty(cptr)) continue;
@@ -2080,30 +2082,31 @@ int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw)
2080 } 2082 }
2081 2083
2082 if (hdw->std_dirty || 2084 if (hdw->std_dirty ||
2083 hdw->res_ver_dirty ||
2084 hdw->res_hor_dirty ||
2085 hdw->interlace_dirty || 2085 hdw->interlace_dirty ||
2086 hdw->vbr_dirty || 2086 hdw->vbr_dirty ||
2087 hdw->videobitrate_dirty || 2087 hdw->videobitrate_dirty ||
2088 hdw->videopeak_dirty || 2088 hdw->videopeak_dirty ||
2089 hdw->audiobitrate_dirty || 2089 hdw->audiobitrate_dirty ||
2090 hdw->srate_dirty ||
2091 hdw->audiolayer_dirty || 2090 hdw->audiolayer_dirty ||
2092 hdw->audiocrc_dirty || 2091 hdw->audiocrc_dirty ||
2093 hdw->audioemphasis_dirty) { 2092 hdw->audioemphasis_dirty ||
2093 hdw->srate_dirty ||
2094 hdw->res_ver_dirty ||
2095 hdw->res_hor_dirty) {
2094 /* If any of this changes, then the encoder needs to be 2096 /* If any of this changes, then the encoder needs to be
2095 reconfigured, and we need to reset the stream. */ 2097 reconfigured, and we need to reset the stream. */
2096 stale_subsys_mask |= (1<<PVR2_SUBSYS_B_ENC_CFG); 2098 stale_subsys_mask |= (1<<PVR2_SUBSYS_B_ENC_CFG);
2097 stale_subsys_mask |= hdw->subsys_stream_mask; 2099 stale_subsys_mask |= hdw->subsys_stream_mask;
2098 } 2100 }
2099 2101
2102
2100 /* Scan i2c core at this point - before we clear all the dirty 2103 /* Scan i2c core at this point - before we clear all the dirty
2101 bits. Various parts of the i2c core will notice dirty bits as 2104 bits. Various parts of the i2c core will notice dirty bits as
2102 appropriate and arrange to broadcast or directly send updates to 2105 appropriate and arrange to broadcast or directly send updates to
2103 the client drivers in order to keep everything in sync */ 2106 the client drivers in order to keep everything in sync */
2104 pvr2_i2c_core_check_stale(hdw); 2107 pvr2_i2c_core_check_stale(hdw);
2105 2108
2106 for (idx = 0; idx < CTRL_COUNT; idx++) { 2109 for (idx = 0; idx < hdw->control_cnt; idx++) {
2107 cptr = hdw->controls + idx; 2110 cptr = hdw->controls + idx;
2108 if (!cptr->info->clear_dirty) continue; 2111 if (!cptr->info->clear_dirty) continue;
2109 cptr->info->clear_dirty(cptr); 2112 cptr->info->clear_dirty(cptr);