Mike Rapoport | 67088d4 | 2015-09-22 12:01:16 +0300 | [diff] [blame] | 1 | #include <linux/kernel.h> |
| 2 | #include <linux/module.h> |
| 3 | #include <linux/errno.h> |
| 4 | #include <linux/string.h> |
| 5 | #include <linux/mm.h> |
| 6 | #include <linux/slab.h> |
| 7 | #include <linux/delay.h> |
| 8 | #include <linux/fb.h> |
| 9 | #include <linux/ioport.h> |
| 10 | #include <linux/init.h> |
| 11 | #include <linux/pci.h> |
| 12 | #include <linux/mm_types.h> |
| 13 | #include <linux/vmalloc.h> |
| 14 | #include <linux/pagemap.h> |
| 15 | #include <linux/screen_info.h> |
| 16 | #include <linux/vmalloc.h> |
| 17 | #include <linux/pagemap.h> |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 18 | #include <linux/console.h> |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 19 | #include <asm/fb.h> |
| 20 | #include "sm750.h" |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 21 | #include "sm750_accel.h" |
| 22 | #include "sm750_cursor.h" |
| 23 | |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 24 | /* |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 25 | * #ifdef __BIG_ENDIAN |
| 26 | * ssize_t lynxfb_ops_write(struct fb_info *info, const char __user *buf, |
| 27 | * size_t count, loff_t *ppos); |
| 28 | * ssize_t lynxfb_ops_read(struct fb_info *info, char __user *buf, |
| 29 | * size_t count, loff_t *ppos); |
| 30 | * #endif |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 31 | */ |
| 32 | |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 33 | /* common var for all device */ |
| 34 | static int g_hwcursor = 1; |
Supriya Karanth | b30edfc | 2015-03-12 13:26:21 +0900 | [diff] [blame] | 35 | static int g_noaccel; |
Supriya Karanth | b30edfc | 2015-03-12 13:26:21 +0900 | [diff] [blame] | 36 | static int g_nomtrr; |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 37 | static const char *g_fbmode[] = {NULL, NULL}; |
| 38 | static const char *g_def_fbmode = "800x600-16@60"; |
Vinay Simha BN | df52568 | 2015-07-14 19:15:28 +0530 | [diff] [blame] | 39 | static char *g_settings; |
Supriya Karanth | b30edfc | 2015-03-12 13:26:21 +0900 | [diff] [blame] | 40 | static int g_dualview; |
Vinay Simha BN | df52568 | 2015-07-14 19:15:28 +0530 | [diff] [blame] | 41 | static char *g_option; |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 42 | |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 43 | static const struct fb_videomode lynx750_ext[] = { |
Michel von Czettritz | 4bd9503 | 2015-03-26 23:26:04 +0100 | [diff] [blame] | 44 | /* 1024x600-60 VESA [1.71:1] */ |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 45 | {NULL, 60, 1024, 600, 20423, 144, 40, 18, 1, 104, 3, |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 46 | FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
| 47 | FB_VMODE_NONINTERLACED}, |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 48 | |
Michel von Czettritz | 4bd9503 | 2015-03-26 23:26:04 +0100 | [diff] [blame] | 49 | /* 1024x600-70 VESA */ |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 50 | {NULL, 70, 1024, 600, 17211, 152, 48, 21, 1, 104, 3, |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 51 | FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
| 52 | FB_VMODE_NONINTERLACED}, |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 53 | |
Michel von Czettritz | 4bd9503 | 2015-03-26 23:26:04 +0100 | [diff] [blame] | 54 | /* 1024x600-75 VESA */ |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 55 | {NULL, 75, 1024, 600, 15822, 160, 56, 23, 1, 104, 3, |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 56 | FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
| 57 | FB_VMODE_NONINTERLACED}, |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 58 | |
Michel von Czettritz | 4bd9503 | 2015-03-26 23:26:04 +0100 | [diff] [blame] | 59 | /* 1024x600-85 VESA */ |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 60 | {NULL, 85, 1024, 600, 13730, 168, 56, 26, 1, 112, 3, |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 61 | FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
| 62 | FB_VMODE_NONINTERLACED}, |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 63 | |
| 64 | /* 720x480 */ |
| 65 | {NULL, 60, 720, 480, 37427, 88, 16, 13, 1, 72, 3, |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 66 | FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
| 67 | FB_VMODE_NONINTERLACED}, |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 68 | |
| 69 | /* 1280x720 [1.78:1] */ |
| 70 | {NULL, 60, 1280, 720, 13426, 162, 86, 22, 1, 136, 3, |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 71 | FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
| 72 | FB_VMODE_NONINTERLACED}, |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 73 | |
Michel von Czettritz | 4bd9503 | 2015-03-26 23:26:04 +0100 | [diff] [blame] | 74 | /* 1280x768@60 */ |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 75 | {NULL, 60, 1280, 768, 12579, 192, 64, 20, 3, 128, 7, |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 76 | FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
| 77 | FB_VMODE_NONINTERLACED}, |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 78 | |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 79 | /* 1360 x 768 [1.77083:1] */ |
| 80 | {NULL, 60, 1360, 768, 11804, 208, 64, 23, 1, 144, 3, |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 81 | FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
| 82 | FB_VMODE_NONINTERLACED}, |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 83 | |
| 84 | /* 1368 x 768 [1.78:1] */ |
| 85 | {NULL, 60, 1368, 768, 11647, 216, 72, 23, 1, 144, 3, |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 86 | FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
| 87 | FB_VMODE_NONINTERLACED}, |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 88 | |
Michel von Czettritz | 4bd9503 | 2015-03-26 23:26:04 +0100 | [diff] [blame] | 89 | /* 1440 x 900 [16:10] */ |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 90 | {NULL, 60, 1440, 900, 9392, 232, 80, 28, 1, 152, 3, |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 91 | FB_SYNC_VERT_HIGH_ACT, |
| 92 | FB_VMODE_NONINTERLACED}, |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 93 | |
| 94 | /* 1440x960 [15:10] */ |
| 95 | {NULL, 60, 1440, 960, 8733, 240, 88, 30, 1, 152, 3, |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 96 | FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
| 97 | FB_VMODE_NONINTERLACED}, |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 98 | |
| 99 | /* 1920x1080 [16:9] */ |
| 100 | {NULL, 60, 1920, 1080, 6734, 148, 88, 41, 1, 44, 3, |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 101 | FB_SYNC_VERT_HIGH_ACT, |
| 102 | FB_VMODE_NONINTERLACED}, |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 103 | }; |
| 104 | |
| 105 | |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 106 | /* no hardware cursor supported under version 2.6.10, kernel bug */ |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 107 | static int lynxfb_ops_cursor(struct fb_info *info, struct fb_cursor *fbcursor) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 108 | { |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 109 | struct lynxfb_par *par; |
| 110 | struct lynxfb_crtc *crtc; |
| 111 | struct lynx_cursor *cursor; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 112 | |
| 113 | par = info->par; |
| 114 | crtc = &par->crtc; |
| 115 | cursor = &crtc->cursor; |
| 116 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 117 | if (fbcursor->image.width > cursor->maxW || |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 118 | fbcursor->image.height > cursor->maxH || |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 119 | fbcursor->image.depth > 1) { |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 120 | return -ENXIO; |
| 121 | } |
| 122 | |
Mike Rapoport | fb7f405 | 2015-10-26 09:05:50 +0200 | [diff] [blame] | 123 | hw_cursor_disable(cursor); |
Michel von Czettritz | f46a04c | 2015-03-27 19:42:48 +0100 | [diff] [blame] | 124 | if (fbcursor->set & FB_CUR_SETSIZE) |
Mike Rapoport | fb7f405 | 2015-10-26 09:05:50 +0200 | [diff] [blame] | 125 | hw_cursor_setSize(cursor, |
| 126 | fbcursor->image.width, |
| 127 | fbcursor->image.height); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 128 | |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 129 | if (fbcursor->set & FB_CUR_SETPOS) |
Mike Rapoport | fb7f405 | 2015-10-26 09:05:50 +0200 | [diff] [blame] | 130 | hw_cursor_setPos(cursor, |
| 131 | fbcursor->image.dx - info->var.xoffset, |
| 132 | fbcursor->image.dy - info->var.yoffset); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 133 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 134 | if (fbcursor->set & FB_CUR_SETCMAP) { |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 135 | /* get the 16bit color of kernel means */ |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 136 | u16 fg, bg; |
Michel von Czettritz | 876e5a7 | 2015-03-26 23:26:37 +0100 | [diff] [blame] | 137 | |
Sudip Mukherjee | 13ef345 | 2015-08-07 17:34:03 +0530 | [diff] [blame] | 138 | fg = ((info->cmap.red[fbcursor->image.fg_color] & 0xf800)) | |
| 139 | ((info->cmap.green[fbcursor->image.fg_color] & 0xfc00) >> 5) | |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 140 | ((info->cmap.blue[fbcursor->image.fg_color] & 0xf800) >> 11); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 141 | |
Sudip Mukherjee | 13ef345 | 2015-08-07 17:34:03 +0530 | [diff] [blame] | 142 | bg = ((info->cmap.red[fbcursor->image.bg_color] & 0xf800)) | |
| 143 | ((info->cmap.green[fbcursor->image.bg_color] & 0xfc00) >> 5) | |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 144 | ((info->cmap.blue[fbcursor->image.bg_color] & 0xf800) >> 11); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 145 | |
Mike Rapoport | fb7f405 | 2015-10-26 09:05:50 +0200 | [diff] [blame] | 146 | hw_cursor_setColor(cursor, fg, bg); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 147 | } |
| 148 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 149 | if (fbcursor->set & (FB_CUR_SETSHAPE | FB_CUR_SETIMAGE)) { |
Mike Rapoport | fb7f405 | 2015-10-26 09:05:50 +0200 | [diff] [blame] | 150 | hw_cursor_setData(cursor, |
| 151 | fbcursor->rop, |
| 152 | fbcursor->image.data, |
| 153 | fbcursor->mask); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 154 | } |
| 155 | |
Michel von Czettritz | f46a04c | 2015-03-27 19:42:48 +0100 | [diff] [blame] | 156 | if (fbcursor->enable) |
Mike Rapoport | fb7f405 | 2015-10-26 09:05:50 +0200 | [diff] [blame] | 157 | hw_cursor_enable(cursor); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 158 | |
| 159 | return 0; |
| 160 | } |
| 161 | |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 162 | static void lynxfb_ops_fillrect(struct fb_info *info, |
| 163 | const struct fb_fillrect *region) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 164 | { |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 165 | struct lynxfb_par *par; |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 166 | struct sm750_dev *sm750_dev; |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 167 | unsigned int base, pitch, Bpp, rop; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 168 | u32 color; |
| 169 | |
Michel von Czettritz | f46a04c | 2015-03-27 19:42:48 +0100 | [diff] [blame] | 170 | if (info->state != FBINFO_STATE_RUNNING) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 171 | return; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 172 | |
| 173 | par = info->par; |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 174 | sm750_dev = par->dev; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 175 | |
Sudip Mukherjee | d11ac7c | 2015-08-07 17:34:04 +0530 | [diff] [blame] | 176 | /* |
| 177 | * each time 2d function begin to work,below three variable always need |
| 178 | * be set, seems we can put them together in some place |
| 179 | */ |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 180 | base = par->crtc.oScreen; |
| 181 | pitch = info->fix.line_length; |
| 182 | Bpp = info->var.bits_per_pixel >> 3; |
| 183 | |
Sudip Mukherjee | 13ef345 | 2015-08-07 17:34:03 +0530 | [diff] [blame] | 184 | color = (Bpp == 1) ? region->color : |
| 185 | ((u32 *)info->pseudo_palette)[region->color]; |
| 186 | rop = (region->rop != ROP_COPY) ? HW_ROP2_XOR : HW_ROP2_COPY; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 187 | |
Lorenzo Stoakes | cb422f3 | 2015-03-20 15:22:15 +0000 | [diff] [blame] | 188 | /* |
| 189 | * If not use spin_lock,system will die if user load driver |
Carlos E. Garcia | 69e98df | 2015-04-24 09:40:42 -0400 | [diff] [blame] | 190 | * and immediately unload driver frequently (dual) |
Lorenzo Stoakes | cb422f3 | 2015-03-20 15:22:15 +0000 | [diff] [blame] | 191 | */ |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 192 | if (sm750_dev->dual) |
| 193 | spin_lock(&sm750_dev->slock); |
Lorenzo Stoakes | cb422f3 | 2015-03-20 15:22:15 +0000 | [diff] [blame] | 194 | |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 195 | sm750_dev->accel.de_fillrect(&sm750_dev->accel, |
| 196 | base, pitch, Bpp, |
| 197 | region->dx, region->dy, |
| 198 | region->width, region->height, |
| 199 | color, rop); |
| 200 | if (sm750_dev->dual) |
| 201 | spin_unlock(&sm750_dev->slock); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 202 | } |
| 203 | |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 204 | static void lynxfb_ops_copyarea(struct fb_info *info, |
| 205 | const struct fb_copyarea *region) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 206 | { |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 207 | struct lynxfb_par *par; |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 208 | struct sm750_dev *sm750_dev; |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 209 | unsigned int base, pitch, Bpp; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 210 | |
| 211 | par = info->par; |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 212 | sm750_dev = par->dev; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 213 | |
Sudip Mukherjee | d11ac7c | 2015-08-07 17:34:04 +0530 | [diff] [blame] | 214 | /* |
| 215 | * each time 2d function begin to work,below three variable always need |
| 216 | * be set, seems we can put them together in some place |
| 217 | */ |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 218 | base = par->crtc.oScreen; |
| 219 | pitch = info->fix.line_length; |
| 220 | Bpp = info->var.bits_per_pixel >> 3; |
| 221 | |
Lorenzo Stoakes | cb422f3 | 2015-03-20 15:22:15 +0000 | [diff] [blame] | 222 | /* |
| 223 | * If not use spin_lock, system will die if user load driver |
Carlos E. Garcia | 69e98df | 2015-04-24 09:40:42 -0400 | [diff] [blame] | 224 | * and immediately unload driver frequently (dual) |
Lorenzo Stoakes | cb422f3 | 2015-03-20 15:22:15 +0000 | [diff] [blame] | 225 | */ |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 226 | if (sm750_dev->dual) |
| 227 | spin_lock(&sm750_dev->slock); |
Lorenzo Stoakes | cb422f3 | 2015-03-20 15:22:15 +0000 | [diff] [blame] | 228 | |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 229 | sm750_dev->accel.de_copyarea(&sm750_dev->accel, |
| 230 | base, pitch, region->sx, region->sy, |
| 231 | base, pitch, Bpp, region->dx, region->dy, |
| 232 | region->width, region->height, |
| 233 | HW_ROP2_COPY); |
| 234 | if (sm750_dev->dual) |
| 235 | spin_unlock(&sm750_dev->slock); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 236 | } |
| 237 | |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 238 | static void lynxfb_ops_imageblit(struct fb_info *info, |
| 239 | const struct fb_image *image) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 240 | { |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 241 | unsigned int base, pitch, Bpp; |
| 242 | unsigned int fgcol, bgcol; |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 243 | struct lynxfb_par *par; |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 244 | struct sm750_dev *sm750_dev; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 245 | |
| 246 | par = info->par; |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 247 | sm750_dev = par->dev; |
Sudip Mukherjee | d11ac7c | 2015-08-07 17:34:04 +0530 | [diff] [blame] | 248 | /* |
| 249 | * each time 2d function begin to work,below three variable always need |
| 250 | * be set, seems we can put them together in some place |
| 251 | */ |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 252 | base = par->crtc.oScreen; |
| 253 | pitch = info->fix.line_length; |
| 254 | Bpp = info->var.bits_per_pixel >> 3; |
| 255 | |
Huacai Chen | 288ef56 | 2015-05-11 11:08:22 +0800 | [diff] [blame] | 256 | /* TODO: Implement hardware acceleration for image->depth > 1 */ |
Sudip Mukherjee | f8fbc83 | 2015-08-07 17:34:05 +0530 | [diff] [blame] | 257 | if (image->depth != 1) { |
| 258 | cfb_imageblit(info, image); |
| 259 | return; |
| 260 | } |
Huacai Chen | 288ef56 | 2015-05-11 11:08:22 +0800 | [diff] [blame] | 261 | |
Sudip Mukherjee | f8fbc83 | 2015-08-07 17:34:05 +0530 | [diff] [blame] | 262 | if (info->fix.visual == FB_VISUAL_TRUECOLOR || |
| 263 | info->fix.visual == FB_VISUAL_DIRECTCOLOR) { |
| 264 | fgcol = ((u32 *)info->pseudo_palette)[image->fg_color]; |
| 265 | bgcol = ((u32 *)info->pseudo_palette)[image->bg_color]; |
| 266 | } else { |
| 267 | fgcol = image->fg_color; |
| 268 | bgcol = image->bg_color; |
| 269 | } |
| 270 | |
Lorenzo Stoakes | cb422f3 | 2015-03-20 15:22:15 +0000 | [diff] [blame] | 271 | /* |
| 272 | * If not use spin_lock, system will die if user load driver |
Carlos E. Garcia | 69e98df | 2015-04-24 09:40:42 -0400 | [diff] [blame] | 273 | * and immediately unload driver frequently (dual) |
Lorenzo Stoakes | cb422f3 | 2015-03-20 15:22:15 +0000 | [diff] [blame] | 274 | */ |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 275 | if (sm750_dev->dual) |
| 276 | spin_lock(&sm750_dev->slock); |
Lorenzo Stoakes | cb422f3 | 2015-03-20 15:22:15 +0000 | [diff] [blame] | 277 | |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 278 | sm750_dev->accel.de_imageblit(&sm750_dev->accel, |
| 279 | image->data, image->width >> 3, 0, |
| 280 | base, pitch, Bpp, |
| 281 | image->dx, image->dy, |
| 282 | image->width, image->height, |
| 283 | fgcol, bgcol, HW_ROP2_COPY); |
| 284 | if (sm750_dev->dual) |
| 285 | spin_unlock(&sm750_dev->slock); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var, |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 289 | struct fb_info *info) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 290 | { |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 291 | struct lynxfb_par *par; |
| 292 | struct lynxfb_crtc *crtc; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 293 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 294 | if (!info) |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 295 | return -EINVAL; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 296 | |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 297 | par = info->par; |
| 298 | crtc = &par->crtc; |
Mike Rapoport | c202bee | 2015-10-23 17:55:10 +0300 | [diff] [blame] | 299 | return hw_sm750_pan_display(crtc, var, info); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 300 | } |
| 301 | |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 302 | static int lynxfb_ops_set_par(struct fb_info *info) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 303 | { |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 304 | struct lynxfb_par *par; |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 305 | struct lynxfb_crtc *crtc; |
| 306 | struct lynxfb_output *output; |
| 307 | struct fb_var_screeninfo *var; |
| 308 | struct fb_fix_screeninfo *fix; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 309 | int ret; |
| 310 | unsigned int line_length; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 311 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 312 | if (!info) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 313 | return -EINVAL; |
| 314 | |
| 315 | ret = 0; |
| 316 | par = info->par; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 317 | crtc = &par->crtc; |
| 318 | output = &par->output; |
| 319 | var = &info->var; |
| 320 | fix = &info->fix; |
| 321 | |
| 322 | /* fix structur is not so FIX ... */ |
| 323 | line_length = var->xres_virtual * var->bits_per_pixel / 8; |
Mike Rapoport | e3a3f9f | 2015-10-26 09:05:52 +0200 | [diff] [blame] | 324 | line_length = ALIGN(line_length, crtc->line_pad); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 325 | fix->line_length = line_length; |
Hari Prasath Gujulan Elango | 78cb7a3 | 2015-06-18 12:56:54 +0000 | [diff] [blame] | 326 | pr_info("fix->line_length = %d\n", fix->line_length); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 327 | |
Sudip Mukherjee | d11ac7c | 2015-08-07 17:34:04 +0530 | [diff] [blame] | 328 | /* |
| 329 | * var->red,green,blue,transp are need to be set by driver |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 330 | * and these data should be set before setcolreg routine |
Sudip Mukherjee | d11ac7c | 2015-08-07 17:34:04 +0530 | [diff] [blame] | 331 | */ |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 332 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 333 | switch (var->bits_per_pixel) { |
Ioana Ciornei | d6b0d6d | 2015-03-11 04:35:04 +0200 | [diff] [blame] | 334 | case 8: |
| 335 | fix->visual = FB_VISUAL_PSEUDOCOLOR; |
| 336 | var->red.offset = 0; |
| 337 | var->red.length = 8; |
| 338 | var->green.offset = 0; |
| 339 | var->green.length = 8; |
| 340 | var->blue.offset = 0; |
| 341 | var->blue.length = 8; |
| 342 | var->transp.length = 0; |
| 343 | var->transp.offset = 0; |
| 344 | break; |
| 345 | case 16: |
| 346 | var->red.offset = 11; |
| 347 | var->red.length = 5; |
| 348 | var->green.offset = 5; |
| 349 | var->green.length = 6; |
| 350 | var->blue.offset = 0; |
| 351 | var->blue.length = 5; |
| 352 | var->transp.length = 0; |
| 353 | var->transp.offset = 0; |
| 354 | fix->visual = FB_VISUAL_TRUECOLOR; |
| 355 | break; |
| 356 | case 24: |
| 357 | case 32: |
| 358 | var->red.offset = 16; |
| 359 | var->red.length = 8; |
| 360 | var->green.offset = 8; |
| 361 | var->green.length = 8; |
Michel von Czettritz | a0c838f | 2015-03-26 23:26:52 +0100 | [diff] [blame] | 362 | var->blue.offset = 0; |
Ioana Ciornei | d6b0d6d | 2015-03-11 04:35:04 +0200 | [diff] [blame] | 363 | var->blue.length = 8; |
| 364 | fix->visual = FB_VISUAL_TRUECOLOR; |
| 365 | break; |
| 366 | default: |
| 367 | ret = -EINVAL; |
| 368 | break; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 369 | } |
| 370 | var->height = var->width = -1; |
| 371 | var->accel_flags = 0;/*FB_ACCELF_TEXT;*/ |
| 372 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 373 | if (ret) { |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 374 | pr_err("pixel bpp format not satisfied\n."); |
| 375 | return ret; |
| 376 | } |
Mike Rapoport | c202bee | 2015-10-23 17:55:10 +0300 | [diff] [blame] | 377 | ret = hw_sm750_crtc_setMode(crtc, var, fix); |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 378 | if (!ret) |
Mike Rapoport | 9821ed04 | 2015-10-23 17:55:11 +0300 | [diff] [blame] | 379 | ret = hw_sm750_output_setMode(output, var, fix); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 380 | return ret; |
| 381 | } |
Sudip Mukherjee | 848f2fc | 2015-03-10 14:15:38 +0530 | [diff] [blame] | 382 | |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 383 | static inline unsigned int chan_to_field(unsigned int chan, |
| 384 | struct fb_bitfield *bf) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 385 | { |
| 386 | chan &= 0xffff; |
| 387 | chan >>= 16 - bf->length; |
| 388 | return chan << bf->offset; |
| 389 | } |
| 390 | |
Sudip Mukherjee | 848f2fc | 2015-03-10 14:15:38 +0530 | [diff] [blame] | 391 | #ifdef CONFIG_PM |
| 392 | static int lynxfb_suspend(struct pci_dev *pdev, pm_message_t mesg) |
| 393 | { |
| 394 | struct fb_info *info; |
Mike Rapoport | 083c204 | 2015-10-26 09:06:03 +0200 | [diff] [blame] | 395 | struct sm750_dev *sm750_dev; |
Sudip Mukherjee | 848f2fc | 2015-03-10 14:15:38 +0530 | [diff] [blame] | 396 | int ret; |
| 397 | |
| 398 | if (mesg.event == pdev->dev.power.power_state.event) |
| 399 | return 0; |
| 400 | |
| 401 | ret = 0; |
Mike Rapoport | 083c204 | 2015-10-26 09:06:03 +0200 | [diff] [blame] | 402 | sm750_dev = pci_get_drvdata(pdev); |
Sudip Mukherjee | 848f2fc | 2015-03-10 14:15:38 +0530 | [diff] [blame] | 403 | switch (mesg.event) { |
| 404 | case PM_EVENT_FREEZE: |
| 405 | case PM_EVENT_PRETHAW: |
| 406 | pdev->dev.power.power_state = mesg; |
| 407 | return 0; |
| 408 | } |
| 409 | |
| 410 | console_lock(); |
| 411 | if (mesg.event & PM_EVENT_SLEEP) { |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 412 | info = sm750_dev->fbinfo[0]; |
Sudip Mukherjee | 848f2fc | 2015-03-10 14:15:38 +0530 | [diff] [blame] | 413 | if (info) |
Michel von Czettritz | 4bd9503 | 2015-03-26 23:26:04 +0100 | [diff] [blame] | 414 | /* 1 means do suspend */ |
Sudip Mukherjee | 848f2fc | 2015-03-10 14:15:38 +0530 | [diff] [blame] | 415 | fb_set_suspend(info, 1); |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 416 | info = sm750_dev->fbinfo[1]; |
Sudip Mukherjee | 848f2fc | 2015-03-10 14:15:38 +0530 | [diff] [blame] | 417 | if (info) |
Michel von Czettritz | 4bd9503 | 2015-03-26 23:26:04 +0100 | [diff] [blame] | 418 | /* 1 means do suspend */ |
Sudip Mukherjee | 848f2fc | 2015-03-10 14:15:38 +0530 | [diff] [blame] | 419 | fb_set_suspend(info, 1); |
| 420 | |
| 421 | ret = pci_save_state(pdev); |
| 422 | if (ret) { |
| 423 | pr_err("error:%d occurred in pci_save_state\n", ret); |
| 424 | return ret; |
| 425 | } |
| 426 | |
Sudip Mukherjee | 848f2fc | 2015-03-10 14:15:38 +0530 | [diff] [blame] | 427 | pci_disable_device(pdev); |
| 428 | ret = pci_set_power_state(pdev, pci_choose_state(pdev, mesg)); |
| 429 | if (ret) { |
| 430 | pr_err("error:%d occurred in pci_set_power_state\n", ret); |
| 431 | return ret; |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | pdev->dev.power.power_state = mesg; |
| 436 | console_unlock(); |
| 437 | return ret; |
| 438 | } |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 439 | |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 440 | static int lynxfb_resume(struct pci_dev *pdev) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 441 | { |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 442 | struct fb_info *info; |
Mike Rapoport | 700591a | 2015-10-26 09:06:01 +0200 | [diff] [blame] | 443 | struct sm750_dev *sm750_dev; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 444 | |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 445 | struct lynxfb_par *par; |
| 446 | struct lynxfb_crtc *crtc; |
| 447 | struct lynx_cursor *cursor; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 448 | |
| 449 | int ret; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 450 | |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 451 | ret = 0; |
Mike Rapoport | 083c204 | 2015-10-26 09:06:03 +0200 | [diff] [blame] | 452 | sm750_dev = pci_get_drvdata(pdev); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 453 | |
| 454 | console_lock(); |
| 455 | |
Michel von Czettritz | 61c507c | 2015-03-26 23:27:25 +0100 | [diff] [blame] | 456 | ret = pci_set_power_state(pdev, PCI_D0); |
| 457 | if (ret) { |
Carlos E. Garcia | 69e98df | 2015-04-24 09:40:42 -0400 | [diff] [blame] | 458 | pr_err("error:%d occurred in pci_set_power_state\n", ret); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 459 | return ret; |
| 460 | } |
| 461 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 462 | if (pdev->dev.power.power_state.event != PM_EVENT_FREEZE) { |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 463 | pci_restore_state(pdev); |
Michel von Czettritz | 61c507c | 2015-03-26 23:27:25 +0100 | [diff] [blame] | 464 | ret = pci_enable_device(pdev); |
| 465 | if (ret) { |
Carlos E. Garcia | 69e98df | 2015-04-24 09:40:42 -0400 | [diff] [blame] | 466 | pr_err("error:%d occurred in pci_enable_device\n", ret); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 467 | return ret; |
| 468 | } |
| 469 | pci_set_master(pdev); |
| 470 | } |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 471 | |
Mike Rapoport | 700591a | 2015-10-26 09:06:01 +0200 | [diff] [blame] | 472 | hw_sm750_inithw(sm750_dev, pdev); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 473 | |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 474 | info = sm750_dev->fbinfo[0]; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 475 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 476 | if (info) { |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 477 | par = info->par; |
| 478 | crtc = &par->crtc; |
| 479 | cursor = &crtc->cursor; |
Lorenzo Stoakes | 3de08a2 | 2015-03-20 15:22:11 +0000 | [diff] [blame] | 480 | memset_io(cursor->vstart, 0x0, cursor->size); |
| 481 | memset_io(crtc->vScreen, 0x0, crtc->vidmem_size); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 482 | lynxfb_ops_set_par(info); |
| 483 | fb_set_suspend(info, 0); |
| 484 | } |
| 485 | |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 486 | info = sm750_dev->fbinfo[1]; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 487 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 488 | if (info) { |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 489 | par = info->par; |
| 490 | crtc = &par->crtc; |
| 491 | cursor = &crtc->cursor; |
Lorenzo Stoakes | 3de08a2 | 2015-03-20 15:22:11 +0000 | [diff] [blame] | 492 | memset_io(cursor->vstart, 0x0, cursor->size); |
| 493 | memset_io(crtc->vScreen, 0x0, crtc->vidmem_size); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 494 | lynxfb_ops_set_par(info); |
| 495 | fb_set_suspend(info, 0); |
| 496 | } |
| 497 | |
Binbin Zhou | 31557ea | 2015-10-12 09:48:27 +0800 | [diff] [blame] | 498 | pdev->dev.power.power_state.event = PM_EVENT_RESUME; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 499 | console_unlock(); |
| 500 | return ret; |
| 501 | } |
| 502 | #endif |
| 503 | |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 504 | static int lynxfb_ops_check_var(struct fb_var_screeninfo *var, |
| 505 | struct fb_info *info) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 506 | { |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 507 | struct lynxfb_par *par; |
| 508 | struct lynxfb_crtc *crtc; |
| 509 | struct lynxfb_output *output; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 510 | resource_size_t request; |
| 511 | |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 512 | par = info->par; |
| 513 | crtc = &par->crtc; |
| 514 | output = &par->output; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 515 | |
| 516 | pr_debug("check var:%dx%d-%d\n", |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 517 | var->xres, |
| 518 | var->yres, |
| 519 | var->bits_per_pixel); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 520 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 521 | switch (var->bits_per_pixel) { |
Ioana Ciornei | d6b0d6d | 2015-03-11 04:35:04 +0200 | [diff] [blame] | 522 | case 8: |
Ioana Ciornei | d6b0d6d | 2015-03-11 04:35:04 +0200 | [diff] [blame] | 523 | info->fix.visual = FB_VISUAL_PSEUDOCOLOR; |
| 524 | var->red.offset = 0; |
| 525 | var->red.length = 8; |
| 526 | var->green.offset = 0; |
| 527 | var->green.length = 8; |
| 528 | var->blue.offset = 0; |
| 529 | var->blue.length = 8; |
| 530 | var->transp.length = 0; |
| 531 | var->transp.offset = 0; |
| 532 | break; |
| 533 | case 16: |
| 534 | var->red.offset = 11; |
| 535 | var->red.length = 5; |
| 536 | var->green.offset = 5; |
| 537 | var->green.length = 6; |
| 538 | var->blue.offset = 0; |
| 539 | var->blue.length = 5; |
| 540 | var->transp.length = 0; |
| 541 | var->transp.offset = 0; |
| 542 | info->fix.visual = FB_VISUAL_TRUECOLOR; |
| 543 | break; |
| 544 | case 24: |
| 545 | case 32: |
| 546 | var->red.offset = 16; |
| 547 | var->red.length = 8; |
| 548 | var->green.offset = 8; |
| 549 | var->green.length = 8; |
Michel von Czettritz | a0c838f | 2015-03-26 23:26:52 +0100 | [diff] [blame] | 550 | var->blue.offset = 0; |
Ioana Ciornei | d6b0d6d | 2015-03-11 04:35:04 +0200 | [diff] [blame] | 551 | var->blue.length = 8; |
| 552 | info->fix.visual = FB_VISUAL_TRUECOLOR; |
| 553 | break; |
| 554 | default: |
Mike Rapoport | 104f456 | 2015-10-01 12:14:02 +0300 | [diff] [blame] | 555 | pr_err("bpp %d not supported\n", var->bits_per_pixel); |
| 556 | return -EINVAL; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 557 | } |
| 558 | var->height = var->width = -1; |
Michel von Czettritz | 4bd9503 | 2015-03-26 23:26:04 +0100 | [diff] [blame] | 559 | var->accel_flags = 0;/* FB_ACCELF_TEXT; */ |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 560 | |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 561 | /* check if current fb's video memory big enought to hold the onscreen*/ |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 562 | request = var->xres_virtual * (var->bits_per_pixel >> 3); |
| 563 | /* defaulty crtc->channel go with par->index */ |
| 564 | |
Mike Rapoport | e3a3f9f | 2015-10-26 09:05:52 +0200 | [diff] [blame] | 565 | request = ALIGN(request, crtc->line_pad); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 566 | request = request * var->yres_virtual; |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 567 | if (crtc->vidmem_size < request) { |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 568 | pr_err("not enough video memory for mode\n"); |
| 569 | return -ENOMEM; |
| 570 | } |
| 571 | |
Mike Rapoport | c202bee | 2015-10-23 17:55:10 +0300 | [diff] [blame] | 572 | return hw_sm750_crtc_checkMode(crtc, var); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 573 | } |
| 574 | |
Michel von Czettritz | 876e5a7 | 2015-03-26 23:26:37 +0100 | [diff] [blame] | 575 | static int lynxfb_ops_setcolreg(unsigned regno, |
| 576 | unsigned red, |
| 577 | unsigned green, |
| 578 | unsigned blue, |
| 579 | unsigned transp, |
| 580 | struct fb_info *info) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 581 | { |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 582 | struct lynxfb_par *par; |
| 583 | struct lynxfb_crtc *crtc; |
| 584 | struct fb_var_screeninfo *var; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 585 | int ret; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 586 | |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 587 | par = info->par; |
| 588 | crtc = &par->crtc; |
| 589 | var = &info->var; |
| 590 | ret = 0; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 591 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 592 | if (regno > 256) { |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 593 | pr_err("regno = %d\n", regno); |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 594 | return -EINVAL; |
| 595 | } |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 596 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 597 | if (info->var.grayscale) |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 598 | red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 599 | |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 600 | if (var->bits_per_pixel == 8 && |
| 601 | info->fix.visual == FB_VISUAL_PSEUDOCOLOR) { |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 602 | red >>= 8; |
| 603 | green >>= 8; |
| 604 | blue >>= 8; |
Mike Rapoport | c202bee | 2015-10-23 17:55:10 +0300 | [diff] [blame] | 605 | ret = hw_sm750_setColReg(crtc, regno, red, green, blue); |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 606 | goto exit; |
| 607 | } |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 608 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 609 | if (info->fix.visual == FB_VISUAL_TRUECOLOR && regno < 256) { |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 610 | u32 val; |
Michel von Czettritz | 876e5a7 | 2015-03-26 23:26:37 +0100 | [diff] [blame] | 611 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 612 | if (var->bits_per_pixel == 16 || |
Michel von Czettritz | 876e5a7 | 2015-03-26 23:26:37 +0100 | [diff] [blame] | 613 | var->bits_per_pixel == 32 || |
| 614 | var->bits_per_pixel == 24) { |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 615 | val = chan_to_field(red, &var->red); |
| 616 | val |= chan_to_field(green, &var->green); |
| 617 | val |= chan_to_field(blue, &var->blue); |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 618 | par->pseudo_palette[regno] = val; |
| 619 | goto exit; |
| 620 | } |
| 621 | } |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 622 | |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 623 | ret = -EINVAL; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 624 | |
| 625 | exit: |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 626 | return ret; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 627 | } |
| 628 | |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 629 | static int lynxfb_ops_blank(int blank, struct fb_info *info) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 630 | { |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 631 | struct lynxfb_par *par; |
| 632 | struct lynxfb_output *output; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 633 | |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 634 | pr_debug("blank = %d.\n", blank); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 635 | par = info->par; |
| 636 | output = &par->output; |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 637 | return output->proc_setBLANK(output, blank); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 638 | } |
| 639 | |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 640 | static int sm750fb_set_drv(struct lynxfb_par *par) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 641 | { |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 642 | int ret; |
Mike Rapoport | 5ef2f68 | 2015-10-26 09:05:56 +0200 | [diff] [blame] | 643 | struct sm750_dev *sm750_dev; |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 644 | struct lynxfb_output *output; |
| 645 | struct lynxfb_crtc *crtc; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 646 | |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 647 | ret = 0; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 648 | |
Mike Rapoport | f11fa2a | 2015-10-26 09:05:59 +0200 | [diff] [blame] | 649 | sm750_dev = par->dev; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 650 | output = &par->output; |
| 651 | crtc = &par->crtc; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 652 | |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 653 | crtc->vidmem_size = (sm750_dev->dual) ? sm750_dev->vidmem_size >> 1 : |
| 654 | sm750_dev->vidmem_size; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 655 | /* setup crtc and output member */ |
Mike Rapoport | 5ef2f68 | 2015-10-26 09:05:56 +0200 | [diff] [blame] | 656 | sm750_dev->hwCursor = g_hwcursor; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 657 | |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 658 | crtc->line_pad = 16; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 659 | crtc->xpanstep = 8; |
| 660 | crtc->ypanstep = 1; |
| 661 | crtc->ywrapstep = 0; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 662 | |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 663 | output->proc_setBLANK = (sm750_dev->revid == SM750LE_REVISION_ID) ? |
Sudip Mukherjee | 13ef345 | 2015-08-07 17:34:03 +0530 | [diff] [blame] | 664 | hw_sm750le_setBLANK : hw_sm750_setBLANK; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 665 | /* chip specific phase */ |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 666 | sm750_dev->accel.de_wait = (sm750_dev->revid == SM750LE_REVISION_ID) ? |
| 667 | hw_sm750le_deWait : hw_sm750_deWait; |
Mike Rapoport | 1757d10 | 2015-10-26 09:05:57 +0200 | [diff] [blame] | 668 | switch (sm750_dev->dataflow) { |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 669 | case sm750_simul_pri: |
| 670 | output->paths = sm750_pnc; |
| 671 | crtc->channel = sm750_primary; |
| 672 | crtc->oScreen = 0; |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 673 | crtc->vScreen = sm750_dev->pvMem; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 674 | pr_info("use simul primary mode\n"); |
| 675 | break; |
| 676 | case sm750_simul_sec: |
| 677 | output->paths = sm750_pnc; |
| 678 | crtc->channel = sm750_secondary; |
| 679 | crtc->oScreen = 0; |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 680 | crtc->vScreen = sm750_dev->pvMem; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 681 | break; |
| 682 | case sm750_dual_normal: |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 683 | if (par->index == 0) { |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 684 | output->paths = sm750_panel; |
| 685 | crtc->channel = sm750_primary; |
| 686 | crtc->oScreen = 0; |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 687 | crtc->vScreen = sm750_dev->pvMem; |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 688 | } else { |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 689 | output->paths = sm750_crt; |
| 690 | crtc->channel = sm750_secondary; |
Michel von Czettritz | 4bd9503 | 2015-03-26 23:26:04 +0100 | [diff] [blame] | 691 | /* not consider of padding stuffs for oScreen,need fix */ |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 692 | crtc->oScreen = (sm750_dev->vidmem_size >> 1); |
| 693 | crtc->vScreen = sm750_dev->pvMem + crtc->oScreen; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 694 | } |
| 695 | break; |
| 696 | case sm750_dual_swap: |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 697 | if (par->index == 0) { |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 698 | output->paths = sm750_panel; |
| 699 | crtc->channel = sm750_secondary; |
| 700 | crtc->oScreen = 0; |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 701 | crtc->vScreen = sm750_dev->pvMem; |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 702 | } else { |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 703 | output->paths = sm750_crt; |
| 704 | crtc->channel = sm750_primary; |
Michel von Czettritz | 4bd9503 | 2015-03-26 23:26:04 +0100 | [diff] [blame] | 705 | /* not consider of padding stuffs for oScreen,need fix */ |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 706 | crtc->oScreen = (sm750_dev->vidmem_size >> 1); |
| 707 | crtc->vScreen = sm750_dev->pvMem + crtc->oScreen; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 708 | } |
| 709 | break; |
| 710 | default: |
| 711 | ret = -EINVAL; |
| 712 | } |
| 713 | |
| 714 | return ret; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 715 | } |
| 716 | |
Michel von Czettritz | a0c838f | 2015-03-26 23:26:52 +0100 | [diff] [blame] | 717 | static struct fb_ops lynxfb_ops = { |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 718 | .owner = THIS_MODULE, |
| 719 | .fb_check_var = lynxfb_ops_check_var, |
| 720 | .fb_set_par = lynxfb_ops_set_par, |
| 721 | .fb_setcolreg = lynxfb_ops_setcolreg, |
| 722 | .fb_blank = lynxfb_ops_blank, |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 723 | .fb_fillrect = cfb_fillrect, |
| 724 | .fb_imageblit = cfb_imageblit, |
| 725 | .fb_copyarea = cfb_copyarea, |
| 726 | /* cursor */ |
| 727 | .fb_cursor = lynxfb_ops_cursor, |
| 728 | }; |
| 729 | |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 730 | static int lynxfb_set_fbinfo(struct fb_info *info, int index) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 731 | { |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 732 | int i; |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 733 | struct lynxfb_par *par; |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 734 | struct sm750_dev *sm750_dev; |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 735 | struct lynxfb_crtc *crtc; |
| 736 | struct lynxfb_output *output; |
| 737 | struct fb_var_screeninfo *var; |
| 738 | struct fb_fix_screeninfo *fix; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 739 | |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 740 | const struct fb_videomode *pdb[] = { |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 741 | lynx750_ext, NULL, vesa_modes, |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 742 | }; |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 743 | int cdb[] = {ARRAY_SIZE(lynx750_ext), 0, VESA_MODEDB_SIZE}; |
Michel von Czettritz | a0c838f | 2015-03-26 23:26:52 +0100 | [diff] [blame] | 744 | static const char *mdb_desc[] = { |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 745 | "driver prepared modes", |
| 746 | "kernel prepared default modedb", |
| 747 | "kernel HELPERS prepared vesa_modes", |
| 748 | }; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 749 | |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 750 | static const char *fixId[2] = { |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 751 | "sm750_fb1", "sm750_fb2", |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 752 | }; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 753 | |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 754 | int ret, line_length; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 755 | |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 756 | ret = 0; |
| 757 | par = (struct lynxfb_par *)info->par; |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 758 | sm750_dev = par->dev; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 759 | crtc = &par->crtc; |
| 760 | output = &par->output; |
| 761 | var = &info->var; |
| 762 | fix = &info->fix; |
| 763 | |
| 764 | /* set index */ |
| 765 | par->index = index; |
| 766 | output->channel = &crtc->channel; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 767 | sm750fb_set_drv(par); |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 768 | lynxfb_ops.fb_pan_display = lynxfb_ops_pan_display; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 769 | |
Sudip Mukherjee | d11ac7c | 2015-08-07 17:34:04 +0530 | [diff] [blame] | 770 | /* |
| 771 | * set current cursor variable and proc pointer, |
| 772 | * must be set after crtc member initialized |
| 773 | */ |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 774 | crtc->cursor.offset = crtc->oScreen + crtc->vidmem_size - 1024; |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 775 | crtc->cursor.mmio = sm750_dev->pvReg + |
| 776 | 0x800f0 + (int)crtc->channel * 0x140; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 777 | |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 778 | pr_info("crtc->cursor.mmio = %p\n", crtc->cursor.mmio); |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 779 | crtc->cursor.maxH = crtc->cursor.maxW = 64; |
Sudip Mukherjee | 13ef345 | 2015-08-07 17:34:03 +0530 | [diff] [blame] | 780 | crtc->cursor.size = crtc->cursor.maxH * crtc->cursor.maxW * 2 / 8; |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 781 | crtc->cursor.vstart = sm750_dev->pvMem + crtc->cursor.offset; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 782 | |
Mike Rapoport | 52e9332 | 2015-10-26 09:06:04 +0200 | [diff] [blame] | 783 | memset_io(crtc->cursor.vstart, 0, crtc->cursor.size); |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 784 | if (!g_hwcursor) { |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 785 | lynxfb_ops.fb_cursor = NULL; |
Mike Rapoport | fb7f405 | 2015-10-26 09:05:50 +0200 | [diff] [blame] | 786 | hw_cursor_disable(&crtc->cursor); |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 787 | } |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 788 | |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 789 | /* set info->fbops, must be set before fb_find_mode */ |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 790 | if (!sm750_dev->accel_off) { |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 791 | /* use 2d acceleration */ |
| 792 | lynxfb_ops.fb_fillrect = lynxfb_ops_fillrect; |
| 793 | lynxfb_ops.fb_copyarea = lynxfb_ops_copyarea; |
| 794 | lynxfb_ops.fb_imageblit = lynxfb_ops_imageblit; |
| 795 | } |
| 796 | info->fbops = &lynxfb_ops; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 797 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 798 | if (!g_fbmode[index]) { |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 799 | g_fbmode[index] = g_def_fbmode; |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 800 | if (index) |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 801 | g_fbmode[index] = g_fbmode[0]; |
| 802 | } |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 803 | |
Michel von Czettritz | a0c838f | 2015-03-26 23:26:52 +0100 | [diff] [blame] | 804 | for (i = 0; i < 3; i++) { |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 805 | |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 806 | ret = fb_find_mode(var, info, g_fbmode[index], |
| 807 | pdb[i], cdb[i], NULL, 8); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 808 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 809 | if (ret == 1) { |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 810 | pr_info("success! use specified mode:%s in %s\n", |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 811 | g_fbmode[index], |
| 812 | mdb_desc[i]); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 813 | break; |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 814 | } else if (ret == 2) { |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 815 | pr_warn("use specified mode:%s in %s,with an ignored refresh rate\n", |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 816 | g_fbmode[index], |
| 817 | mdb_desc[i]); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 818 | break; |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 819 | } else if (ret == 3) { |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 820 | pr_warn("wanna use default mode\n"); |
Michel von Czettritz | 4bd9503 | 2015-03-26 23:26:04 +0100 | [diff] [blame] | 821 | /*break;*/ |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 822 | } else if (ret == 4) { |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 823 | pr_warn("fall back to any valid mode\n"); |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 824 | } else { |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 825 | pr_warn("ret = %d,fb_find_mode failed,with %s\n", |
| 826 | ret, |
| 827 | mdb_desc[i]); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 828 | } |
| 829 | } |
| 830 | |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 831 | /* some member of info->var had been set by fb_find_mode */ |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 832 | |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 833 | pr_info("Member of info->var is :\n\ |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 834 | xres=%d\n\ |
| 835 | yres=%d\n\ |
| 836 | xres_virtual=%d\n\ |
| 837 | yres_virtual=%d\n\ |
| 838 | xoffset=%d\n\ |
| 839 | yoffset=%d\n\ |
| 840 | bits_per_pixel=%d\n \ |
| 841 | ...\n", |
| 842 | var->xres, |
| 843 | var->yres, |
| 844 | var->xres_virtual, |
| 845 | var->yres_virtual, |
| 846 | var->xoffset, |
| 847 | var->yoffset, |
| 848 | var->bits_per_pixel); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 849 | |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 850 | /* set par */ |
| 851 | par->info = info; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 852 | |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 853 | /* set info */ |
Mike Rapoport | e3a3f9f | 2015-10-26 09:05:52 +0200 | [diff] [blame] | 854 | line_length = ALIGN((var->xres_virtual * var->bits_per_pixel / 8), |
| 855 | crtc->line_pad); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 856 | |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 857 | info->pseudo_palette = &par->pseudo_palette[0]; |
| 858 | info->screen_base = crtc->vScreen; |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 859 | pr_debug("screen_base vaddr = %p\n", info->screen_base); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 860 | info->screen_size = line_length * var->yres_virtual; |
Sudip Mukherjee | 13ef345 | 2015-08-07 17:34:03 +0530 | [diff] [blame] | 861 | info->flags = FBINFO_FLAG_DEFAULT | 0; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 862 | |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 863 | /* set info->fix */ |
| 864 | fix->type = FB_TYPE_PACKED_PIXELS; |
| 865 | fix->type_aux = 0; |
| 866 | fix->xpanstep = crtc->xpanstep; |
| 867 | fix->ypanstep = crtc->ypanstep; |
| 868 | fix->ywrapstep = crtc->ywrapstep; |
| 869 | fix->accel = FB_ACCEL_SMI; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 870 | |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 871 | strlcpy(fix->id, fixId[index], sizeof(fix->id)); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 872 | |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 873 | fix->smem_start = crtc->oScreen + sm750_dev->vidmem_start; |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 874 | pr_info("fix->smem_start = %lx\n", fix->smem_start); |
Sudip Mukherjee | d11ac7c | 2015-08-07 17:34:04 +0530 | [diff] [blame] | 875 | /* |
| 876 | * according to mmap experiment from user space application, |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 877 | * fix->mmio_len should not larger than virtual size |
| 878 | * (xres_virtual x yres_virtual x ByPP) |
| 879 | * Below line maybe buggy when user mmap fb dev node and write |
| 880 | * data into the bound over virtual size |
Sudip Mukherjee | d11ac7c | 2015-08-07 17:34:04 +0530 | [diff] [blame] | 881 | */ |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 882 | fix->smem_len = crtc->vidmem_size; |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 883 | pr_info("fix->smem_len = %x\n", fix->smem_len); |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 884 | info->screen_size = fix->smem_len; |
| 885 | fix->line_length = line_length; |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 886 | fix->mmio_start = sm750_dev->vidreg_start; |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 887 | pr_info("fix->mmio_start = %lx\n", fix->mmio_start); |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 888 | fix->mmio_len = sm750_dev->vidreg_size; |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 889 | pr_info("fix->mmio_len = %x\n", fix->mmio_len); |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 890 | switch (var->bits_per_pixel) { |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 891 | case 8: |
| 892 | fix->visual = FB_VISUAL_PSEUDOCOLOR; |
| 893 | break; |
| 894 | case 16: |
| 895 | case 32: |
| 896 | fix->visual = FB_VISUAL_TRUECOLOR; |
| 897 | break; |
| 898 | } |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 899 | |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 900 | /* set var */ |
| 901 | var->activate = FB_ACTIVATE_NOW; |
| 902 | var->accel_flags = 0; |
| 903 | var->vmode = FB_VMODE_NONINTERLACED; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 904 | |
Juston Li | a1fe154 | 2015-07-14 21:14:44 -0700 | [diff] [blame] | 905 | pr_debug("#1 show info->cmap :\nstart=%d,len=%d,red=%p,green=%p,blue=%p,transp=%p\n", |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 906 | info->cmap.start, info->cmap.len, |
| 907 | info->cmap.red, info->cmap.green, info->cmap.blue, |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 908 | info->cmap.transp); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 909 | |
Michel von Czettritz | 61c507c | 2015-03-26 23:27:25 +0100 | [diff] [blame] | 910 | ret = fb_alloc_cmap(&info->cmap, 256, 0); |
| 911 | if (ret < 0) { |
Masanari Iida | 0082720 | 2015-05-28 08:41:16 +0900 | [diff] [blame] | 912 | pr_err("Could not allocate memory for cmap.\n"); |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 913 | goto exit; |
| 914 | } |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 915 | |
Michel von Czettritz | a0c838f | 2015-03-26 23:26:52 +0100 | [diff] [blame] | 916 | pr_debug("#2 show info->cmap :\nstart=%d,len=%d,red=%p,green=%p,blue=%p,transp=%p\n", |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 917 | info->cmap.start, info->cmap.len, |
| 918 | info->cmap.red, info->cmap.green, info->cmap.blue, |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 919 | info->cmap.transp); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 920 | |
| 921 | exit: |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 922 | lynxfb_ops_check_var(var, info); |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 923 | return ret; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 924 | } |
| 925 | |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 926 | /* chip specific g_option configuration routine */ |
Mike Rapoport | 700591a | 2015-10-26 09:06:01 +0200 | [diff] [blame] | 927 | static void sm750fb_setup(struct sm750_dev *sm750_dev, char *src) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 928 | { |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 929 | char *opt; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 930 | int swap; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 931 | |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 932 | swap = 0; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 933 | |
Mike Rapoport | 1757d10 | 2015-10-26 09:05:57 +0200 | [diff] [blame] | 934 | sm750_dev->initParm.chip_clk = 0; |
| 935 | sm750_dev->initParm.mem_clk = 0; |
| 936 | sm750_dev->initParm.master_clk = 0; |
| 937 | sm750_dev->initParm.powerMode = 0; |
| 938 | sm750_dev->initParm.setAllEngOff = 0; |
| 939 | sm750_dev->initParm.resetMemory = 1; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 940 | |
Michel von Czettritz | 4bd9503 | 2015-03-26 23:26:04 +0100 | [diff] [blame] | 941 | /* defaultly turn g_hwcursor on for both view */ |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 942 | g_hwcursor = 3; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 943 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 944 | if (!src || !*src) { |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 945 | pr_warn("no specific g_option.\n"); |
| 946 | goto NO_PARAM; |
| 947 | } |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 948 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 949 | while ((opt = strsep(&src, ":")) != NULL && *opt != 0) { |
Hari Prasath Gujulan Elango | 78cb7a3 | 2015-06-18 12:56:54 +0000 | [diff] [blame] | 950 | pr_info("opt=%s\n", opt); |
| 951 | pr_info("src=%s\n", src); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 952 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 953 | if (!strncmp(opt, "swap", strlen("swap"))) |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 954 | swap = 1; |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 955 | else if (!strncmp(opt, "nocrt", strlen("nocrt"))) |
Mike Rapoport | 1757d10 | 2015-10-26 09:05:57 +0200 | [diff] [blame] | 956 | sm750_dev->nocrt = 1; |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 957 | else if (!strncmp(opt, "36bit", strlen("36bit"))) |
Mike Rapoport | 1757d10 | 2015-10-26 09:05:57 +0200 | [diff] [blame] | 958 | sm750_dev->pnltype = sm750_doubleTFT; |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 959 | else if (!strncmp(opt, "18bit", strlen("18bit"))) |
Mike Rapoport | 1757d10 | 2015-10-26 09:05:57 +0200 | [diff] [blame] | 960 | sm750_dev->pnltype = sm750_dualTFT; |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 961 | else if (!strncmp(opt, "24bit", strlen("24bit"))) |
Mike Rapoport | 1757d10 | 2015-10-26 09:05:57 +0200 | [diff] [blame] | 962 | sm750_dev->pnltype = sm750_24TFT; |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 963 | else if (!strncmp(opt, "nohwc0", strlen("nohwc0"))) |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 964 | g_hwcursor &= ~0x1; |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 965 | else if (!strncmp(opt, "nohwc1", strlen("nohwc1"))) |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 966 | g_hwcursor &= ~0x2; |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 967 | else if (!strncmp(opt, "nohwc", strlen("nohwc"))) |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 968 | g_hwcursor = 0; |
Michel von Czettritz | 70407df | 2015-03-26 23:25:08 +0100 | [diff] [blame] | 969 | else { |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 970 | if (!g_fbmode[0]) { |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 971 | g_fbmode[0] = opt; |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 972 | pr_info("find fbmode0 : %s\n", g_fbmode[0]); |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 973 | } else if (!g_fbmode[1]) { |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 974 | g_fbmode[1] = opt; |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 975 | pr_info("find fbmode1 : %s\n", g_fbmode[1]); |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 976 | } else { |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 977 | pr_warn("How many view you wann set?\n"); |
| 978 | } |
| 979 | } |
| 980 | } |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 981 | |
| 982 | NO_PARAM: |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 983 | if (sm750_dev->revid != SM750LE_REVISION_ID) { |
| 984 | if (sm750_dev->dual) { |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 985 | if (swap) |
Mike Rapoport | 1757d10 | 2015-10-26 09:05:57 +0200 | [diff] [blame] | 986 | sm750_dev->dataflow = sm750_dual_swap; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 987 | else |
Mike Rapoport | 1757d10 | 2015-10-26 09:05:57 +0200 | [diff] [blame] | 988 | sm750_dev->dataflow = sm750_dual_normal; |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 989 | } else { |
| 990 | if (swap) |
Mike Rapoport | 1757d10 | 2015-10-26 09:05:57 +0200 | [diff] [blame] | 991 | sm750_dev->dataflow = sm750_simul_sec; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 992 | else |
Mike Rapoport | 1757d10 | 2015-10-26 09:05:57 +0200 | [diff] [blame] | 993 | sm750_dev->dataflow = sm750_simul_pri; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 994 | } |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 995 | } else { |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 996 | /* SM750LE only have one crt channel */ |
Mike Rapoport | 1757d10 | 2015-10-26 09:05:57 +0200 | [diff] [blame] | 997 | sm750_dev->dataflow = sm750_simul_sec; |
Michel von Czettritz | 4bd9503 | 2015-03-26 23:26:04 +0100 | [diff] [blame] | 998 | /* sm750le do not have complex attributes */ |
Mike Rapoport | 1757d10 | 2015-10-26 09:05:57 +0200 | [diff] [blame] | 999 | sm750_dev->nocrt = 0; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 1000 | } |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1001 | } |
| 1002 | |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 1003 | static int lynxfb_pci_probe(struct pci_dev *pdev, |
Greg Donald | eb0f427 | 2015-06-18 15:06:56 -0500 | [diff] [blame] | 1004 | const struct pci_device_id *ent) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1005 | { |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 1006 | struct fb_info *info[] = {NULL, NULL}; |
Mike Rapoport | 5ef2f68 | 2015-10-26 09:05:56 +0200 | [diff] [blame] | 1007 | struct sm750_dev *sm750_dev = NULL; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1008 | int fbidx; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 1009 | |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1010 | /* enable device */ |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 1011 | if (pci_enable_device(pdev)) { |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1012 | pr_err("can not enable device.\n"); |
| 1013 | goto err_enable; |
| 1014 | } |
| 1015 | |
Mike Rapoport | 5ef2f68 | 2015-10-26 09:05:56 +0200 | [diff] [blame] | 1016 | sm750_dev = kzalloc(sizeof(*sm750_dev), GFP_KERNEL); |
| 1017 | if (!sm750_dev) { |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1018 | pr_err("Could not allocate memory for share.\n"); |
| 1019 | goto err_share; |
| 1020 | } |
| 1021 | |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 1022 | sm750_dev->fbinfo[0] = sm750_dev->fbinfo[1] = NULL; |
| 1023 | sm750_dev->devid = pdev->device; |
| 1024 | sm750_dev->revid = pdev->revision; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1025 | |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 1026 | pr_info("share->revid = %02x\n", sm750_dev->revid); |
| 1027 | sm750_dev->pdev = pdev; |
| 1028 | sm750_dev->mtrr_off = g_nomtrr; |
| 1029 | sm750_dev->mtrr.vram = 0; |
| 1030 | sm750_dev->accel_off = g_noaccel; |
| 1031 | sm750_dev->dual = g_dualview; |
| 1032 | spin_lock_init(&sm750_dev->slock); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1033 | |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 1034 | if (!sm750_dev->accel_off) { |
Sudip Mukherjee | d11ac7c | 2015-08-07 17:34:04 +0530 | [diff] [blame] | 1035 | /* |
| 1036 | * hook deInit and 2d routines, notes that below hw_xxx |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1037 | * routine can work on most of lynx chips |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 1038 | * if some chip need specific function, |
Sudip Mukherjee | d11ac7c | 2015-08-07 17:34:04 +0530 | [diff] [blame] | 1039 | * please hook it in smXXX_set_drv routine |
| 1040 | */ |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 1041 | sm750_dev->accel.de_init = hw_de_init; |
| 1042 | sm750_dev->accel.de_fillrect = hw_fillrect; |
| 1043 | sm750_dev->accel.de_copyarea = hw_copyarea; |
| 1044 | sm750_dev->accel.de_imageblit = hw_imageblit; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1045 | pr_info("enable 2d acceleration\n"); |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 1046 | } else { |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1047 | pr_info("disable 2d acceleration\n"); |
| 1048 | } |
| 1049 | |
| 1050 | /* call chip specific setup routine */ |
Mike Rapoport | 700591a | 2015-10-26 09:06:01 +0200 | [diff] [blame] | 1051 | sm750fb_setup(sm750_dev, g_settings); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1052 | |
| 1053 | /* call chip specific mmap routine */ |
Mike Rapoport | 700591a | 2015-10-26 09:06:01 +0200 | [diff] [blame] | 1054 | if (hw_sm750_map(sm750_dev, pdev)) { |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1055 | pr_err("Memory map failed\n"); |
| 1056 | goto err_map; |
| 1057 | } |
| 1058 | |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 1059 | if (!sm750_dev->mtrr_off) |
| 1060 | sm750_dev->mtrr.vram = arch_phys_wc_add(sm750_dev->vidmem_start, |
| 1061 | sm750_dev->vidmem_size); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1062 | |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 1063 | memset_io(sm750_dev->pvMem, 0, sm750_dev->vidmem_size); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1064 | |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 1065 | pr_info("sm%3x mmio address = %p\n", sm750_dev->devid, |
| 1066 | sm750_dev->pvReg); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1067 | |
Mike Rapoport | 083c204 | 2015-10-26 09:06:03 +0200 | [diff] [blame] | 1068 | pci_set_drvdata(pdev, sm750_dev); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1069 | |
| 1070 | /* call chipInit routine */ |
Mike Rapoport | 700591a | 2015-10-26 09:06:01 +0200 | [diff] [blame] | 1071 | hw_sm750_inithw(sm750_dev, pdev); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1072 | |
| 1073 | /* allocate frame buffer info structor according to g_dualview */ |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 1074 | fbidx = 0; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1075 | ALLOC_FB: |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 1076 | info[fbidx] = framebuffer_alloc(sizeof(struct lynxfb_par), &pdev->dev); |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 1077 | if (!info[fbidx]) { |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 1078 | pr_err("Could not allocate framebuffer #%d.\n", fbidx); |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 1079 | if (fbidx == 0) |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 1080 | goto err_info0_alloc; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1081 | else |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 1082 | goto err_info1_alloc; |
Michel von Czettritz | 70407df | 2015-03-26 23:25:08 +0100 | [diff] [blame] | 1083 | } else { |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 1084 | struct lynxfb_par *par; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 1085 | int errno; |
Michel von Czettritz | 876e5a7 | 2015-03-26 23:26:37 +0100 | [diff] [blame] | 1086 | |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 1087 | pr_info("framebuffer #%d alloc okay\n", fbidx); |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 1088 | sm750_dev->fbinfo[fbidx] = info[fbidx]; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 1089 | par = info[fbidx]->par; |
Mike Rapoport | f11fa2a | 2015-10-26 09:05:59 +0200 | [diff] [blame] | 1090 | par->dev = sm750_dev; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1091 | |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 1092 | /* set fb_info structure */ |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 1093 | if (lynxfb_set_fbinfo(info[fbidx], fbidx)) { |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 1094 | pr_err("Failed to initial fb_info #%d.\n", fbidx); |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 1095 | if (fbidx == 0) |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 1096 | goto err_info0_set; |
| 1097 | else |
| 1098 | goto err_info1_set; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1099 | } |
| 1100 | |
Michel von Czettritz | 4bd9503 | 2015-03-26 23:26:04 +0100 | [diff] [blame] | 1101 | /* register frame buffer */ |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 1102 | pr_info("Ready to register framebuffer #%d.\n", fbidx); |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 1103 | errno = register_framebuffer(info[fbidx]); |
| 1104 | if (errno < 0) { |
Michel von Czettritz | 3318bb5 | 2015-03-26 23:26:23 +0100 | [diff] [blame] | 1105 | pr_err("Failed to register fb_info #%d. err %d\n", |
Michel von Czettritz | 876e5a7 | 2015-03-26 23:26:37 +0100 | [diff] [blame] | 1106 | fbidx, |
| 1107 | errno); |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 1108 | if (fbidx == 0) |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 1109 | goto err_register0; |
| 1110 | else |
| 1111 | goto err_register1; |
| 1112 | } |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 1113 | pr_info("Accomplished register framebuffer #%d.\n", fbidx); |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 1114 | } |
| 1115 | |
| 1116 | /* no dual view by far */ |
| 1117 | fbidx++; |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 1118 | if (sm750_dev->dual && fbidx < 2) |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 1119 | goto ALLOC_FB; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1120 | |
| 1121 | return 0; |
| 1122 | |
| 1123 | err_register1: |
| 1124 | err_info1_set: |
| 1125 | framebuffer_release(info[1]); |
| 1126 | err_info1_alloc: |
| 1127 | unregister_framebuffer(info[0]); |
| 1128 | err_register0: |
| 1129 | err_info0_set: |
| 1130 | framebuffer_release(info[0]); |
| 1131 | err_info0_alloc: |
| 1132 | err_map: |
Mike Rapoport | 5ef2f68 | 2015-10-26 09:05:56 +0200 | [diff] [blame] | 1133 | kfree(sm750_dev); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1134 | err_share: |
| 1135 | err_enable: |
| 1136 | return -ENODEV; |
| 1137 | } |
| 1138 | |
Arnd Bergmann | bb6ce8b | 2015-04-11 00:03:19 +0200 | [diff] [blame] | 1139 | static void lynxfb_pci_remove(struct pci_dev *pdev) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1140 | { |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 1141 | struct fb_info *info; |
Mike Rapoport | 4fd92f5 | 2015-10-26 09:06:02 +0200 | [diff] [blame] | 1142 | struct sm750_dev *sm750_dev; |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 1143 | struct lynxfb_par *par; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1144 | int cnt; |
| 1145 | |
| 1146 | cnt = 2; |
Mike Rapoport | 083c204 | 2015-10-26 09:06:03 +0200 | [diff] [blame] | 1147 | sm750_dev = pci_get_drvdata(pdev); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1148 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 1149 | while (cnt-- > 0) { |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 1150 | info = sm750_dev->fbinfo[cnt]; |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 1151 | if (!info) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1152 | continue; |
| 1153 | par = info->par; |
| 1154 | |
| 1155 | unregister_framebuffer(info); |
Michel von Czettritz | 4bd9503 | 2015-03-26 23:26:04 +0100 | [diff] [blame] | 1156 | /* release frame buffer */ |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1157 | framebuffer_release(info); |
| 1158 | } |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 1159 | arch_phys_wc_del(sm750_dev->mtrr.vram); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1160 | |
Mike Rapoport | e359b6a | 2015-10-26 09:06:06 +0200 | [diff] [blame] | 1161 | iounmap(sm750_dev->pvReg); |
| 1162 | iounmap(sm750_dev->pvMem); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1163 | kfree(g_settings); |
Mike Rapoport | 5ef2f68 | 2015-10-26 09:05:56 +0200 | [diff] [blame] | 1164 | kfree(sm750_dev); |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 1165 | pci_set_drvdata(pdev, NULL); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1166 | } |
| 1167 | |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 1168 | static int __init lynxfb_setup(char *options) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1169 | { |
| 1170 | int len; |
Michel von Czettritz | 27fa159 | 2015-03-26 23:25:37 +0100 | [diff] [blame] | 1171 | char *opt, *tmp; |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 1172 | |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 1173 | if (!options || !*options) { |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1174 | pr_warn("no options.\n"); |
| 1175 | return 0; |
| 1176 | } |
| 1177 | |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 1178 | pr_info("options:%s\n", options); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1179 | |
| 1180 | len = strlen(options) + 1; |
Madhusudhanan Ravindran | a99e334 | 2015-03-10 23:07:39 +0530 | [diff] [blame] | 1181 | g_settings = kzalloc(len, GFP_KERNEL); |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 1182 | if (!g_settings) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1183 | return -ENOMEM; |
| 1184 | |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1185 | tmp = g_settings; |
| 1186 | |
Sudip Mukherjee | d11ac7c | 2015-08-07 17:34:04 +0530 | [diff] [blame] | 1187 | /* |
| 1188 | * Notes: |
| 1189 | * char * strsep(char **s,const char * ct); |
| 1190 | * @s: the string to be searched |
| 1191 | * @ct :the characters to search for |
| 1192 | * |
| 1193 | * strsep() updates @options to pointer after the first found token |
| 1194 | * it also returns the pointer ahead the token. |
| 1195 | */ |
Michel von Czettritz | a0c838f | 2015-03-26 23:26:52 +0100 | [diff] [blame] | 1196 | while ((opt = strsep(&options, ":")) != NULL) { |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1197 | /* options that mean for any lynx chips are configured here */ |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 1198 | if (!strncmp(opt, "noaccel", strlen("noaccel"))) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1199 | g_noaccel = 1; |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 1200 | else if (!strncmp(opt, "nomtrr", strlen("nomtrr"))) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1201 | g_nomtrr = 1; |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 1202 | else if (!strncmp(opt, "dual", strlen("dual"))) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1203 | g_dualview = 1; |
Michel von Czettritz | 70407df | 2015-03-26 23:25:08 +0100 | [diff] [blame] | 1204 | else { |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 1205 | strcat(tmp, opt); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1206 | tmp += strlen(opt); |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 1207 | if (options != NULL) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1208 | *tmp++ = ':'; |
| 1209 | else |
| 1210 | *tmp++ = 0; |
| 1211 | } |
| 1212 | } |
| 1213 | |
| 1214 | /* misc g_settings are transport to chip specific routines */ |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 1215 | pr_info("parameter left for chip specific analysis:%s\n", g_settings); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1216 | return 0; |
| 1217 | } |
| 1218 | |
| 1219 | static struct pci_device_id smi_pci_table[] = { |
| 1220 | { PCI_DEVICE(0x126f, 0x0750), }, |
| 1221 | {0,} |
| 1222 | }; |
| 1223 | |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 1224 | MODULE_DEVICE_TABLE(pci, smi_pci_table); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1225 | |
| 1226 | static struct pci_driver lynxfb_driver = { |
| 1227 | .name = "sm750fb", |
| 1228 | .id_table = smi_pci_table, |
| 1229 | .probe = lynxfb_pci_probe, |
| 1230 | .remove = lynxfb_pci_remove, |
| 1231 | #ifdef CONFIG_PM |
| 1232 | .suspend = lynxfb_suspend, |
| 1233 | .resume = lynxfb_resume, |
| 1234 | #endif |
| 1235 | }; |
| 1236 | |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1237 | static int __init lynxfb_init(void) |
| 1238 | { |
Michel von Czettritz | a0c838f | 2015-03-26 23:26:52 +0100 | [diff] [blame] | 1239 | char *option; |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1240 | int ret; |
| 1241 | |
| 1242 | #ifdef MODULE |
| 1243 | option = g_option; |
| 1244 | #else |
Michel von Czettritz | 5ace4e1 | 2015-03-26 23:25:22 +0100 | [diff] [blame] | 1245 | if (fb_get_options("sm750fb", &option)) |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1246 | return -ENODEV; |
| 1247 | #endif |
| 1248 | |
| 1249 | lynxfb_setup(option); |
| 1250 | ret = pci_register_driver(&lynxfb_driver); |
| 1251 | return ret; |
| 1252 | } |
| 1253 | module_init(lynxfb_init); |
| 1254 | |
| 1255 | static void __exit lynxfb_exit(void) |
| 1256 | { |
| 1257 | pci_unregister_driver(&lynxfb_driver); |
| 1258 | } |
| 1259 | module_exit(lynxfb_exit); |
| 1260 | |
Michel von Czettritz | 45e3b3d | 2015-03-26 23:24:53 +0100 | [diff] [blame] | 1261 | module_param(g_option, charp, S_IRUGO); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1262 | |
| 1263 | MODULE_PARM_DESC(g_option, |
Michel von Czettritz | c52c370 | 2015-03-26 23:24:32 +0100 | [diff] [blame] | 1264 | "\n\t\tCommon options:\n" |
| 1265 | "\t\tnoaccel:disable 2d capabilities\n" |
| 1266 | "\t\tnomtrr:disable MTRR attribute for video memory\n" |
| 1267 | "\t\tdualview:dual frame buffer feature enabled\n" |
| 1268 | "\t\tnohwc:disable hardware cursor\n" |
| 1269 | "\t\tUsual example:\n" |
| 1270 | "\t\tinsmod ./sm750fb.ko g_option=\"noaccel,nohwc,1280x1024-8@60\"\n" |
| 1271 | ); |
Sudip Mukherjee | 81dee67 | 2015-03-03 16:21:06 +0530 | [diff] [blame] | 1272 | |
| 1273 | MODULE_AUTHOR("monk liu <monk.liu@siliconmotion.com>"); |
| 1274 | MODULE_AUTHOR("Sudip Mukherjee <sudip@vectorindia.org>"); |
| 1275 | MODULE_DESCRIPTION("Frame buffer driver for SM750 chipset"); |
| 1276 | MODULE_LICENSE("GPL v2"); |