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