hid-picolcd_fb.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. /***************************************************************************
  2. * Copyright (C) 2010-2012 by Bruno Prémont <bonbons@linux-vserver.org> *
  3. * *
  4. * Based on Logitech G13 driver (v0.4) *
  5. * Copyright (C) 2009 by Rick L. Vinyard, Jr. <rvinyard@cs.nmsu.edu> *
  6. * *
  7. * This program is free software: you can redistribute it and/or modify *
  8. * it under the terms of the GNU General Public License as published by *
  9. * the Free Software Foundation, version 2 of the License. *
  10. * *
  11. * This driver is distributed in the hope that it will be useful, but *
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of *
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
  14. * General Public License for more details. *
  15. * *
  16. * You should have received a copy of the GNU General Public License *
  17. * along with this software. If not see <http://www.gnu.org/licenses/>. *
  18. ***************************************************************************/
  19. #include <linux/hid.h>
  20. #include "usbhid/usbhid.h"
  21. #include <linux/usb.h>
  22. #include <linux/fb.h>
  23. #include <linux/module.h>
  24. #include "hid-picolcd.h"
  25. /* Framebuffer
  26. *
  27. * The PicoLCD use a Topway LCD module of 256x64 pixel
  28. * This display area is tiled over 4 controllers with 8 tiles
  29. * each. Each tile has 8x64 pixel, each data byte representing
  30. * a 1-bit wide vertical line of the tile.
  31. *
  32. * The display can be updated at a tile granularity.
  33. *
  34. * Chip 1 Chip 2 Chip 3 Chip 4
  35. * +----------------+----------------+----------------+----------------+
  36. * | Tile 1 | Tile 1 | Tile 1 | Tile 1 |
  37. * +----------------+----------------+----------------+----------------+
  38. * | Tile 2 | Tile 2 | Tile 2 | Tile 2 |
  39. * +----------------+----------------+----------------+----------------+
  40. * ...
  41. * +----------------+----------------+----------------+----------------+
  42. * | Tile 8 | Tile 8 | Tile 8 | Tile 8 |
  43. * +----------------+----------------+----------------+----------------+
  44. */
  45. #define PICOLCDFB_NAME "picolcdfb"
  46. #define PICOLCDFB_WIDTH (256)
  47. #define PICOLCDFB_HEIGHT (64)
  48. #define PICOLCDFB_SIZE (PICOLCDFB_WIDTH * PICOLCDFB_HEIGHT / 8)
  49. #define PICOLCDFB_UPDATE_RATE_LIMIT 10
  50. #define PICOLCDFB_UPDATE_RATE_DEFAULT 2
  51. /* Framebuffer visual structures */
  52. static const struct fb_fix_screeninfo picolcdfb_fix = {
  53. .id = PICOLCDFB_NAME,
  54. .type = FB_TYPE_PACKED_PIXELS,
  55. .visual = FB_VISUAL_MONO01,
  56. .xpanstep = 0,
  57. .ypanstep = 0,
  58. .ywrapstep = 0,
  59. .line_length = PICOLCDFB_WIDTH / 8,
  60. .accel = FB_ACCEL_NONE,
  61. };
  62. static const struct fb_var_screeninfo picolcdfb_var = {
  63. .xres = PICOLCDFB_WIDTH,
  64. .yres = PICOLCDFB_HEIGHT,
  65. .xres_virtual = PICOLCDFB_WIDTH,
  66. .yres_virtual = PICOLCDFB_HEIGHT,
  67. .width = 103,
  68. .height = 26,
  69. .bits_per_pixel = 1,
  70. .grayscale = 1,
  71. .red = {
  72. .offset = 0,
  73. .length = 1,
  74. .msb_right = 0,
  75. },
  76. .green = {
  77. .offset = 0,
  78. .length = 1,
  79. .msb_right = 0,
  80. },
  81. .blue = {
  82. .offset = 0,
  83. .length = 1,
  84. .msb_right = 0,
  85. },
  86. .transp = {
  87. .offset = 0,
  88. .length = 0,
  89. .msb_right = 0,
  90. },
  91. };
  92. /* Send a given tile to PicoLCD */
  93. static int picolcd_fb_send_tile(struct hid_device *hdev, int chip, int tile)
  94. {
  95. struct picolcd_data *data = hid_get_drvdata(hdev);
  96. struct hid_report *report1 = picolcd_out_report(REPORT_LCD_CMD_DATA, hdev);
  97. struct hid_report *report2 = picolcd_out_report(REPORT_LCD_DATA, hdev);
  98. unsigned long flags;
  99. u8 *tdata;
  100. int i;
  101. if (!report1 || report1->maxfield != 1 || !report2 || report2->maxfield != 1)
  102. return -ENODEV;
  103. spin_lock_irqsave(&data->lock, flags);
  104. hid_set_field(report1->field[0], 0, chip << 2);
  105. hid_set_field(report1->field[0], 1, 0x02);
  106. hid_set_field(report1->field[0], 2, 0x00);
  107. hid_set_field(report1->field[0], 3, 0x00);
  108. hid_set_field(report1->field[0], 4, 0xb8 | tile);
  109. hid_set_field(report1->field[0], 5, 0x00);
  110. hid_set_field(report1->field[0], 6, 0x00);
  111. hid_set_field(report1->field[0], 7, 0x40);
  112. hid_set_field(report1->field[0], 8, 0x00);
  113. hid_set_field(report1->field[0], 9, 0x00);
  114. hid_set_field(report1->field[0], 10, 32);
  115. hid_set_field(report2->field[0], 0, (chip << 2) | 0x01);
  116. hid_set_field(report2->field[0], 1, 0x00);
  117. hid_set_field(report2->field[0], 2, 0x00);
  118. hid_set_field(report2->field[0], 3, 32);
  119. tdata = data->fb_vbitmap + (tile * 4 + chip) * 64;
  120. for (i = 0; i < 64; i++)
  121. if (i < 32)
  122. hid_set_field(report1->field[0], 11 + i, tdata[i]);
  123. else
  124. hid_set_field(report2->field[0], 4 + i - 32, tdata[i]);
  125. usbhid_submit_report(data->hdev, report1, USB_DIR_OUT);
  126. usbhid_submit_report(data->hdev, report2, USB_DIR_OUT);
  127. spin_unlock_irqrestore(&data->lock, flags);
  128. return 0;
  129. }
  130. /* Translate a single tile*/
  131. static int picolcd_fb_update_tile(u8 *vbitmap, const u8 *bitmap, int bpp,
  132. int chip, int tile)
  133. {
  134. int i, b, changed = 0;
  135. u8 tdata[64];
  136. u8 *vdata = vbitmap + (tile * 4 + chip) * 64;
  137. if (bpp == 1) {
  138. for (b = 7; b >= 0; b--) {
  139. const u8 *bdata = bitmap + tile * 256 + chip * 8 + b * 32;
  140. for (i = 0; i < 64; i++) {
  141. tdata[i] <<= 1;
  142. tdata[i] |= (bdata[i/8] >> (i % 8)) & 0x01;
  143. }
  144. }
  145. } else if (bpp == 8) {
  146. for (b = 7; b >= 0; b--) {
  147. const u8 *bdata = bitmap + (tile * 256 + chip * 8 + b * 32) * 8;
  148. for (i = 0; i < 64; i++) {
  149. tdata[i] <<= 1;
  150. tdata[i] |= (bdata[i] & 0x80) ? 0x01 : 0x00;
  151. }
  152. }
  153. } else {
  154. /* Oops, we should never get here! */
  155. WARN_ON(1);
  156. return 0;
  157. }
  158. for (i = 0; i < 64; i++)
  159. if (tdata[i] != vdata[i]) {
  160. changed = 1;
  161. vdata[i] = tdata[i];
  162. }
  163. return changed;
  164. }
  165. void picolcd_fb_refresh(struct picolcd_data *data)
  166. {
  167. if (data->fb_info)
  168. schedule_delayed_work(&data->fb_info->deferred_work, 0);
  169. }
  170. /* Reconfigure LCD display */
  171. int picolcd_fb_reset(struct picolcd_data *data, int clear)
  172. {
  173. struct hid_report *report = picolcd_out_report(REPORT_LCD_CMD, data->hdev);
  174. int i, j;
  175. unsigned long flags;
  176. static const u8 mapcmd[8] = { 0x00, 0x02, 0x00, 0x64, 0x3f, 0x00, 0x64, 0xc0 };
  177. if (!report || report->maxfield != 1)
  178. return -ENODEV;
  179. spin_lock_irqsave(&data->lock, flags);
  180. for (i = 0; i < 4; i++) {
  181. for (j = 0; j < report->field[0]->maxusage; j++)
  182. if (j == 0)
  183. hid_set_field(report->field[0], j, i << 2);
  184. else if (j < sizeof(mapcmd))
  185. hid_set_field(report->field[0], j, mapcmd[j]);
  186. else
  187. hid_set_field(report->field[0], j, 0);
  188. usbhid_submit_report(data->hdev, report, USB_DIR_OUT);
  189. }
  190. data->status |= PICOLCD_READY_FB;
  191. spin_unlock_irqrestore(&data->lock, flags);
  192. if (data->fb_bitmap) {
  193. if (clear) {
  194. memset(data->fb_vbitmap, 0, PICOLCDFB_SIZE);
  195. memset(data->fb_bitmap, 0, PICOLCDFB_SIZE*data->fb_bpp);
  196. }
  197. data->fb_force = 1;
  198. }
  199. /* schedule first output of framebuffer */
  200. picolcd_fb_refresh(data);
  201. return 0;
  202. }
  203. /* Update fb_vbitmap from the screen_base and send changed tiles to device */
  204. static void picolcd_fb_update(struct fb_info *info)
  205. {
  206. int chip, tile, n;
  207. unsigned long flags;
  208. struct picolcd_data *data;
  209. mutex_lock(&info->lock);
  210. data = info->par;
  211. if (!data)
  212. goto out;
  213. spin_lock_irqsave(&data->lock, flags);
  214. if (!(data->status & PICOLCD_READY_FB)) {
  215. spin_unlock_irqrestore(&data->lock, flags);
  216. picolcd_fb_reset(data, 0);
  217. } else {
  218. spin_unlock_irqrestore(&data->lock, flags);
  219. }
  220. /*
  221. * Translate the framebuffer into the format needed by the PicoLCD.
  222. * See display layout above.
  223. * Do this one tile after the other and push those tiles that changed.
  224. *
  225. * Wait for our IO to complete as otherwise we might flood the queue!
  226. */
  227. n = 0;
  228. for (chip = 0; chip < 4; chip++)
  229. for (tile = 0; tile < 8; tile++)
  230. if (picolcd_fb_update_tile(data->fb_vbitmap,
  231. data->fb_bitmap, data->fb_bpp, chip, tile) ||
  232. data->fb_force) {
  233. n += 2;
  234. if (n >= HID_OUTPUT_FIFO_SIZE / 2) {
  235. mutex_unlock(&info->lock);
  236. usbhid_wait_io(data->hdev);
  237. mutex_lock(&info->lock);
  238. data = info->par;
  239. if (!data)
  240. goto out;
  241. spin_lock_irqsave(&data->lock, flags);
  242. if (data->status & PICOLCD_FAILED) {
  243. spin_unlock_irqrestore(&data->lock, flags);
  244. goto out;
  245. }
  246. spin_unlock_irqrestore(&data->lock, flags);
  247. n = 0;
  248. }
  249. picolcd_fb_send_tile(data->hdev, chip, tile);
  250. }
  251. data->fb_force = false;
  252. if (n) {
  253. mutex_unlock(&info->lock);
  254. usbhid_wait_io(data->hdev);
  255. return;
  256. }
  257. out:
  258. mutex_unlock(&info->lock);
  259. }
  260. /* Stub to call the system default and update the image on the picoLCD */
  261. static void picolcd_fb_fillrect(struct fb_info *info,
  262. const struct fb_fillrect *rect)
  263. {
  264. if (!info->par)
  265. return;
  266. sys_fillrect(info, rect);
  267. schedule_delayed_work(&info->deferred_work, 0);
  268. }
  269. /* Stub to call the system default and update the image on the picoLCD */
  270. static void picolcd_fb_copyarea(struct fb_info *info,
  271. const struct fb_copyarea *area)
  272. {
  273. if (!info->par)
  274. return;
  275. sys_copyarea(info, area);
  276. schedule_delayed_work(&info->deferred_work, 0);
  277. }
  278. /* Stub to call the system default and update the image on the picoLCD */
  279. static void picolcd_fb_imageblit(struct fb_info *info, const struct fb_image *image)
  280. {
  281. if (!info->par)
  282. return;
  283. sys_imageblit(info, image);
  284. schedule_delayed_work(&info->deferred_work, 0);
  285. }
  286. /*
  287. * this is the slow path from userspace. they can seek and write to
  288. * the fb. it's inefficient to do anything less than a full screen draw
  289. */
  290. static ssize_t picolcd_fb_write(struct fb_info *info, const char __user *buf,
  291. size_t count, loff_t *ppos)
  292. {
  293. ssize_t ret;
  294. if (!info->par)
  295. return -ENODEV;
  296. ret = fb_sys_write(info, buf, count, ppos);
  297. if (ret >= 0)
  298. schedule_delayed_work(&info->deferred_work, 0);
  299. return ret;
  300. }
  301. static int picolcd_fb_blank(int blank, struct fb_info *info)
  302. {
  303. if (!info->par)
  304. return -ENODEV;
  305. /* We let fb notification do this for us via lcd/backlight device */
  306. return 0;
  307. }
  308. static void picolcd_fb_destroy(struct fb_info *info)
  309. {
  310. /* make sure no work is deferred */
  311. fb_deferred_io_cleanup(info);
  312. vfree((u8 *)info->fix.smem_start);
  313. framebuffer_release(info);
  314. printk(KERN_DEBUG "picolcd_fb_destroy(%p)\n", info);
  315. }
  316. static int picolcd_fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
  317. {
  318. __u32 bpp = var->bits_per_pixel;
  319. __u32 activate = var->activate;
  320. /* only allow 1/8 bit depth (8-bit is grayscale) */
  321. *var = picolcdfb_var;
  322. var->activate = activate;
  323. if (bpp >= 8) {
  324. var->bits_per_pixel = 8;
  325. var->red.length = 8;
  326. var->green.length = 8;
  327. var->blue.length = 8;
  328. } else {
  329. var->bits_per_pixel = 1;
  330. var->red.length = 1;
  331. var->green.length = 1;
  332. var->blue.length = 1;
  333. }
  334. return 0;
  335. }
  336. static int picolcd_set_par(struct fb_info *info)
  337. {
  338. struct picolcd_data *data = info->par;
  339. u8 *tmp_fb, *o_fb;
  340. if (!data)
  341. return -ENODEV;
  342. if (info->var.bits_per_pixel == data->fb_bpp)
  343. return 0;
  344. /* switch between 1/8 bit depths */
  345. if (info->var.bits_per_pixel != 1 && info->var.bits_per_pixel != 8)
  346. return -EINVAL;
  347. o_fb = data->fb_bitmap;
  348. tmp_fb = kmalloc(PICOLCDFB_SIZE*info->var.bits_per_pixel, GFP_KERNEL);
  349. if (!tmp_fb)
  350. return -ENOMEM;
  351. /* translate FB content to new bits-per-pixel */
  352. if (info->var.bits_per_pixel == 1) {
  353. int i, b;
  354. for (i = 0; i < PICOLCDFB_SIZE; i++) {
  355. u8 p = 0;
  356. for (b = 0; b < 8; b++) {
  357. p <<= 1;
  358. p |= o_fb[i*8+b] ? 0x01 : 0x00;
  359. }
  360. tmp_fb[i] = p;
  361. }
  362. memcpy(o_fb, tmp_fb, PICOLCDFB_SIZE);
  363. info->fix.visual = FB_VISUAL_MONO01;
  364. info->fix.line_length = PICOLCDFB_WIDTH / 8;
  365. } else {
  366. int i;
  367. memcpy(tmp_fb, o_fb, PICOLCDFB_SIZE);
  368. for (i = 0; i < PICOLCDFB_SIZE * 8; i++)
  369. o_fb[i] = tmp_fb[i/8] & (0x01 << (7 - i % 8)) ? 0xff : 0x00;
  370. info->fix.visual = FB_VISUAL_DIRECTCOLOR;
  371. info->fix.line_length = PICOLCDFB_WIDTH;
  372. }
  373. kfree(tmp_fb);
  374. data->fb_bpp = info->var.bits_per_pixel;
  375. return 0;
  376. }
  377. /* Note this can't be const because of struct fb_info definition */
  378. static struct fb_ops picolcdfb_ops = {
  379. .owner = THIS_MODULE,
  380. .fb_destroy = picolcd_fb_destroy,
  381. .fb_read = fb_sys_read,
  382. .fb_write = picolcd_fb_write,
  383. .fb_blank = picolcd_fb_blank,
  384. .fb_fillrect = picolcd_fb_fillrect,
  385. .fb_copyarea = picolcd_fb_copyarea,
  386. .fb_imageblit = picolcd_fb_imageblit,
  387. .fb_check_var = picolcd_fb_check_var,
  388. .fb_set_par = picolcd_set_par,
  389. };
  390. /* Callback from deferred IO workqueue */
  391. static void picolcd_fb_deferred_io(struct fb_info *info, struct list_head *pagelist)
  392. {
  393. picolcd_fb_update(info);
  394. }
  395. static const struct fb_deferred_io picolcd_fb_defio = {
  396. .delay = HZ / PICOLCDFB_UPDATE_RATE_DEFAULT,
  397. .deferred_io = picolcd_fb_deferred_io,
  398. };
  399. /*
  400. * The "fb_update_rate" sysfs attribute
  401. */
  402. static ssize_t picolcd_fb_update_rate_show(struct device *dev,
  403. struct device_attribute *attr, char *buf)
  404. {
  405. struct picolcd_data *data = dev_get_drvdata(dev);
  406. unsigned i, fb_update_rate = data->fb_update_rate;
  407. size_t ret = 0;
  408. for (i = 1; i <= PICOLCDFB_UPDATE_RATE_LIMIT; i++)
  409. if (ret >= PAGE_SIZE)
  410. break;
  411. else if (i == fb_update_rate)
  412. ret += snprintf(buf+ret, PAGE_SIZE-ret, "[%u] ", i);
  413. else
  414. ret += snprintf(buf+ret, PAGE_SIZE-ret, "%u ", i);
  415. if (ret > 0)
  416. buf[min(ret, (size_t)PAGE_SIZE)-1] = '\n';
  417. return ret;
  418. }
  419. static ssize_t picolcd_fb_update_rate_store(struct device *dev,
  420. struct device_attribute *attr, const char *buf, size_t count)
  421. {
  422. struct picolcd_data *data = dev_get_drvdata(dev);
  423. int i;
  424. unsigned u;
  425. if (count < 1 || count > 10)
  426. return -EINVAL;
  427. i = sscanf(buf, "%u", &u);
  428. if (i != 1)
  429. return -EINVAL;
  430. if (u > PICOLCDFB_UPDATE_RATE_LIMIT)
  431. return -ERANGE;
  432. else if (u == 0)
  433. u = PICOLCDFB_UPDATE_RATE_DEFAULT;
  434. data->fb_update_rate = u;
  435. data->fb_info->fbdefio->delay = HZ / data->fb_update_rate;
  436. return count;
  437. }
  438. static DEVICE_ATTR(fb_update_rate, 0666, picolcd_fb_update_rate_show,
  439. picolcd_fb_update_rate_store);
  440. /* initialize Framebuffer device */
  441. int picolcd_init_framebuffer(struct picolcd_data *data)
  442. {
  443. struct device *dev = &data->hdev->dev;
  444. struct fb_info *info = NULL;
  445. int i, error = -ENOMEM;
  446. u8 *fb_vbitmap = NULL;
  447. u8 *fb_bitmap = NULL;
  448. u32 *palette;
  449. fb_bitmap = vmalloc(PICOLCDFB_SIZE*8);
  450. if (fb_bitmap == NULL) {
  451. dev_err(dev, "can't get a free page for framebuffer\n");
  452. goto err_nomem;
  453. }
  454. fb_vbitmap = kmalloc(PICOLCDFB_SIZE, GFP_KERNEL);
  455. if (fb_vbitmap == NULL) {
  456. dev_err(dev, "can't alloc vbitmap image buffer\n");
  457. goto err_nomem;
  458. }
  459. data->fb_update_rate = PICOLCDFB_UPDATE_RATE_DEFAULT;
  460. /* The extra memory is:
  461. * - 256*u32 for pseudo_palette
  462. * - struct fb_deferred_io
  463. */
  464. info = framebuffer_alloc(256 * sizeof(u32) +
  465. sizeof(struct fb_deferred_io), dev);
  466. if (info == NULL) {
  467. dev_err(dev, "failed to allocate a framebuffer\n");
  468. goto err_nomem;
  469. }
  470. info->fbdefio = info->par;
  471. *info->fbdefio = picolcd_fb_defio;
  472. palette = info->par + sizeof(struct fb_deferred_io);
  473. for (i = 0; i < 256; i++)
  474. palette[i] = i > 0 && i < 16 ? 0xff : 0;
  475. info->pseudo_palette = palette;
  476. info->screen_base = (char __force __iomem *)fb_bitmap;
  477. info->fbops = &picolcdfb_ops;
  478. info->var = picolcdfb_var;
  479. info->fix = picolcdfb_fix;
  480. info->fix.smem_len = PICOLCDFB_SIZE*8;
  481. info->fix.smem_start = (unsigned long)fb_bitmap;
  482. info->par = data;
  483. info->flags = FBINFO_FLAG_DEFAULT;
  484. data->fb_vbitmap = fb_vbitmap;
  485. data->fb_bitmap = fb_bitmap;
  486. data->fb_bpp = picolcdfb_var.bits_per_pixel;
  487. error = picolcd_fb_reset(data, 1);
  488. if (error) {
  489. dev_err(dev, "failed to configure display\n");
  490. goto err_cleanup;
  491. }
  492. error = device_create_file(dev, &dev_attr_fb_update_rate);
  493. if (error) {
  494. dev_err(dev, "failed to create sysfs attributes\n");
  495. goto err_cleanup;
  496. }
  497. fb_deferred_io_init(info);
  498. data->fb_info = info;
  499. error = register_framebuffer(info);
  500. if (error) {
  501. dev_err(dev, "failed to register framebuffer\n");
  502. goto err_sysfs;
  503. }
  504. /* schedule first output of framebuffer */
  505. data->fb_force = 1;
  506. schedule_delayed_work(&info->deferred_work, 0);
  507. return 0;
  508. err_sysfs:
  509. fb_deferred_io_cleanup(info);
  510. device_remove_file(dev, &dev_attr_fb_update_rate);
  511. err_cleanup:
  512. data->fb_vbitmap = NULL;
  513. data->fb_bitmap = NULL;
  514. data->fb_bpp = 0;
  515. data->fb_info = NULL;
  516. err_nomem:
  517. framebuffer_release(info);
  518. vfree(fb_bitmap);
  519. kfree(fb_vbitmap);
  520. return error;
  521. }
  522. void picolcd_exit_framebuffer(struct picolcd_data *data)
  523. {
  524. struct fb_info *info = data->fb_info;
  525. u8 *fb_vbitmap = data->fb_vbitmap;
  526. if (!info)
  527. return;
  528. device_remove_file(&data->hdev->dev, &dev_attr_fb_update_rate);
  529. info->par = NULL;
  530. unregister_framebuffer(info);
  531. data->fb_vbitmap = NULL;
  532. data->fb_bitmap = NULL;
  533. data->fb_bpp = 0;
  534. data->fb_info = NULL;
  535. kfree(fb_vbitmap);
  536. }