summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2006-04-25 19:09:51 -0500
committerMike Isely <isely@pobox.com>2006-04-25 19:09:51 -0500
commitbec655f69df2e179760e48639daf3cc936d6c6e6 (patch)
tree1cdae8fd76295bedf0a7ccd380ba4bec4ab3dd9d
parent6bfc9bfdb9ac2503b801f907c2c51af7275bb03c (diff)
downloadmediapointer-dvb-s2-bec655f69df2e179760e48639daf3cc936d6c6e6.tar.gz
mediapointer-dvb-s2-bec655f69df2e179760e48639daf3cc936d6c6e6.tar.bz2
Various pvrusb2 video standard cleanups
From: Mike Isely <isely@pobox.com> Signed-off-by: Mike Isely <isely@pobox.com>
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-std.c81
1 files changed, 55 insertions, 26 deletions
diff --git a/linux/drivers/media/video/pvrusb2/pvrusb2-std.c b/linux/drivers/media/video/pvrusb2/pvrusb2-std.c
index 857829120..64ba223c2 100644
--- a/linux/drivers/media/video/pvrusb2/pvrusb2-std.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-std.c
@@ -27,6 +27,7 @@ struct std_name {
v4l2_std_id id;
};
+
#define CSTD_PAL \
(V4L2_STD_PAL_B| \
V4L2_STD_PAL_B1| \
@@ -44,6 +45,7 @@ struct std_name {
#define CSTD_NTSC \
(V4L2_STD_NTSC_M| \
V4L2_STD_NTSC_M_JP| \
+ V4L2_STD_NTSC_M_KR| \
V4L2_STD_NTSC_443)
#define CSTD_SECAM \
@@ -66,10 +68,7 @@ struct std_name {
#define TSTD_K (V4L2_STD_PAL_K|V4L2_STD_SECAM_K)
#define TSTD_K1 (V4L2_STD_SECAM_K1)
#define TSTD_L (V4L2_STD_SECAM_L)
-#define TSTD_LC (V4L2_STD_SECAM_LC)
#define TSTD_M (V4L2_STD_PAL_M|V4L2_STD_NTSC_M)
-#define TSTD_Mj (V4L2_STD_NTSC_M_JP)
-#define TSTD_443 (V4L2_STD_NTSC_443)
#define TSTD_N (V4L2_STD_PAL_N)
#define TSTD_Nc (V4L2_STD_PAL_Nc)
#define TSTD_60 (V4L2_STD_PAL_60)
@@ -95,10 +94,11 @@ const static struct std_name std_items[] = {
{"K",TSTD_K},
{"K1",TSTD_K1},
{"L",TSTD_L},
- {"LC",TSTD_LC},
+ {"LC",V4L2_STD_SECAM_LC},
{"M",TSTD_M},
- {"Mj",TSTD_Mj},
- {"443",TSTD_443},
+ {"Mj",V4L2_STD_NTSC_M_JP},
+ {"443",V4L2_STD_NTSC_443},
+ {"Mk",V4L2_STD_NTSC_M_KR},
{"N",TSTD_N},
{"Nc",TSTD_Nc},
{"60",TSTD_60},
@@ -236,7 +236,7 @@ static struct v4l2_standard generic_standards[] = {
TSTD_I|
TSTD_K|TSTD_K1|
TSTD_L|
- TSTD_LC|
+ V4L2_STD_SECAM_LC |
TSTD_N|TSTD_Nc),
.frameperiod =
{
@@ -246,7 +246,9 @@ static struct v4l2_standard generic_standards[] = {
.framelines = 625,
.reserved = {0,0,0,0}
}, {
- .id = (TSTD_M|TSTD_Mj),
+ .id = (TSTD_M|
+ V4L2_STD_NTSC_M_JP|
+ V4L2_STD_NTSC_M_KR),
.frameperiod =
{
.numerator = 1001,
@@ -264,7 +266,7 @@ static struct v4l2_standard generic_standards[] = {
.framelines = 525,
.reserved = {0,0,0,0}
}, { // This is total wild guess
- .id = (TSTD_443),
+ .id = V4L2_STD_NTSC_443,
.frameperiod =
{
.numerator = 1001,
@@ -288,15 +290,40 @@ static struct v4l2_standard *match_std(v4l2_std_id id)
return 0;
}
+static int pvr2_std_fill(struct v4l2_standard *std,v4l2_std_id id)
+{
+ struct v4l2_standard *template;
+ int idx;
+ unsigned int bcnt;
+ template = match_std(id);
+ if (!template) return 0;
+ idx = std->index;
+ memcpy(std,template,sizeof(*template));
+ std->index = idx;
+ std->id = id;
+ bcnt = pvr2_std_id_to_str(std->name,sizeof(std->name)-1,id);
+ std->name[bcnt] = 0;
+ pvr2_trace(PVR2_TRACE_INIT,"Set up standard idx=%u name=%s",
+ std->index,std->name);
+ return !0;
+}
+
+/* These are special cases of combined standards that we should enumerate
+ separately if the component pieces are present. */
+static v4l2_std_id std_mixes[] = {
+ V4L2_STD_PAL_B | V4L2_STD_PAL_G,
+ V4L2_STD_PAL_D | V4L2_STD_PAL_K,
+ V4L2_STD_SECAM_B | V4L2_STD_SECAM_G,
+ V4L2_STD_SECAM_D | V4L2_STD_SECAM_K,
+};
+
struct v4l2_standard *pvr2_std_create_enum(unsigned int *countptr,
v4l2_std_id id)
{
unsigned int std_cnt = 0;
- unsigned int idx,bcnt;
+ unsigned int idx,bcnt,idx2;
v4l2_std_id idmsk,cmsk,fmsk;
struct v4l2_standard *stddefs;
- struct v4l2_standard *template;
- struct v4l2_standard *std;
if (pvrusb2_debug & PVR2_TRACE_INIT) {
char buf[50];
@@ -319,6 +346,10 @@ struct v4l2_standard *pvr2_std_create_enum(unsigned int *countptr,
fmsk |= idmsk;
}
+ for (idx2 = 0; idx2 < sizeof(std_mixes)/sizeof(std_mixes[0]); idx2++) {
+ if ((id & std_mixes[idx2]) == std_mixes[idx2]) std_cnt++;
+ }
+
if (fmsk) {
char buf[50];
bcnt = pvr2_std_id_to_str(buf,sizeof(buf),fmsk);
@@ -336,23 +367,21 @@ struct v4l2_standard *pvr2_std_create_enum(unsigned int *countptr,
stddefs = kmalloc(sizeof(struct v4l2_standard) * std_cnt,
GFP_KERNEL);
memset(stddefs,0,sizeof(struct v4l2_standard) * std_cnt);
+ for (idx = 0; idx < std_cnt; idx++) stddefs[idx].index = idx;
+
idx = 0;
- for (idmsk = 1, cmsk = id; cmsk; idmsk <<= 1) {
+
+ /* Enumerate potential special cases */
+ for (idx2 = 0; ((idx2 < sizeof(std_mixes)/sizeof(std_mixes[0])) &&
+ (idx < std_cnt)); idx2++) {
+ if (!(id & std_mixes[idx2])) continue;
+ if (pvr2_std_fill(stddefs+idx,std_mixes[idx2])) idx++;
+ }
+ /* Now enumerate individual pieces */
+ for (idmsk = 1, cmsk = id; cmsk && (idx < std_cnt); idmsk <<= 1) {
if (!(idmsk & cmsk)) continue;
cmsk &= ~idmsk;
- template = match_std(idmsk);
- if (!template) continue;
- if (idx >= std_cnt) break;
- std = stddefs+idx;
- memcpy(std,template,sizeof(*template));
- std->index = idx;
- std->id = idmsk;
- bcnt = pvr2_std_id_to_str(std->name,
- sizeof(std->name)-1,
- idmsk);
- std->name[bcnt] = 0;
- pvr2_trace(PVR2_TRACE_INIT,"Set up standard idx=%u name=%s",
- idx,std->name);
+ if (!pvr2_std_fill(stddefs+idx,idmsk)) continue;
idx++;
}