Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fbdev/stifb: Allocate fb_info instance with framebuffer_alloc()

Allocate stifb's instance of fb_info with framebuffer_alloc(). This
is the preferred way of creating fb_info with associated driver data
stored in struct fb_info.par. Requires several, but minor, changes
through out the driver's code.

The intended side effect of this patch is that the new instance of
struct fb_info now has its device field correctly set to the parent
device of the STI ROM. A later patch can detect if the device is the
firmware's primary output. It is also now correctly located within
the Linux device hierarchy.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Tested-by: Helge Deller <deller@gmx.de>
Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Helge Deller <deller@gmx.de>

authored by

Thomas Zimmermann and committed by
Helge Deller
b3621797 12b8de56

+56 -50
+56 -50
drivers/video/fbdev/stifb.c
··· 103 103 } ngle_rom_t; 104 104 105 105 struct stifb_info { 106 - struct fb_info info; 106 + struct fb_info *info; 107 107 unsigned int id; 108 108 ngle_rom_t ngle_rom; 109 109 struct sti_struct *sti; ··· 153 153 #define REG_44 0x210030 154 154 #define REG_45 0x210034 155 155 156 - #define READ_BYTE(fb,reg) gsc_readb((fb)->info.fix.mmio_start + (reg)) 157 - #define READ_WORD(fb,reg) gsc_readl((fb)->info.fix.mmio_start + (reg)) 156 + #define READ_BYTE(fb, reg) gsc_readb((fb)->info->fix.mmio_start + (reg)) 157 + #define READ_WORD(fb, reg) gsc_readl((fb)->info->fix.mmio_start + (reg)) 158 158 159 159 160 160 #ifndef DEBUG_STIFB_REGS 161 161 # define DEBUG_OFF() 162 162 # define DEBUG_ON() 163 - # define WRITE_BYTE(value,fb,reg) gsc_writeb((value),(fb)->info.fix.mmio_start + (reg)) 164 - # define WRITE_WORD(value,fb,reg) gsc_writel((value),(fb)->info.fix.mmio_start + (reg)) 163 + # define WRITE_BYTE(value, fb, reg) gsc_writeb((value), (fb)->info->fix.mmio_start + (reg)) 164 + # define WRITE_WORD(value, fb, reg) gsc_writel((value), (fb)->info->fix.mmio_start + (reg)) 165 165 #else 166 166 static int debug_on = 1; 167 167 # define DEBUG_OFF() debug_on=0 ··· 169 169 # define WRITE_BYTE(value,fb,reg) do { if (debug_on) \ 170 170 printk(KERN_DEBUG "%30s: WRITE_BYTE(0x%06x) = 0x%02x (old=0x%02x)\n", \ 171 171 __func__, reg, value, READ_BYTE(fb,reg)); \ 172 - gsc_writeb((value),(fb)->info.fix.mmio_start + (reg)); } while (0) 172 + gsc_writeb((value), (fb)->info->fix.mmio_start + (reg)); } while (0) 173 173 # define WRITE_WORD(value,fb,reg) do { if (debug_on) \ 174 174 printk(KERN_DEBUG "%30s: WRITE_WORD(0x%06x) = 0x%08x (old=0x%08x)\n", \ 175 175 __func__, reg, value, READ_WORD(fb,reg)); \ 176 - gsc_writel((value),(fb)->info.fix.mmio_start + (reg)); } while (0) 176 + gsc_writel((value), (fb)->info->fix.mmio_start + (reg)); } while (0) 177 177 #endif /* DEBUG_STIFB_REGS */ 178 178 179 179 ··· 210 210 reg10_value = 0x13601000; 211 211 break; 212 212 case S9000_ID_A1439A: 213 - if (fb->info.var.bits_per_pixel == 32) 213 + if (fb->info->var.bits_per_pixel == 32) 214 214 reg10_value = 0xBBA0A000; 215 215 else 216 216 reg10_value = 0x13601000; 217 217 break; 218 218 case S9000_ID_HCRX: 219 - if (fb->info.var.bits_per_pixel == 32) 219 + if (fb->info->var.bits_per_pixel == 32) 220 220 reg10_value = 0xBBA0A000; 221 221 else 222 222 reg10_value = 0x13602000; ··· 254 254 FINISH_IMAGE_COLORMAP_ACCESS(struct stifb_info *fb) 255 255 { 256 256 WRITE_WORD(0x400, fb, REG_2); 257 - if (fb->info.var.bits_per_pixel == 32) { 257 + if (fb->info->var.bits_per_pixel == 32) { 258 258 WRITE_WORD(0x83000100, fb, REG_1); 259 259 } else { 260 260 if (fb->id == S9000_ID_ARTIST || fb->id == CRT_ID_VISUALIZE_EG) ··· 503 503 ngleSetupAttrPlanes(struct stifb_info *fb, int BufferNumber) 504 504 { 505 505 SETUP_ATTR_ACCESS(fb, BufferNumber); 506 - SET_ATTR_SIZE(fb, fb->info.var.xres, fb->info.var.yres); 506 + SET_ATTR_SIZE(fb, fb->info->var.xres, fb->info->var.yres); 507 507 FINISH_ATTR_ACCESS(fb); 508 508 SETUP_FB(fb); 509 509 } ··· 526 526 SETUP_FB(fb); 527 527 fb->id = saved_id; 528 528 529 - for (y = 0; y < fb->info.var.yres; ++y) 530 - fb_memset_io(fb->info.screen_base + y * fb->info.fix.line_length, 531 - 0xff, fb->info.var.xres * fb->info.var.bits_per_pixel/8); 529 + for (y = 0; y < fb->info->var.yres; ++y) 530 + fb_memset_io(fb->info->screen_base + y * fb->info->fix.line_length, 531 + 0xff, fb->info->var.xres * fb->info->var.bits_per_pixel/8); 532 532 533 533 CRX24_SET_OVLY_MASK(fb); 534 534 SETUP_FB(fb); ··· 607 607 lutBltCtl.fields.lutType = HYPER_CMAP_TYPE; 608 608 609 609 /* Expect lutIndex to be 0 or 1 for image cmaps, 2 or 3 for overlay cmaps */ 610 - if (fb->info.var.bits_per_pixel == 8) 610 + if (fb->info->var.bits_per_pixel == 8) 611 611 lutBltCtl.fields.lutOffset = 2 * 256; 612 612 else 613 613 lutBltCtl.fields.lutOffset = 0 * 256; ··· 688 688 DataDynamic, MaskOtc, 689 689 BGx(0), FGx(0))); 690 690 packed_dst = 0; 691 - packed_len = (fb->info.var.xres << 16) | fb->info.var.yres; 691 + packed_len = (fb->info->var.xres << 16) | fb->info->var.yres; 692 692 GET_FIFO_SLOTS(fb, nFreeFifoSlots, 2); 693 693 NGLE_SET_DSTXY(fb, packed_dst); 694 694 SET_LENXY_START_RECFILL(fb, packed_len); ··· 738 738 NGLE_REALLY_SET_IMAGE_PLANEMASK(fb, mask); 739 739 740 740 packed_dst = 0; 741 - packed_len = (fb->info.var.xres << 16) | fb->info.var.yres; 741 + packed_len = (fb->info->var.xres << 16) | fb->info->var.yres; 742 742 NGLE_SET_DSTXY(fb, packed_dst); 743 743 744 744 /* Write zeroes to overlay planes */ ··· 760 760 NGLE_LOCK(fb); 761 761 762 762 if (IS_24_DEVICE(fb)) 763 - if (fb->info.var.bits_per_pixel == 32) 763 + if (fb->info->var.bits_per_pixel == 32) 764 764 controlPlaneReg = 0x04000F00; 765 765 else 766 766 controlPlaneReg = 0x00000F00; /* 0x00000800 should be enough, but lets clear all 4 bits */ ··· 890 890 GET_FIFO_SLOTS(fb, nFreeFifoSlots, 7); 891 891 892 892 if (IS_24_DEVICE(fb)) { 893 - hyperbowl = (fb->info.var.bits_per_pixel == 32) ? 893 + hyperbowl = (fb->info->var.bits_per_pixel == 32) ? 894 894 HYPERBOWL_MODE01_8_24_LUT0_TRANSPARENT_LUT1_OPAQUE : 895 895 HYPERBOWL_MODE01_8_24_LUT0_OPAQUE_LUT1_OPAQUE; 896 896 ··· 924 924 static int 925 925 stifb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) 926 926 { 927 - struct stifb_info *fb = container_of(info, struct stifb_info, info); 927 + struct stifb_info *fb = info->par; 928 928 929 - if (var->xres != fb->info.var.xres || 930 - var->yres != fb->info.var.yres || 931 - var->bits_per_pixel != fb->info.var.bits_per_pixel) 929 + if (var->xres != fb->info->var.xres || 930 + var->yres != fb->info->var.yres || 931 + var->bits_per_pixel != fb->info->var.bits_per_pixel) 932 932 return -EINVAL; 933 933 934 934 var->xres_virtual = var->xres; 935 935 var->yres_virtual = var->yres; 936 936 var->xoffset = 0; 937 937 var->yoffset = 0; 938 - var->grayscale = fb->info.var.grayscale; 939 - var->red.length = fb->info.var.red.length; 940 - var->green.length = fb->info.var.green.length; 941 - var->blue.length = fb->info.var.blue.length; 938 + var->grayscale = fb->info->var.grayscale; 939 + var->red.length = fb->info->var.red.length; 940 + var->green.length = fb->info->var.green.length; 941 + var->blue.length = fb->info->var.blue.length; 942 942 943 943 return 0; 944 944 } ··· 947 947 stifb_setcolreg(u_int regno, u_int red, u_int green, 948 948 u_int blue, u_int transp, struct fb_info *info) 949 949 { 950 - struct stifb_info *fb = container_of(info, struct stifb_info, info); 950 + struct stifb_info *fb = info->par; 951 951 u32 color; 952 952 953 953 if (regno >= NR_PALETTE) ··· 961 961 962 962 START_IMAGE_COLORMAP_ACCESS(fb); 963 963 964 - if (unlikely(fb->info.var.grayscale)) { 964 + if (unlikely(fb->info->var.grayscale)) { 965 965 /* gray = 0.30*R + 0.59*G + 0.11*B */ 966 966 color = ((red * 77) + 967 967 (green * 151) + ··· 972 972 (blue)); 973 973 } 974 974 975 - if (fb->info.fix.visual == FB_VISUAL_DIRECTCOLOR) { 976 - struct fb_var_screeninfo *var = &fb->info.var; 975 + if (fb->info->fix.visual == FB_VISUAL_DIRECTCOLOR) { 976 + struct fb_var_screeninfo *var = &fb->info->var; 977 977 if (regno < 16) 978 - ((u32 *)fb->info.pseudo_palette)[regno] = 978 + ((u32 *)fb->info->pseudo_palette)[regno] = 979 979 regno << var->red.offset | 980 980 regno << var->green.offset | 981 981 regno << var->blue.offset; ··· 1007 1007 static int 1008 1008 stifb_blank(int blank_mode, struct fb_info *info) 1009 1009 { 1010 - struct stifb_info *fb = container_of(info, struct stifb_info, info); 1010 + struct stifb_info *fb = info->par; 1011 1011 int enable = (blank_mode == 0) ? ENABLE : DISABLE; 1012 1012 1013 1013 switch (fb->id) { ··· 1036 1036 static void 1037 1037 stifb_copyarea(struct fb_info *info, const struct fb_copyarea *area) 1038 1038 { 1039 - struct stifb_info *fb = container_of(info, struct stifb_info, info); 1039 + struct stifb_info *fb = info->par; 1040 1040 1041 1041 SETUP_COPYAREA(fb); 1042 1042 1043 1043 SETUP_HW(fb); 1044 - if (fb->info.var.bits_per_pixel == 32) { 1044 + if (fb->info->var.bits_per_pixel == 32) { 1045 1045 WRITE_WORD(0xBBA0A000, fb, REG_10); 1046 1046 1047 1047 NGLE_REALLY_SET_IMAGE_PLANEMASK(fb, 0xffffffff); ··· 1075 1075 static void 1076 1076 stifb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) 1077 1077 { 1078 - struct stifb_info *fb = container_of(info, struct stifb_info, info); 1078 + struct stifb_info *fb = info->par; 1079 1079 1080 1080 if (rect->rop != ROP_COPY || 1081 - (fb->id == S9000_ID_HCRX && fb->info.var.bits_per_pixel == 32)) 1081 + (fb->id == S9000_ID_HCRX && fb->info->var.bits_per_pixel == 32)) 1082 1082 return cfb_fillrect(info, rect); 1083 1083 1084 1084 SETUP_HW(fb); 1085 1085 1086 - if (fb->info.var.bits_per_pixel == 32) { 1086 + if (fb->info->var.bits_per_pixel == 32) { 1087 1087 WRITE_WORD(0xBBA0A000, fb, REG_10); 1088 1088 1089 1089 NGLE_REALLY_SET_IMAGE_PLANEMASK(fb, 0xffffffff); ··· 1141 1141 switch (id) { 1142 1142 case S9000_ID_A1659A: 1143 1143 case S9000_ID_A1439A: 1144 - if (fb->info.var.bits_per_pixel == 32) 1144 + if (fb->info->var.bits_per_pixel == 32) 1145 1145 ngleSetupAttrPlanes(fb, BUFF1_CMAP3); 1146 1146 else { 1147 1147 ngleSetupAttrPlanes(fb, BUFF1_CMAP0); ··· 1151 1151 break; 1152 1152 case S9000_ID_ARTIST: 1153 1153 case CRT_ID_VISUALIZE_EG: 1154 - if (fb->info.var.bits_per_pixel == 32) 1154 + if (fb->info->var.bits_per_pixel == 32) 1155 1155 ngleSetupAttrPlanes(fb, BUFF1_CMAP3); 1156 1156 else { 1157 1157 ngleSetupAttrPlanes(fb, ARTIST_CMAP0); ··· 1193 1193 char *dev_name; 1194 1194 int bpp, xres, yres; 1195 1195 1196 - fb = kzalloc(sizeof(*fb), GFP_ATOMIC); 1197 - if (!fb) 1196 + info = framebuffer_alloc(sizeof(*fb), sti->dev); 1197 + if (!info) 1198 1198 return -ENOMEM; 1199 - 1200 - info = &fb->info; 1199 + fb = info->par; 1200 + fb->info = info; 1201 1201 1202 1202 /* set struct to a known state */ 1203 1203 fix = &info->fix; ··· 1390 1390 1391 1391 /* save for primary gfx device detection & unregister_framebuffer() */ 1392 1392 sti->info = info; 1393 - if (register_framebuffer(&fb->info) < 0) 1393 + if (register_framebuffer(fb->info) < 0) 1394 1394 goto out_err4; 1395 1395 1396 - fb_info(&fb->info, "%s %dx%d-%d frame buffer device, %s, id: %04x, mmio: 0x%04lx\n", 1396 + fb_info(fb->info, "%s %dx%d-%d frame buffer device, %s, id: %04x, mmio: 0x%04lx\n", 1397 1397 fix->id, 1398 1398 var->xres, 1399 1399 var->yres, ··· 1401 1401 dev_name, 1402 1402 fb->id, 1403 1403 fix->mmio_start); 1404 + 1405 + dev_set_drvdata(sti->dev, info); 1404 1406 1405 1407 return 0; 1406 1408 ··· 1416 1414 out_err1: 1417 1415 iounmap(info->screen_base); 1418 1416 out_err0: 1419 - kfree(fb); 1417 + framebuffer_release(info); 1420 1418 sti->info = NULL; 1421 1419 return -ENXIO; 1422 1420 } ··· 1482 1480 sti = sti_get_rom(i); 1483 1481 if (!sti) 1484 1482 break; 1485 - if (sti->info) { 1486 - struct fb_info *info = sti->info; 1487 - unregister_framebuffer(sti->info); 1483 + if (sti->dev) { 1484 + struct fb_info *info = dev_get_drvdata(sti->dev); 1485 + 1486 + if (!info) 1487 + continue; 1488 + unregister_framebuffer(info); 1488 1489 release_mem_region(info->fix.mmio_start, info->fix.mmio_len); 1489 1490 release_mem_region(info->fix.smem_start, info->fix.smem_len); 1490 1491 if (info->screen_base) 1491 1492 iounmap(info->screen_base); 1492 1493 fb_dealloc_cmap(&info->cmap); 1493 1494 framebuffer_release(info); 1495 + dev_set_drvdata(sti->dev, NULL); 1494 1496 } 1495 1497 sti->info = NULL; 1496 1498 }