1 From dc1c33574c4dcf24192cb219ea6caaf2c7804eef Mon Sep 17 00:00:00 2001
2 From: James Hughes <james.hughes@raspberrypi.org>
3 Date: Thu, 10 May 2018 11:34:38 +0100
4 Subject: [PATCH 297/454] Cleanup of bcm2708_fb file to kernel coding standards
6 Some minor change to function - remove a use of
7 in_atomic, plus replacing various debug messages
8 that manually specify the function name with
11 Signed-off-by: James Hughes <james.hughes@raspberrypi.org>
13 drivers/video/fbdev/bcm2708_fb.c | 136 ++++++++++++++++++-------------
14 1 file changed, 81 insertions(+), 55 deletions(-)
16 --- a/drivers/video/fbdev/bcm2708_fb.c
17 +++ b/drivers/video/fbdev/bcm2708_fb.c
19 #define MODULE_NAME "bcm2708_fb"
21 #ifdef BCM2708_FB_DEBUG
22 -#define print_debug(fmt,...) pr_debug("%s:%s:%d: "fmt, MODULE_NAME, __func__, __LINE__, ##__VA_ARGS__)
23 +#define print_debug(fmt, ...) pr_debug("%s:%s:%d: "fmt, \
24 + MODULE_NAME, __func__, __LINE__, ##__VA_ARGS__)
26 -#define print_debug(fmt,...)
27 +#define print_debug(fmt, ...)
30 /* This is limited to 16 characters when displayed by X startup */
31 @@ -51,10 +52,10 @@ static const char *bcm2708_name = "BCM27
33 #define DRIVER_NAME "bcm2708_fb"
35 -static int fbwidth = 800; /* module parameter */
36 -static int fbheight = 480; /* module parameter */
37 -static int fbdepth = 32; /* module parameter */
38 -static int fbswap = 0; /* module parameter */
39 +static int fbwidth = 800; /* module parameter */
40 +static int fbheight = 480; /* module parameter */
41 +static int fbdepth = 32; /* module parameter */
42 +static int fbswap; /* module parameter */
44 static u32 dma_busy_wait_threshold = 1<<15;
45 module_param(dma_busy_wait_threshold, int, 0644);
46 @@ -221,11 +222,13 @@ static int bcm2708_fb_check_var(struct f
49 /* info input, var output */
50 - print_debug("bcm2708_fb_check_var info(%p) %dx%d (%dx%d), %d, %d\n", info,
51 + print_debug("%s(%p) %dx%d (%dx%d), %d, %d\n",
54 info->var.xres, info->var.yres, info->var.xres_virtual,
55 info->var.yres_virtual, (int)info->screen_size,
56 info->var.bits_per_pixel);
57 - print_debug("bcm2708_fb_check_var var(%p) %dx%d (%dx%d), %d\n", var,
58 + print_debug("%s(%p) %dx%d (%dx%d), %d\n", __func__, var,
59 var->xres, var->yres, var->xres_virtual, var->yres_virtual,
62 @@ -233,7 +236,7 @@ static int bcm2708_fb_check_var(struct f
63 var->bits_per_pixel = 16;
65 if (bcm2708_fb_set_bitfields(var) != 0) {
66 - pr_err("bcm2708_fb_check_var: invalid bits_per_pixel %d\n",
67 + pr_err("%s: invalid bits_per_pixel %d\n", __func__,
71 @@ -245,9 +248,8 @@ static int bcm2708_fb_check_var(struct f
72 if (var->yres_virtual == -1) {
73 var->yres_virtual = 480;
76 - ("bcm2708_fb_check_var: virtual resolution set to maximum of %dx%d\n",
77 - var->xres_virtual, var->yres_virtual);
78 + pr_err("%s: virtual resolution set to maximum of %dx%d\n",
79 + __func__, var->xres_virtual, var->yres_virtual);
81 if (var->yres_virtual < var->yres)
82 var->yres_virtual = var->yres;
83 @@ -291,7 +293,7 @@ static int bcm2708_fb_set_par(struct fb_
87 - print_debug("bcm2708_fb_set_par info(%p) %dx%d (%dx%d), %d, %d\n", info,
88 + print_debug("%s(%p) %dx%d (%dx%d), %d, %d\n", __func__, info,
89 info->var.xres, info->var.yres, info->var.xres_virtual,
90 info->var.yres_virtual, (int)info->screen_size,
91 info->var.bits_per_pixel);
92 @@ -326,11 +328,12 @@ static int bcm2708_fb_set_par(struct fb_
97 - ("BCM2708FB: start = %p,%p width=%d, height=%d, bpp=%d, pitch=%d size=%d\n",
98 - (void *)fb->fb.screen_base, (void *)fb->fb_bus_address,
99 - fbinfo.xres, fbinfo.yres, fbinfo.bpp,
100 - fbinfo.pitch, (int)fb->fb.screen_size);
102 + "%s: start = %p,%p width=%d, height=%d, bpp=%d, pitch=%d size=%d\n",
104 + (void *)fb->fb.screen_base, (void *)fb->fb_bus_address,
105 + fbinfo.xres, fbinfo.yres, fbinfo.bpp,
106 + fbinfo.pitch, (int)fb->fb.screen_size);
110 @@ -349,7 +352,6 @@ static int bcm2708_fb_setcolreg(unsigned
112 struct bcm2708_fb *fb = to_bcm2708(info);
114 - /*print_debug("BCM2708FB: setcolreg %d:(%02x,%02x,%02x,%02x) %x\n", regno, red, green, blue, transp, fb->fb.fix.visual);*/
115 if (fb->fb.var.bits_per_pixel <= 8) {
117 /* blue [23:16], green [15:8], red [7:0] */
118 @@ -357,8 +359,12 @@ static int bcm2708_fb_setcolreg(unsigned
119 ((green >> 8) & 0xff) << 8 |
120 ((blue >> 8) & 0xff) << 16;
122 - /* Hack: we need to tell GPU the palette has changed, but currently bcm2708_fb_set_par takes noticable time when called for every (256) colour */
123 - /* So just call it for what looks like the last colour in a list for now. */
124 + /* Hack: we need to tell GPU the palette has changed, but
125 + * currently bcm2708_fb_set_par takes noticeable time when
126 + * called for every (256) colour
127 + * So just call it for what looks like the last colour in a
130 if (regno == 15 || regno == 255) {
133 @@ -372,19 +378,23 @@ static int bcm2708_fb_setcolreg(unsigned
136 packet->length = regno + 1;
137 - memcpy(packet->cmap, fb->gpu_cmap, sizeof(packet->cmap));
138 - ret = rpi_firmware_property(fb->fw, RPI_FIRMWARE_FRAMEBUFFER_SET_PALETTE,
139 - packet, (2 + packet->length) * sizeof(u32));
140 + memcpy(packet->cmap, fb->gpu_cmap,
141 + sizeof(packet->cmap));
142 + ret = rpi_firmware_property(fb->fw,
143 + RPI_FIRMWARE_FRAMEBUFFER_SET_PALETTE,
145 + (2 + packet->length) * sizeof(u32));
146 if (ret || packet->offset)
147 - dev_err(info->device, "Failed to set palette (%d,%u)\n",
148 + dev_err(info->device,
149 + "Failed to set palette (%d,%u)\n",
150 ret, packet->offset);
153 - } else if (regno < 16) {
154 + } else if (regno < 16) {
155 fb->cmap[regno] = convert_bitfield(transp, &fb->fb.var.transp) |
156 - convert_bitfield(blue, &fb->fb.var.blue) |
157 - convert_bitfield(green, &fb->fb.var.green) |
158 - convert_bitfield(red, &fb->fb.var.red);
159 + convert_bitfield(blue, &fb->fb.var.blue) |
160 + convert_bitfield(green, &fb->fb.var.green) |
161 + convert_bitfield(red, &fb->fb.var.red);
165 @@ -412,24 +422,28 @@ static int bcm2708_fb_blank(int blank_mo
166 ret = rpi_firmware_property(fb->fw, RPI_FIRMWARE_FRAMEBUFFER_BLANK,
167 &value, sizeof(value));
169 - dev_err(info->device, "bcm2708_fb_blank(%d) failed: %d\n",
170 + dev_err(info->device, "%s(%d) failed: %d\n", __func__,
176 -static int bcm2708_fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
177 +static int bcm2708_fb_pan_display(struct fb_var_screeninfo *var,
178 + struct fb_info *info)
182 info->var.xoffset = var->xoffset;
183 info->var.yoffset = var->yoffset;
184 result = bcm2708_fb_set_par(info);
186 - pr_err("bcm2708_fb_pan_display(%d,%d) returns=%d\n", var->xoffset, var->yoffset, result);
187 + pr_err("%s(%d,%d) returns=%d\n", __func__,
188 + var->xoffset, var->yoffset, result);
192 -static void dma_memcpy(struct bcm2708_fb *fb, dma_addr_t dst, dma_addr_t src, int size)
193 +static void dma_memcpy(struct bcm2708_fb *fb, dma_addr_t dst, dma_addr_t src,
196 int burst_size = (fb->dma_chan == 0) ? 8 : 2;
197 struct bcm2708_dma_cb *cb = fb->cb_base;
198 @@ -450,6 +464,7 @@ static void dma_memcpy(struct bcm2708_fb
199 bcm_dma_wait_idle(fb->dma_chan_base);
201 void __iomem *dma_chan = fb->dma_chan_base;
203 cb->info |= BCM2708_DMA_INT_EN;
204 bcm_dma_start(fb->dma_chan_base, fb->cb_handle);
205 while (bcm_dma_is_busy(dma_chan)) {
206 @@ -462,8 +477,10 @@ static void dma_memcpy(struct bcm2708_fb
207 fb->stats.dma_copies++;
210 -#define INTALIAS_NORMAL(x) ((x)&~0xc0000000) // address with no aliases
211 -#define INTALIAS_L1L2_NONALLOCATING(x) (((x)&~0xc0000000)|0x80000000) // cache coherent but non-allocating in L1 and L2
212 +/* address with no aliases */
213 +#define INTALIAS_NORMAL(x) ((x)&~0xc0000000)
214 +/* cache coherent but non-allocating in L1 and L2 */
215 +#define INTALIAS_L1L2_NONALLOCATING(x) (((x)&~0xc0000000)|0x80000000)
217 static long vc_mem_copy(struct bcm2708_fb *fb, unsigned long arg)
219 @@ -475,8 +492,7 @@ static long vc_mem_copy(struct bcm2708_f
222 /* restrict this to root user */
223 - if (!uid_eq(current_euid(), GLOBAL_ROOT_UID))
225 + if (!uid_eq(current_euid(), GLOBAL_ROOT_UID)) {
229 @@ -492,12 +508,16 @@ static long vc_mem_copy(struct bcm2708_f
232 if (fb->gpu.base == 0 || fb->gpu.length == 0) {
233 - pr_err("[%s]: Unable to determine gpu memory (%x,%x)\n", __func__, fb->gpu.base, fb->gpu.length);
234 + pr_err("[%s]: Unable to determine gpu memory (%x,%x)\n",
235 + __func__, fb->gpu.base, fb->gpu.length);
239 - if (INTALIAS_NORMAL(ioparam.src) < fb->gpu.base || INTALIAS_NORMAL(ioparam.src) >= fb->gpu.base + fb->gpu.length) {
240 - pr_err("[%s]: Invalid memory access %x (%x-%x)", __func__, INTALIAS_NORMAL(ioparam.src), fb->gpu.base, fb->gpu.base + fb->gpu.length);
241 + if (INTALIAS_NORMAL(ioparam.src) < fb->gpu.base ||
242 + INTALIAS_NORMAL(ioparam.src) >= fb->gpu.base + fb->gpu.length) {
243 + pr_err("[%s]: Invalid memory access %x (%x-%x)", __func__,
244 + INTALIAS_NORMAL(ioparam.src), fb->gpu.base,
245 + fb->gpu.base + fb->gpu.length);
249 @@ -515,7 +535,9 @@ static long vc_mem_copy(struct bcm2708_f
250 size_t s = min(size, remaining);
251 unsigned char *p = (unsigned char *)ioparam.src + offset;
252 unsigned char *q = (unsigned char *)ioparam.dst + offset;
253 - dma_memcpy(fb, bus_addr, INTALIAS_L1L2_NONALLOCATING((dma_addr_t)p), size);
255 + dma_memcpy(fb, bus_addr,
256 + INTALIAS_L1L2_NONALLOCATING((dma_addr_t)p), size);
257 if (copy_to_user(q, buf, s) != 0) {
258 pr_err("[%s]: failed to copy-to-user\n",
260 @@ -525,11 +547,13 @@ static long vc_mem_copy(struct bcm2708_f
264 - dma_free_coherent(fb->fb.device, PAGE_ALIGN(size), buf, bus_addr);
265 + dma_free_coherent(fb->fb.device, PAGE_ALIGN(size), buf,
270 -static int bcm2708_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
271 +static int bcm2708_ioctl(struct fb_info *info, unsigned int cmd,
274 struct bcm2708_fb *fb = to_bcm2708(info);
276 @@ -593,13 +617,13 @@ static void bcm2708_fb_copyarea(struct f
277 struct bcm2708_fb *fb = to_bcm2708(info);
278 struct bcm2708_dma_cb *cb = fb->cb_base;
279 int bytes_per_pixel = (info->var.bits_per_pixel + 7) >> 3;
281 /* Channel 0 supports larger bursts and is a bit faster */
282 int burst_size = (fb->dma_chan == 0) ? 8 : 2;
283 int pixels = region->width * region->height;
285 /* Fallback to cfb_copyarea() if we don't like something */
287 - bytes_per_pixel > 4 ||
288 + if (bytes_per_pixel > 4 ||
289 info->var.xres * info->var.yres > 1920 * 1200 ||
290 region->width <= 0 || region->width > info->var.xres ||
291 region->height <= 0 || region->height > info->var.yres ||
292 @@ -663,6 +687,7 @@ static void bcm2708_fb_copyarea(struct f
294 /* A single dma control block is enough. */
297 if (region->dy <= region->sy) {
298 /* processing from top to bottom */
300 @@ -694,6 +719,7 @@ static void bcm2708_fb_copyarea(struct f
301 bcm_dma_wait_idle(fb->dma_chan_base);
303 void __iomem *dma_chan = fb->dma_chan_base;
305 cb->info |= BCM2708_DMA_INT_EN;
306 bcm_dma_start(fb->dma_chan_base, fb->cb_handle);
307 while (bcm_dma_is_busy(dma_chan)) {
308 @@ -791,8 +817,8 @@ static int bcm2708_fb_register(struct bc
312 - print_debug("BCM2708FB: registering framebuffer (%dx%d@%d) (%d)\n", fbwidth,
313 - fbheight, fbdepth, fbswap);
314 + print_debug("BCM2708FB: registering framebuffer (%dx%d@%d) (%d)\n",
315 + fbwidth, fbheight, fbdepth, fbswap);
317 ret = register_framebuffer(&fb->fb);
318 print_debug("BCM2708FB: register framebuffer (%d)\n", ret);
319 @@ -813,19 +839,17 @@ static int bcm2708_fb_probe(struct platf
321 fw_np = of_parse_phandle(dev->dev.of_node, "firmware", 0);
322 /* Remove comment when booting without Device Tree is no longer supported
324 - dev_err(&dev->dev, "Missing firmware node\n");
329 + * dev_err(&dev->dev, "Missing firmware node\n");
333 fw = rpi_firmware_get(fw_np);
335 return -EPROBE_DEFER;
337 fb = kzalloc(sizeof(struct bcm2708_fb), GFP_KERNEL);
340 - "could not allocate new bcm2708_fb struct\n");
344 @@ -866,7 +890,9 @@ static int bcm2708_fb_probe(struct platf
346 fb->fb.device = &dev->dev;
348 - // failure here isn't fatal, but we'll fail in vc_mem_copy if fb->gpu is not valid
349 + /* failure here isn't fatal, but we'll fail in vc_mem_copy if
350 + * fb->gpu is not valid
352 rpi_firmware_property(fb->fw,
353 RPI_FIRMWARE_GET_VC_MEMORY,
354 &fb->gpu, sizeof(fb->gpu));