aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/xawtv/xawtv-3.95/12_fbtv_radeonfb.patch
blob: 3b002c9bcebaa4cf307c9b255568d5b0f90fb3fd (plain)
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
diff -urNad xawtv-3.95.dfsg.1~/console/fbtools.c xawtv-3.95.dfsg.1/console/fbtools.c
--- xawtv-3.95.dfsg.1~/console/fbtools.c	2007-07-29 00:54:44.000000000 +0200
+++ xawtv-3.95.dfsg.1/console/fbtools.c	2007-07-29 00:55:39.000000000 +0200
@@ -447,7 +447,7 @@
     fb_activate_current(tty);
 
     /* cls */
-    fb_memset(fb_mem+fb_mem_offset,0,fb_fix.smem_len);
+    fb_memset(fb_mem+fb_mem_offset,0,fb_var.yres * fb_fix.line_length);
     return fb;
 
  err:
@@ -458,15 +458,33 @@
 void
 fb_cleanup(void)
 {
+    struct fb_var_screeninfo var;
+
     /* restore console */
+    if (0 == ioctl(fb,FBIOGET_VSCREENINFO,&var)) {
+	if (!memcmp(&var, &fb_ovar, sizeof(var))) {
+	    goto skip_var;
+	}
+    }
     if (-1 == ioctl(fb,FBIOPUT_VSCREENINFO,&fb_ovar))
 	perror("ioctl FBIOPUT_VSCREENINFO");
+skip_var:
     if (-1 == ioctl(fb,FBIOGET_FSCREENINFO,&fb_fix))
 	perror("ioctl FBIOGET_FSCREENINFO");
     if (fb_ovar.bits_per_pixel == 8 ||
 	fb_fix.visual == FB_VISUAL_DIRECTCOLOR) {
-	if (-1 == ioctl(fb,FBIOPUTCMAP,&ocmap))
-	    perror("ioctl FBIOPUTCMAP");
+	if (-1 == ioctl(fb,FBIOPUTCMAP,&ocmap)) {
+            /*
+             * radeonfb in 15/16bpp returns EINVAL when color
+             * map retrieved by FBIOGETCMAP is programmed back
+             * by FBIOPUTCMAP.  It still programs palette
+             * correctly, just instead of ignoring items 64-255
+             * it returns an error.
+             */
+	    if (errno != EINVAL) {
+	        perror("ioctl FBIOPUTCMAP");
+	    }
+	}
     }
     close(fb);
 
diff -urNad xawtv-3.95.dfsg.1~/console/fbtv.c xawtv-3.95.dfsg.1/console/fbtv.c
--- xawtv-3.95.dfsg.1~/console/fbtv.c	2005-09-30 12:09:22.000000000 +0200
+++ xawtv-3.95.dfsg.1/console/fbtv.c	2007-07-29 00:55:39.000000000 +0200
@@ -230,6 +230,26 @@
 }
 
 static void
+fb_loadpalette(int fd)
+{
+    if (fb_var.bits_per_pixel == 8 ||
+        fb_fix.visual == FB_VISUAL_DIRECTCOLOR) {
+        if (-1 == ioctl(fd,FBIOPUTCMAP,&cmap)) {
+	    /*
+	     * radeonfb in 15/16bpp returns EINVAL when color 
+	     * map retrieved by FBIOGETCMAP is programmed back
+	     * by FBIOPUTCMAP.  It still programs palette
+	     * correctly, just instead of ignoring items 64-255
+	     * it returns an error.
+	     */
+	    if (errno != EINVAL) {
+                perror("ioctl FBIOPUTCMAP");
+	    }
+	}
+    }
+}
+
+static void
 fb_initcolors(int fd, int gray)
 {
     /* get colormap */
@@ -288,11 +308,7 @@
     }
 
     /* set colormap */
-    if (fb_var.bits_per_pixel == 8 ||
-	fb_fix.visual == FB_VISUAL_DIRECTCOLOR) {
-	if (-1 == ioctl(fd,FBIOPUTCMAP,&cmap))
-	    perror("ioctl FBIOPUTCMAP");
-    }
+    fb_loadpalette(fd);
 }
 
 static void
@@ -511,11 +527,17 @@
 }
 
 static void
+clear_video(void)
+{
+    fb_memset(fb_mem+fb_mem_offset,0,fb_var.yres * fb_fix.line_length);
+}
+
+static void
 do_fullscreen(void)
 {
     do_va_cmd(2,"capture","off");
     quiet = !quiet;
-    fb_memset(fb_mem+fb_mem_offset,0,fb_fix.smem_len);
+    clear_video();
     do_va_cmd(2,"capture","on");
 }
 
@@ -553,8 +575,9 @@
     case FB_ACQ_REQ:
 	switch_last = fb_switch_state;
         fb_switch_acquire();
-	fb_memset(fb_mem+fb_mem_offset,0,fb_fix.smem_len);
+	clear_video();
 	ioctl(fb,FBIOPAN_DISPLAY,&fb_var);
+	fb_loadpalette(fb);
 	do_va_cmd(2,"capture","on");
 	break;
     case FB_ACTIVE:
@@ -748,7 +771,7 @@
     }
 #endif
 
-    fb_memset(fb_mem+fb_mem_offset,0,fb_fix.smem_len);
+    clear_video();
     for (;!sig;) {
 	if ((fb_switch_state == FB_ACTIVE || keep_dma_on) && !quiet) {
 	    /* clear first lines */
@@ -918,7 +941,7 @@
 	audio_off();
     drv->close(h_drv);
     if (fb_switch_state == FB_ACTIVE)
-	fb_memset(fb_mem+fb_mem_offset,0,fb_fix.smem_len);
+	clear_video();
     tty_cleanup();
     fb_cleanup();
     exit(0);
diff -urNad xawtv-3.95.dfsg.1~/console/v4l-conf.c xawtv-3.95.dfsg.1/console/v4l-conf.c
--- xawtv-3.95.dfsg.1~/console/v4l-conf.c	2005-02-09 13:27:36.000000000 +0100
+++ xawtv-3.95.dfsg.1/console/v4l-conf.c	2007-07-29 00:55:39.000000000 +0200
@@ -347,7 +347,7 @@
     /* set values */
     fb.fmt.width  = d->width;
     fb.fmt.height = d->height;
-    switch (d->bpp) {
+    switch (d->bpp != 16 ? d->bpp : d->depth) {
     case  8: fb.fmt.pixelformat = V4L2_PIX_FMT_HI240;   break;
 #if BYTE_ORDER == BIG_ENDIAN
     case 15: fb.fmt.pixelformat = V4L2_PIX_FMT_RGB555X; break;