Date: | 2010-06-01 10:58:19 (13 years 9 months ago) |
---|---|
Author: | Lars C. |
Commit: | f6cda2a5e148d58a142bb5bd0e0b9512ee1fa349 |
Message: | jz4740: fb: Small cleanups |
Files: |
drivers/video/jz4740_fb.c (8 diffs) |
Change Details
drivers/video/jz4740_fb.c | ||
---|---|---|
146 | 146 | .accel = FB_ACCEL_NONE, |
147 | 147 | }; |
148 | 148 | |
149 | const static struct jz_gpio_bulk_request jz_lcd_ctrl_pins[] = { | |
149 | static const struct jz_gpio_bulk_request jz_lcd_ctrl_pins[] = { | |
150 | 150 | JZ_GPIO_BULK_PIN(LCD_PCLK), |
151 | 151 | JZ_GPIO_BULK_PIN(LCD_HSYNC), |
152 | 152 | JZ_GPIO_BULK_PIN(LCD_VSYNC), |
... | ... | |
155 | 155 | JZ_GPIO_BULK_PIN(LCD_REV), |
156 | 156 | }; |
157 | 157 | |
158 | const static struct jz_gpio_bulk_request jz_lcd_data_pins[] = { | |
158 | static const struct jz_gpio_bulk_request jz_lcd_data_pins[] = { | |
159 | 159 | JZ_GPIO_BULK_PIN(LCD_DATA0), |
160 | 160 | JZ_GPIO_BULK_PIN(LCD_DATA1), |
161 | 161 | JZ_GPIO_BULK_PIN(LCD_DATA2), |
... | ... | |
218 | 218 | return num; |
219 | 219 | } |
220 | 220 | |
221 | /* Based on CNVT_TOHW macro from skeletonfb.c */ | |
222 | static inline uint32_t jzfb_convert_color_to_hw(unsigned val, | |
223 | struct fb_bitfield *bf) | |
224 | { | |
225 | return (((val << bf->length) + 0x7FFF - val) >> 16) << bf->offset; | |
226 | } | |
227 | ||
221 | 228 | static int jzfb_setcolreg(unsigned regno, unsigned red, unsigned green, |
222 | 229 | unsigned blue, unsigned transp, struct fb_info *fb) |
223 | 230 | { |
... | ... | |
226 | 233 | if (regno >= 16) |
227 | 234 | return -EINVAL; |
228 | 235 | |
229 | #define CNVT_TOHW(val,width) ((((val)<<(width))+0x7FFF-(val))>>16) | |
230 | red = CNVT_TOHW(red, fb->var.red.length); | |
231 | green = CNVT_TOHW(green, fb->var.green.length); | |
232 | blue = CNVT_TOHW(blue, fb->var.blue.length); | |
233 | transp = CNVT_TOHW(transp, fb->var.transp.length); | |
234 | #undef CNVT_TOHW | |
236 | color = jzfb_convert_color_to_hw(red, fb->var.red.length); | |
237 | color |= jzfb_convert_color_to_hw(green, fb->var.green.length); | |
238 | color |= jzfb_convert_color_to_hw(blue, fb->var.blue.length); | |
239 | color |= jzfb_convert_color_to_hw(transp, fb->var.transp.length); | |
235 | 240 | |
236 | color = (red << fb->var.red.offset) | | |
237 | (green << fb->var.green.offset) | | |
238 | (blue << fb->var.blue.offset) | | |
239 | (transp << fb->var.transp.offset); | |
240 | ||
241 | ((uint32_t*)(fb->pseudo_palette))[regno] = color; | |
241 | ((uint32_t *)(fb->pseudo_palette))[regno] = color; | |
242 | 242 | |
243 | 243 | return 0; |
244 | 244 | } |
... | ... | |
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | static struct fb_videomode *jzfb_get_mode(struct jzfb *jzfb, struct fb_var_screeninfo *var) | |
259 | static struct fb_videomode *jzfb_get_mode(struct jzfb *jzfb, | |
260 | struct fb_var_screeninfo *var) | |
260 | 261 | { |
261 | 262 | size_t i; |
262 | 263 | struct fb_videomode *mode = jzfb->pdata->modes; |
... | ... | |
535 | 536 | max_videosize *= jzfb_get_controller_bpp(jzfb) >> 3; |
536 | 537 | |
537 | 538 | jzfb->framedesc = dma_alloc_coherent(&jzfb->pdev->dev, |
538 | sizeof(*jzfb->framedesc), | |
539 | &jzfb->framedesc_phys, GFP_KERNEL); | |
539 | sizeof(*jzfb->framedesc), | |
540 | &jzfb->framedesc_phys, GFP_KERNEL); | |
540 | 541 | |
541 | 542 | if (!jzfb->framedesc) |
542 | 543 | return -ENOMEM; |
543 | 544 | |
544 | 545 | jzfb->vidmem_size = PAGE_ALIGN(max_videosize); |
545 | 546 | jzfb->vidmem = dma_alloc_coherent(&jzfb->pdev->dev, |
546 | jzfb->vidmem_size, | |
547 | &jzfb->vidmem_phys, GFP_KERNEL); | |
547 | jzfb->vidmem_size, | |
548 | &jzfb->vidmem_phys, GFP_KERNEL); | |
548 | 549 | |
549 | 550 | if (!jzfb->vidmem) |
550 | 551 | goto err_free_framedesc; |
... | ... | |
555 | 556 | SetPageReserved(virt_to_page(page)); |
556 | 557 | } |
557 | 558 | |
558 | ||
559 | 559 | jzfb->framedesc->next = jzfb->framedesc_phys; |
560 | 560 | jzfb->framedesc->addr = jzfb->vidmem_phys; |
561 | 561 | jzfb->framedesc->id = 0xdeafbead; |
... | ... | |
603 | 603 | } |
604 | 604 | |
605 | 605 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
606 | ||
607 | 606 | if (!mem) { |
608 | 607 | dev_err(&pdev->dev, "Failed to get register memory resource\n"); |
609 | 608 | return -ENOENT; |
610 | 609 | } |
611 | 610 | |
612 | 611 | mem = request_mem_region(mem->start, resource_size(mem), pdev->name); |
613 | ||
614 | 612 | if (!mem) { |
615 | 613 | dev_err(&pdev->dev, "Failed to request register memory region\n"); |
616 | 614 | return -EBUSY; |
617 | 615 | } |
618 | 616 | |
619 | ||
620 | 617 | fb = framebuffer_alloc(sizeof(struct jzfb), &pdev->dev); |
621 | ||
622 | 618 | if (!fb) { |
623 | 619 | dev_err(&pdev->dev, "Failed to allocate framebuffer device\n"); |
624 | 620 | ret = -ENOMEM; |
Branches:
ben-wpan
ben-wpan-stefan
5396a9238205f20f811ea57898980d3ca82df0b6
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9