aboutsummaryrefslogtreecommitdiffstats
path: root/multimedia/xawtv/files/patch-libng__plugins__drv0-bsd.c
blob: 62801a53a196a7a1b9482dc4f17986a2b5e01d38 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
--- libng/plugins/drv0-bsd.c.orig	Wed Mar 12 17:45:56 2003
+++ libng/plugins/drv0-bsd.c	Tue May 24 11:32:55 2005
@@ -23,10 +23,12 @@
 
 #ifdef HAVE_DEV_IC_BT8XX_H
 # include <dev/ic/bt8xx.h>
-#endif
-#ifdef HAVE_MACHINE_IOCTL_BT848_H
+#elif defined(HAVE_MACHINE_IOCTL_BT848_H)
 # include <machine/ioctl_bt848.h>
 # include <machine/ioctl_meteor.h>
+#else
+# include <dev/bktr/ioctl_bt848.h>
+# include <dev/bktr/ioctl_meteor.h>
 #endif
 
 #include "grab-ng.h"
@@ -127,7 +129,7 @@
     {  3, "CSVIDEO"      },
     { -1, NULL }
 };
-static int inputs_map[] = {
+static long inputs_map[] = {
     METEOR_INPUT_DEV1,
     METEOR_INPUT_DEV0,
     METEOR_INPUT_DEV_SVIDEO,
@@ -144,7 +146,7 @@
     {  6, "RSVD"      },
     { -1, NULL }
 };
-static int norms_map[] = {
+static long norms_map[] = {
     BT848_IFORM_F_NTSCM,
     BT848_IFORM_F_NTSCJ,
     BT848_IFORM_F_PALBDGHI,
@@ -160,7 +162,7 @@
     {  2, "Intern"      },
     { -1, NULL }
 };
-static int audio_map[] = {
+static long audio_map[] = {
     AUDIO_TUNER,
     AUDIO_EXTERN,
     AUDIO_INTERN,
@@ -242,7 +244,7 @@
 #define PREFIX "bktr: ioctl: "
 
 static int
-xioctl(int fd, int cmd, void *arg)
+xioctl(int fd, unsigned long cmd, void *arg)
 {
     int rc;
 
@@ -296,7 +298,7 @@
 	break;
     }
     default:
-	fprintf(stderr,PREFIX "UNKNOWN(cmd=0x%x)",cmd);
+	fprintf(stderr,PREFIX "UNKNOWN(cmd=0x%x)",(int)cmd);
 	break;
     }
     fprintf(stderr,": %s\n",(rc == 0) ? "ok" : strerror(errno));
@@ -474,7 +476,7 @@
 /* ---------------------------------------------------------------------- */
 
 static int
-bsd_get_range(int id, int *get, int *set)
+bsd_get_range(int id, int *get, long *set)
 {
     switch (id) {
     case ATTR_ID_HUE:
@@ -502,19 +504,20 @@
 static int bsd_read_attr(struct ng_attribute *attr)
 {
     struct bsd_handle *h = attr->handle;
-    int arg, get, set, i;
+    int get, i;
+    long arg, set;
     int value = -1;
 
     switch (attr->id) {
     case ATTR_ID_NORM:
 	if (-1 != xioctl(h->fd,BT848GFMT,&arg))
-	    for (i = 0; i < sizeof(norms_map)/sizeof(int); i++)
+	    for (i = 0; i < sizeof(norms_map)/sizeof(*norms_map); i++)
 		if (arg == norms_map[i])
 		    value = i;
 	break;
     case ATTR_ID_INPUT:
 	if (-1 != xioctl(h->fd,METEORGINPUT,&arg))
-	    for (i = 0; i < sizeof(inputs_map)/sizeof(int); i++)
+	    for (i = 0; i < sizeof(inputs_map)/sizeof(*inputs_map); i++)
 		if (arg == inputs_map[i])
 		    value = i;
 	break;
@@ -532,7 +535,7 @@
 	break;
     case ATTR_ID_COUNT+1: /* AUDIO */
 	if (-1 != xioctl(h->tfd, BT848_GAUDIO, &arg))
-	    for (i = 0; i < sizeof(audio_map)/sizeof(int); i++)
+	    for (i = 0; i < sizeof(audio_map)/sizeof(*audio_map); i++)
 		if (arg == audio_map[i])
 		    value = i;
 	break;
@@ -545,7 +548,8 @@
 static void bsd_write_attr(struct ng_attribute *attr, int value)
 {
     struct bsd_handle *h = attr->handle;
-    int arg, get, set;
+    int get;
+    long arg, set;
 
     switch (attr->id) {
     case ATTR_ID_NORM:
@@ -599,7 +603,15 @@
 
 static int bsd_tuned(void *handle)
 {
-    return 0;
+    struct bsd_handle *h = handle;
+    int signal;
+
+    usleep(10000);
+
+    if (-1 == xioctl(h->tfd, TVTUNER_GETSTATUS, &signal))
+	return 0;
+
+    return signal == 106 ? 1 : 0;
 }
 
 /* ---------------------------------------------------------------------- */