]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/meta-ti-glsdk.git/blob - recipes-kernel/linux/linux-ti33x-psp-3.2/beaglebone/0041-st7735fb-Working-WIP-changes-to-make-DMA-safe-and-ad.patch
linux-ti33x-psp 3.2: update to 3.2.23
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / beaglebone / 0041-st7735fb-Working-WIP-changes-to-make-DMA-safe-and-ad.patch
1 From 7f97d002d17f8de8cde7f248bb1c194172360efe Mon Sep 17 00:00:00 2001
2 From: Matt Porter <mporter@ti.com>
3 Date: Wed, 28 Mar 2012 23:35:44 -0400
4 Subject: [PATCH 41/79] st7735fb: Working WIP changes to make DMA safe and add
5  endian fix
7 This removes the "from the stack" allocation of 1 byte buffers
8 that was a temporary thing and isn't dma safe. Now vmallocs the
9 user buffer to be deferred I/O safe and kmallocs a swapped
10 shadow buffer to support the byte swabbing hack to fix userspace
11 limitations.
13 The buffer allocation and endian hack code needs some serious
14 cleanup as on big endian systems if would fail miserably atm.
15 However, the LE path works for the moment so people can do something
16 with the driver.
18 Signed-off-by: Matt Porter <mporter@ti.com>
19 ---
20  drivers/video/st7735fb.c |   49 ++++++++++++++++++++++++++++++----------------
21  include/video/st7735fb.h |    2 ++
22  2 files changed, 34 insertions(+), 17 deletions(-)
24 diff --git a/drivers/video/st7735fb.c b/drivers/video/st7735fb.c
25 index 500cc88..0931ca2 100644
26 --- a/drivers/video/st7735fb.c
27 +++ b/drivers/video/st7735fb.c
28 @@ -145,11 +145,9 @@ static struct fb_var_screeninfo st7735fb_var __devinitdata = {
29  
30  static int st7735_write(struct st7735fb_par *par, u8 data)
31  {
32 -       u8 txbuf[2]; /* allocation from stack must go */
33 +       par->buf[0] = data;
34  
35 -       txbuf[0] = data;
36 -
37 -       return spi_write(par->spi, &txbuf[0], 1);
38 +       return spi_write(par->spi, par->buf, 1);
39  }
40  
41  static void st7735_write_data(struct st7735fb_par *par, u8 data)
42 @@ -243,16 +241,17 @@ static void st7735_reset(struct st7735fb_par *par)
43  static void st7735fb_update_display(struct st7735fb_par *par)
44  {
45         int ret = 0;
46 -       u8 *vmem = par->info->screen_base;
47 -
48 -       /*
49 -               TODO:
50 -               Allow a subset of pages to be passed in
51 -               (for deferred I/O).  Check pages against
52 -               pan display settings to see if they
53 -               should be updated.
54 -       */
55 -       /* For now, just write the full 40KiB on each update */
56 +       u16 *vmem;
57 +#ifdef __LITTLE_ENDIAN
58 +       int i;
59 +       u16 *vmem16 = (u16 *)par->info->screen_base;
60 +       vmem = par->ssbuf;
61 +
62 +       for (i=0; i<WIDTH*HEIGHT*BPP/8/2; i++)
63 +               vmem[i] = swab16(vmem16[i]);
64 +#else
65 +       vmem = (u16 *)par->info->screen_base;
66 +#endif
67  
68         /* Set row/column data window */
69         st7735_set_addr_win(par, 0, 0, WIDTH-1, HEIGHT-1);
70 @@ -261,7 +260,7 @@ static void st7735fb_update_display(struct st7735fb_par *par)
71         st7735_write_cmd(par, ST7735_RAMWR);
72  
73         /* Blast framebuffer to ST7735 internal display RAM */
74 -       ret = st7735_write_data_buf(par, vmem, WIDTH*HEIGHT*BPP/8);
75 +       ret = st7735_write_data_buf(par, (u8 *)vmem, WIDTH*HEIGHT*BPP/8);
76         if (ret < 0)
77                 pr_err("%s: spi_write failed to update display buffer\n",
78                         par->info->fix.id);
79 @@ -369,7 +368,7 @@ static struct fb_ops st7735fb_ops = {
80  };
81  
82  static struct fb_deferred_io st7735fb_defio = {
83 -       .delay          = HZ,
84 +       .delay          = HZ/20,
85         .deferred_io    = st7735fb_deferred_io,
86  };
87  
88 @@ -395,7 +394,11 @@ static int __devinit st7735fb_probe (struct spi_device *spi)
89                 return -EINVAL;
90         }
91  
92 -       vmem = vzalloc(vmem_size);
93 +#ifdef __LITTLE_ENDIAN
94 +       vmem = (u8 *)vmalloc(vmem_size);
95 +#else
96 +       vmem = (u8 *)kmalloc(vmem_size, GFP_KERNEL);
97 +#endif
98         if (!vmem)
99                 return retval;
100  
101 @@ -431,6 +434,14 @@ static int __devinit st7735fb_probe (struct spi_device *spi)
102         par->spi = spi;
103         par->rst = pdata->rst_gpio;
104         par->dc = pdata->dc_gpio;
105 +       par->buf = kmalloc(1, GFP_KERNEL);
107 +#ifdef __LITTLE_ENDIAN
108 +       /* Allocated swapped shadow buffer */
109 +       par->ssbuf = kmalloc(vmem_size, GFP_KERNEL);
110 +       if (!par->ssbuf)
111 +               return retval;
112 +#endif
113  
114         retval = register_framebuffer(info);
115         if (retval < 0)
116 @@ -457,7 +468,11 @@ fbreg_fail:
117         framebuffer_release(info);
118  
119  fballoc_fail:
120 +#ifdef __LITTLE_ENDIAN
121         vfree(vmem);
122 +#else
123 +       kfree(vmem);
124 +#endif
125  
126         return retval;
127  }
128 diff --git a/include/video/st7735fb.h b/include/video/st7735fb.h
129 index 250f036..e99cd05 100644
130 --- a/include/video/st7735fb.h
131 +++ b/include/video/st7735fb.h
132 @@ -36,6 +36,8 @@ struct st7735fb_par {
133         struct fb_info *info;
134         int rst;
135         int dc;
136 +       u16 *ssbuf;
137 +       u8 *buf;
138  };
139  
140  struct st7735fb_platform_data {
141 -- 
142 1.7.10