xawtv: update to version 3.95
[openembedded.git] / recipes / xawtv / xawtv-3.95 / 12_fbtv_radeonfb.patch
1 diff -urNad xawtv-3.95.dfsg.1~/console/fbtools.c xawtv-3.95.dfsg.1/console/fbtools.c
2 --- xawtv-3.95.dfsg.1~/console/fbtools.c        2007-07-29 00:54:44.000000000 +0200
3 +++ xawtv-3.95.dfsg.1/console/fbtools.c 2007-07-29 00:55:39.000000000 +0200
4 @@ -447,7 +447,7 @@
5      fb_activate_current(tty);
6  
7      /* cls */
8 -    fb_memset(fb_mem+fb_mem_offset,0,fb_fix.smem_len);
9 +    fb_memset(fb_mem+fb_mem_offset,0,fb_var.yres * fb_fix.line_length);
10      return fb;
11  
12   err:
13 @@ -458,15 +458,33 @@
14  void
15  fb_cleanup(void)
16  {
17 +    struct fb_var_screeninfo var;
18 +
19      /* restore console */
20 +    if (0 == ioctl(fb,FBIOGET_VSCREENINFO,&var)) {
21 +       if (!memcmp(&var, &fb_ovar, sizeof(var))) {
22 +           goto skip_var;
23 +       }
24 +    }
25      if (-1 == ioctl(fb,FBIOPUT_VSCREENINFO,&fb_ovar))
26         perror("ioctl FBIOPUT_VSCREENINFO");
27 +skip_var:
28      if (-1 == ioctl(fb,FBIOGET_FSCREENINFO,&fb_fix))
29         perror("ioctl FBIOGET_FSCREENINFO");
30      if (fb_ovar.bits_per_pixel == 8 ||
31         fb_fix.visual == FB_VISUAL_DIRECTCOLOR) {
32 -       if (-1 == ioctl(fb,FBIOPUTCMAP,&ocmap))
33 -           perror("ioctl FBIOPUTCMAP");
34 +       if (-1 == ioctl(fb,FBIOPUTCMAP,&ocmap)) {
35 +            /*
36 +             * radeonfb in 15/16bpp returns EINVAL when color
37 +             * map retrieved by FBIOGETCMAP is programmed back
38 +             * by FBIOPUTCMAP.  It still programs palette
39 +             * correctly, just instead of ignoring items 64-255
40 +             * it returns an error.
41 +             */
42 +           if (errno != EINVAL) {
43 +               perror("ioctl FBIOPUTCMAP");
44 +           }
45 +       }
46      }
47      close(fb);
48  
49 diff -urNad xawtv-3.95.dfsg.1~/console/fbtv.c xawtv-3.95.dfsg.1/console/fbtv.c
50 --- xawtv-3.95.dfsg.1~/console/fbtv.c   2005-09-30 12:09:22.000000000 +0200
51 +++ xawtv-3.95.dfsg.1/console/fbtv.c    2007-07-29 00:55:39.000000000 +0200
52 @@ -230,6 +230,26 @@
53  }
54  
55  static void
56 +fb_loadpalette(int fd)
57 +{
58 +    if (fb_var.bits_per_pixel == 8 ||
59 +        fb_fix.visual == FB_VISUAL_DIRECTCOLOR) {
60 +        if (-1 == ioctl(fd,FBIOPUTCMAP,&cmap)) {
61 +           /*
62 +            * radeonfb in 15/16bpp returns EINVAL when color 
63 +            * map retrieved by FBIOGETCMAP is programmed back
64 +            * by FBIOPUTCMAP.  It still programs palette
65 +            * correctly, just instead of ignoring items 64-255
66 +            * it returns an error.
67 +            */
68 +           if (errno != EINVAL) {
69 +                perror("ioctl FBIOPUTCMAP");
70 +           }
71 +       }
72 +    }
73 +}
74 +
75 +static void
76  fb_initcolors(int fd, int gray)
77  {
78      /* get colormap */
79 @@ -288,11 +308,7 @@
80      }
81  
82      /* set colormap */
83 -    if (fb_var.bits_per_pixel == 8 ||
84 -       fb_fix.visual == FB_VISUAL_DIRECTCOLOR) {
85 -       if (-1 == ioctl(fd,FBIOPUTCMAP,&cmap))
86 -           perror("ioctl FBIOPUTCMAP");
87 -    }
88 +    fb_loadpalette(fd);
89  }
90  
91  static void
92 @@ -511,11 +527,17 @@
93  }
94  
95  static void
96 +clear_video(void)
97 +{
98 +    fb_memset(fb_mem+fb_mem_offset,0,fb_var.yres * fb_fix.line_length);
99 +}
100 +
101 +static void
102  do_fullscreen(void)
103  {
104      do_va_cmd(2,"capture","off");
105      quiet = !quiet;
106 -    fb_memset(fb_mem+fb_mem_offset,0,fb_fix.smem_len);
107 +    clear_video();
108      do_va_cmd(2,"capture","on");
109  }
110  
111 @@ -553,8 +575,9 @@
112      case FB_ACQ_REQ:
113         switch_last = fb_switch_state;
114          fb_switch_acquire();
115 -       fb_memset(fb_mem+fb_mem_offset,0,fb_fix.smem_len);
116 +       clear_video();
117         ioctl(fb,FBIOPAN_DISPLAY,&fb_var);
118 +       fb_loadpalette(fb);
119         do_va_cmd(2,"capture","on");
120         break;
121      case FB_ACTIVE:
122 @@ -748,7 +771,7 @@
123      }
124  #endif
125  
126 -    fb_memset(fb_mem+fb_mem_offset,0,fb_fix.smem_len);
127 +    clear_video();
128      for (;!sig;) {
129         if ((fb_switch_state == FB_ACTIVE || keep_dma_on) && !quiet) {
130             /* clear first lines */
131 @@ -918,7 +941,7 @@
132         audio_off();
133      drv->close(h_drv);
134      if (fb_switch_state == FB_ACTIVE)
135 -       fb_memset(fb_mem+fb_mem_offset,0,fb_fix.smem_len);
136 +       clear_video();
137      tty_cleanup();
138      fb_cleanup();
139      exit(0);
140 diff -urNad xawtv-3.95.dfsg.1~/console/v4l-conf.c xawtv-3.95.dfsg.1/console/v4l-conf.c
141 --- xawtv-3.95.dfsg.1~/console/v4l-conf.c       2005-02-09 13:27:36.000000000 +0100
142 +++ xawtv-3.95.dfsg.1/console/v4l-conf.c        2007-07-29 00:55:39.000000000 +0200
143 @@ -347,7 +347,7 @@
144      /* set values */
145      fb.fmt.width  = d->width;
146      fb.fmt.height = d->height;
147 -    switch (d->bpp) {
148 +    switch (d->bpp != 16 ? d->bpp : d->depth) {
149      case  8: fb.fmt.pixelformat = V4L2_PIX_FMT_HI240;   break;
150  #if BYTE_ORDER == BIG_ENDIAN
151      case 15: fb.fmt.pixelformat = V4L2_PIX_FMT_RGB555X; break;