fbmem.c 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989
  1. /*
  2. * linux/drivers/video/fbmem.c
  3. *
  4. * Copyright (C) 1994 Martin Schaller
  5. *
  6. * 2001 - Documented with DocBook
  7. * - Brad Douglas <brad@neruo.com>
  8. *
  9. * This file is subject to the terms and conditions of the GNU General Public
  10. * License. See the file COPYING in the main directory of this archive
  11. * for more details.
  12. */
  13. #include <linux/module.h>
  14. #include <linux/compat.h>
  15. #include <linux/types.h>
  16. #include <linux/errno.h>
  17. #include <linux/kernel.h>
  18. #include <linux/major.h>
  19. #include <linux/slab.h>
  20. #include <linux/mm.h>
  21. #include <linux/mman.h>
  22. #include <linux/vt.h>
  23. #include <linux/init.h>
  24. #include <linux/linux_logo.h>
  25. #include <linux/proc_fs.h>
  26. #include <linux/seq_file.h>
  27. #include <linux/console.h>
  28. #include <linux/kmod.h>
  29. #include <linux/err.h>
  30. #include <linux/device.h>
  31. #include <linux/efi.h>
  32. #include <linux/fb.h>
  33. #include <asm/fb.h>
  34. /*
  35. * Frame buffer device initialization and setup routines
  36. */
  37. #define FBPIXMAPSIZE (1024 * 8)
  38. static DEFINE_MUTEX(registration_lock);
  39. struct fb_info *registered_fb[FB_MAX] __read_mostly;
  40. EXPORT_SYMBOL(registered_fb);
  41. int num_registered_fb __read_mostly;
  42. EXPORT_SYMBOL(num_registered_fb);
  43. static struct fb_info *get_fb_info(unsigned int idx)
  44. {
  45. struct fb_info *fb_info;
  46. if (idx >= FB_MAX)
  47. return ERR_PTR(-ENODEV);
  48. mutex_lock(&registration_lock);
  49. fb_info = registered_fb[idx];
  50. if (fb_info)
  51. atomic_inc(&fb_info->count);
  52. mutex_unlock(&registration_lock);
  53. return fb_info;
  54. }
  55. static void put_fb_info(struct fb_info *fb_info)
  56. {
  57. if (!atomic_dec_and_test(&fb_info->count))
  58. return;
  59. if (fb_info->fbops->fb_destroy)
  60. fb_info->fbops->fb_destroy(fb_info);
  61. }
  62. int lock_fb_info(struct fb_info *info)
  63. {
  64. mutex_lock(&info->lock);
  65. if (!info->fbops) {
  66. mutex_unlock(&info->lock);
  67. return 0;
  68. }
  69. return 1;
  70. }
  71. EXPORT_SYMBOL(lock_fb_info);
  72. /*
  73. * Helpers
  74. */
  75. int fb_get_color_depth(struct fb_var_screeninfo *var,
  76. struct fb_fix_screeninfo *fix)
  77. {
  78. int depth = 0;
  79. if (fix->visual == FB_VISUAL_MONO01 ||
  80. fix->visual == FB_VISUAL_MONO10)
  81. depth = 1;
  82. else {
  83. if (var->green.length == var->blue.length &&
  84. var->green.length == var->red.length &&
  85. var->green.offset == var->blue.offset &&
  86. var->green.offset == var->red.offset)
  87. depth = var->green.length;
  88. else
  89. depth = var->green.length + var->red.length +
  90. var->blue.length;
  91. }
  92. return depth;
  93. }
  94. EXPORT_SYMBOL(fb_get_color_depth);
  95. /*
  96. * Data padding functions.
  97. */
  98. void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u32 height)
  99. {
  100. __fb_pad_aligned_buffer(dst, d_pitch, src, s_pitch, height);
  101. }
  102. EXPORT_SYMBOL(fb_pad_aligned_buffer);
  103. void fb_pad_unaligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 idx, u32 height,
  104. u32 shift_high, u32 shift_low, u32 mod)
  105. {
  106. u8 mask = (u8) (0xfff << shift_high), tmp;
  107. int i, j;
  108. for (i = height; i--; ) {
  109. for (j = 0; j < idx; j++) {
  110. tmp = dst[j];
  111. tmp &= mask;
  112. tmp |= *src >> shift_low;
  113. dst[j] = tmp;
  114. tmp = *src << shift_high;
  115. dst[j+1] = tmp;
  116. src++;
  117. }
  118. tmp = dst[idx];
  119. tmp &= mask;
  120. tmp |= *src >> shift_low;
  121. dst[idx] = tmp;
  122. if (shift_high < mod) {
  123. tmp = *src << shift_high;
  124. dst[idx+1] = tmp;
  125. }
  126. src++;
  127. dst += d_pitch;
  128. }
  129. }
  130. EXPORT_SYMBOL(fb_pad_unaligned_buffer);
  131. /*
  132. * we need to lock this section since fb_cursor
  133. * may use fb_imageblit()
  134. */
  135. char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size)
  136. {
  137. u32 align = buf->buf_align - 1, offset;
  138. char *addr = buf->addr;
  139. /* If IO mapped, we need to sync before access, no sharing of
  140. * the pixmap is done
  141. */
  142. if (buf->flags & FB_PIXMAP_IO) {
  143. if (info->fbops->fb_sync && (buf->flags & FB_PIXMAP_SYNC))
  144. info->fbops->fb_sync(info);
  145. return addr;
  146. }
  147. /* See if we fit in the remaining pixmap space */
  148. offset = buf->offset + align;
  149. offset &= ~align;
  150. if (offset + size > buf->size) {
  151. /* We do not fit. In order to be able to re-use the buffer,
  152. * we must ensure no asynchronous DMA'ing or whatever operation
  153. * is in progress, we sync for that.
  154. */
  155. if (info->fbops->fb_sync && (buf->flags & FB_PIXMAP_SYNC))
  156. info->fbops->fb_sync(info);
  157. offset = 0;
  158. }
  159. buf->offset = offset + size;
  160. addr += offset;
  161. return addr;
  162. }
  163. EXPORT_SYMBOL(fb_get_buffer_offset);
  164. #ifdef CONFIG_LOGO
  165. static inline unsigned safe_shift(unsigned d, int n)
  166. {
  167. return n < 0 ? d >> -n : d << n;
  168. }
  169. static void fb_set_logocmap(struct fb_info *info,
  170. const struct linux_logo *logo)
  171. {
  172. struct fb_cmap palette_cmap;
  173. u16 palette_green[16];
  174. u16 palette_blue[16];
  175. u16 palette_red[16];
  176. int i, j, n;
  177. const unsigned char *clut = logo->clut;
  178. palette_cmap.start = 0;
  179. palette_cmap.len = 16;
  180. palette_cmap.red = palette_red;
  181. palette_cmap.green = palette_green;
  182. palette_cmap.blue = palette_blue;
  183. palette_cmap.transp = NULL;
  184. for (i = 0; i < logo->clutsize; i += n) {
  185. n = logo->clutsize - i;
  186. /* palette_cmap provides space for only 16 colors at once */
  187. if (n > 16)
  188. n = 16;
  189. palette_cmap.start = 32 + i;
  190. palette_cmap.len = n;
  191. for (j = 0; j < n; ++j) {
  192. palette_cmap.red[j] = clut[0] << 8 | clut[0];
  193. palette_cmap.green[j] = clut[1] << 8 | clut[1];
  194. palette_cmap.blue[j] = clut[2] << 8 | clut[2];
  195. clut += 3;
  196. }
  197. fb_set_cmap(&palette_cmap, info);
  198. }
  199. }
  200. static void fb_set_logo_truepalette(struct fb_info *info,
  201. const struct linux_logo *logo,
  202. u32 *palette)
  203. {
  204. static const unsigned char mask[] = { 0,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff };
  205. unsigned char redmask, greenmask, bluemask;
  206. int redshift, greenshift, blueshift;
  207. int i;
  208. const unsigned char *clut = logo->clut;
  209. /*
  210. * We have to create a temporary palette since console palette is only
  211. * 16 colors long.
  212. */
  213. /* Bug: Doesn't obey msb_right ... (who needs that?) */
  214. redmask = mask[info->var.red.length < 8 ? info->var.red.length : 8];
  215. greenmask = mask[info->var.green.length < 8 ? info->var.green.length : 8];
  216. bluemask = mask[info->var.blue.length < 8 ? info->var.blue.length : 8];
  217. redshift = info->var.red.offset - (8 - info->var.red.length);
  218. greenshift = info->var.green.offset - (8 - info->var.green.length);
  219. blueshift = info->var.blue.offset - (8 - info->var.blue.length);
  220. for ( i = 0; i < logo->clutsize; i++) {
  221. palette[i+32] = (safe_shift((clut[0] & redmask), redshift) |
  222. safe_shift((clut[1] & greenmask), greenshift) |
  223. safe_shift((clut[2] & bluemask), blueshift));
  224. clut += 3;
  225. }
  226. }
  227. static void fb_set_logo_directpalette(struct fb_info *info,
  228. const struct linux_logo *logo,
  229. u32 *palette)
  230. {
  231. int redshift, greenshift, blueshift;
  232. int i;
  233. redshift = info->var.red.offset;
  234. greenshift = info->var.green.offset;
  235. blueshift = info->var.blue.offset;
  236. for (i = 32; i < 32 + logo->clutsize; i++)
  237. palette[i] = i << redshift | i << greenshift | i << blueshift;
  238. }
  239. static void fb_set_logo(struct fb_info *info,
  240. const struct linux_logo *logo, u8 *dst,
  241. int depth)
  242. {
  243. int i, j, k;
  244. const u8 *src = logo->data;
  245. u8 xor = (info->fix.visual == FB_VISUAL_MONO01) ? 0xff : 0;
  246. u8 fg = 1, d;
  247. switch (fb_get_color_depth(&info->var, &info->fix)) {
  248. case 1:
  249. fg = 1;
  250. break;
  251. case 2:
  252. fg = 3;
  253. break;
  254. default:
  255. fg = 7;
  256. break;
  257. }
  258. if (info->fix.visual == FB_VISUAL_MONO01 ||
  259. info->fix.visual == FB_VISUAL_MONO10)
  260. fg = ~((u8) (0xfff << info->var.green.length));
  261. switch (depth) {
  262. case 4:
  263. for (i = 0; i < logo->height; i++)
  264. for (j = 0; j < logo->width; src++) {
  265. *dst++ = *src >> 4;
  266. j++;
  267. if (j < logo->width) {
  268. *dst++ = *src & 0x0f;
  269. j++;
  270. }
  271. }
  272. break;
  273. case 1:
  274. for (i = 0; i < logo->height; i++) {
  275. for (j = 0; j < logo->width; src++) {
  276. d = *src ^ xor;
  277. for (k = 7; k >= 0; k--) {
  278. *dst++ = ((d >> k) & 1) ? fg : 0;
  279. j++;
  280. }
  281. }
  282. }
  283. break;
  284. }
  285. }
  286. /*
  287. * Three (3) kinds of logo maps exist. linux_logo_clut224 (>16 colors),
  288. * linux_logo_vga16 (16 colors) and linux_logo_mono (2 colors). Depending on
  289. * the visual format and color depth of the framebuffer, the DAC, the
  290. * pseudo_palette, and the logo data will be adjusted accordingly.
  291. *
  292. * Case 1 - linux_logo_clut224:
  293. * Color exceeds the number of console colors (16), thus we set the hardware DAC
  294. * using fb_set_cmap() appropriately. The "needs_cmapreset" flag will be set.
  295. *
  296. * For visuals that require color info from the pseudo_palette, we also construct
  297. * one for temporary use. The "needs_directpalette" or "needs_truepalette" flags
  298. * will be set.
  299. *
  300. * Case 2 - linux_logo_vga16:
  301. * The number of colors just matches the console colors, thus there is no need
  302. * to set the DAC or the pseudo_palette. However, the bitmap is packed, ie,
  303. * each byte contains color information for two pixels (upper and lower nibble).
  304. * To be consistent with fb_imageblit() usage, we therefore separate the two
  305. * nibbles into separate bytes. The "depth" flag will be set to 4.
  306. *
  307. * Case 3 - linux_logo_mono:
  308. * This is similar with Case 2. Each byte contains information for 8 pixels.
  309. * We isolate each bit and expand each into a byte. The "depth" flag will
  310. * be set to 1.
  311. */
  312. static struct logo_data {
  313. int depth;
  314. int needs_directpalette;
  315. int needs_truepalette;
  316. int needs_cmapreset;
  317. const struct linux_logo *logo;
  318. } fb_logo __read_mostly;
  319. static void fb_rotate_logo_ud(const u8 *in, u8 *out, u32 width, u32 height)
  320. {
  321. u32 size = width * height, i;
  322. out += size - 1;
  323. for (i = size; i--; )
  324. *out-- = *in++;
  325. }
  326. static void fb_rotate_logo_cw(const u8 *in, u8 *out, u32 width, u32 height)
  327. {
  328. int i, j, h = height - 1;
  329. for (i = 0; i < height; i++)
  330. for (j = 0; j < width; j++)
  331. out[height * j + h - i] = *in++;
  332. }
  333. static void fb_rotate_logo_ccw(const u8 *in, u8 *out, u32 width, u32 height)
  334. {
  335. int i, j, w = width - 1;
  336. for (i = 0; i < height; i++)
  337. for (j = 0; j < width; j++)
  338. out[height * (w - j) + i] = *in++;
  339. }
  340. static void fb_rotate_logo(struct fb_info *info, u8 *dst,
  341. struct fb_image *image, int rotate)
  342. {
  343. u32 tmp;
  344. if (rotate == FB_ROTATE_UD) {
  345. fb_rotate_logo_ud(image->data, dst, image->width,
  346. image->height);
  347. image->dx = info->var.xres - image->width - image->dx;
  348. image->dy = info->var.yres - image->height - image->dy;
  349. } else if (rotate == FB_ROTATE_CW) {
  350. fb_rotate_logo_cw(image->data, dst, image->width,
  351. image->height);
  352. tmp = image->width;
  353. image->width = image->height;
  354. image->height = tmp;
  355. tmp = image->dy;
  356. image->dy = image->dx;
  357. image->dx = info->var.xres - image->width - tmp;
  358. } else if (rotate == FB_ROTATE_CCW) {
  359. fb_rotate_logo_ccw(image->data, dst, image->width,
  360. image->height);
  361. tmp = image->width;
  362. image->width = image->height;
  363. image->height = tmp;
  364. tmp = image->dx;
  365. image->dx = image->dy;
  366. image->dy = info->var.yres - image->height - tmp;
  367. }
  368. image->data = dst;
  369. }
  370. static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
  371. int rotate, unsigned int num)
  372. {
  373. unsigned int x;
  374. if (rotate == FB_ROTATE_UR) {
  375. for (x = 0;
  376. x < num && image->dx + image->width <= info->var.xres;
  377. x++) {
  378. info->fbops->fb_imageblit(info, image);
  379. image->dx += image->width + 8;
  380. }
  381. } else if (rotate == FB_ROTATE_UD) {
  382. for (x = 0; x < num && image->dx >= 0; x++) {
  383. info->fbops->fb_imageblit(info, image);
  384. image->dx -= image->width + 8;
  385. }
  386. } else if (rotate == FB_ROTATE_CW) {
  387. for (x = 0;
  388. x < num && image->dy + image->height <= info->var.yres;
  389. x++) {
  390. info->fbops->fb_imageblit(info, image);
  391. image->dy += image->height + 8;
  392. }
  393. } else if (rotate == FB_ROTATE_CCW) {
  394. for (x = 0; x < num && image->dy >= 0; x++) {
  395. info->fbops->fb_imageblit(info, image);
  396. image->dy -= image->height + 8;
  397. }
  398. }
  399. }
  400. static int fb_show_logo_line(struct fb_info *info, int rotate,
  401. const struct linux_logo *logo, int y,
  402. unsigned int n)
  403. {
  404. u32 *palette = NULL, *saved_pseudo_palette = NULL;
  405. unsigned char *logo_new = NULL, *logo_rotate = NULL;
  406. struct fb_image image;
  407. /* Return if the frame buffer is not mapped or suspended */
  408. if (logo == NULL || info->state != FBINFO_STATE_RUNNING ||
  409. info->flags & FBINFO_MODULE)
  410. return 0;
  411. image.depth = 8;
  412. image.data = logo->data;
  413. if (fb_logo.needs_cmapreset)
  414. fb_set_logocmap(info, logo);
  415. if (fb_logo.needs_truepalette ||
  416. fb_logo.needs_directpalette) {
  417. palette = kmalloc(256 * 4, GFP_KERNEL);
  418. if (palette == NULL)
  419. return 0;
  420. if (fb_logo.needs_truepalette)
  421. fb_set_logo_truepalette(info, logo, palette);
  422. else
  423. fb_set_logo_directpalette(info, logo, palette);
  424. saved_pseudo_palette = info->pseudo_palette;
  425. info->pseudo_palette = palette;
  426. }
  427. if (fb_logo.depth <= 4) {
  428. logo_new = kmalloc(logo->width * logo->height, GFP_KERNEL);
  429. if (logo_new == NULL) {
  430. kfree(palette);
  431. if (saved_pseudo_palette)
  432. info->pseudo_palette = saved_pseudo_palette;
  433. return 0;
  434. }
  435. image.data = logo_new;
  436. fb_set_logo(info, logo, logo_new, fb_logo.depth);
  437. }
  438. image.dx = 0;
  439. image.dy = y;
  440. image.width = logo->width;
  441. image.height = logo->height;
  442. if (rotate) {
  443. logo_rotate = kmalloc(logo->width *
  444. logo->height, GFP_KERNEL);
  445. if (logo_rotate)
  446. fb_rotate_logo(info, logo_rotate, &image, rotate);
  447. }
  448. fb_do_show_logo(info, &image, rotate, n);
  449. kfree(palette);
  450. if (saved_pseudo_palette != NULL)
  451. info->pseudo_palette = saved_pseudo_palette;
  452. kfree(logo_new);
  453. kfree(logo_rotate);
  454. return logo->height;
  455. }
  456. #ifdef CONFIG_FB_LOGO_EXTRA
  457. #define FB_LOGO_EX_NUM_MAX 10
  458. static struct logo_data_extra {
  459. const struct linux_logo *logo;
  460. unsigned int n;
  461. } fb_logo_ex[FB_LOGO_EX_NUM_MAX];
  462. static unsigned int fb_logo_ex_num;
  463. void fb_append_extra_logo(const struct linux_logo *logo, unsigned int n)
  464. {
  465. if (!n || fb_logo_ex_num == FB_LOGO_EX_NUM_MAX)
  466. return;
  467. fb_logo_ex[fb_logo_ex_num].logo = logo;
  468. fb_logo_ex[fb_logo_ex_num].n = n;
  469. fb_logo_ex_num++;
  470. }
  471. static int fb_prepare_extra_logos(struct fb_info *info, unsigned int height,
  472. unsigned int yres)
  473. {
  474. unsigned int i;
  475. /* FIXME: logo_ex supports only truecolor fb. */
  476. if (info->fix.visual != FB_VISUAL_TRUECOLOR)
  477. fb_logo_ex_num = 0;
  478. for (i = 0; i < fb_logo_ex_num; i++) {
  479. if (fb_logo_ex[i].logo->type != fb_logo.logo->type) {
  480. fb_logo_ex[i].logo = NULL;
  481. continue;
  482. }
  483. height += fb_logo_ex[i].logo->height;
  484. if (height > yres) {
  485. height -= fb_logo_ex[i].logo->height;
  486. fb_logo_ex_num = i;
  487. break;
  488. }
  489. }
  490. return height;
  491. }
  492. static int fb_show_extra_logos(struct fb_info *info, int y, int rotate)
  493. {
  494. unsigned int i;
  495. for (i = 0; i < fb_logo_ex_num; i++)
  496. y += fb_show_logo_line(info, rotate,
  497. fb_logo_ex[i].logo, y, fb_logo_ex[i].n);
  498. return y;
  499. }
  500. #else /* !CONFIG_FB_LOGO_EXTRA */
  501. static inline int fb_prepare_extra_logos(struct fb_info *info,
  502. unsigned int height,
  503. unsigned int yres)
  504. {
  505. return height;
  506. }
  507. static inline int fb_show_extra_logos(struct fb_info *info, int y, int rotate)
  508. {
  509. return y;
  510. }
  511. #endif /* CONFIG_FB_LOGO_EXTRA */
  512. int fb_prepare_logo(struct fb_info *info, int rotate)
  513. {
  514. int depth = fb_get_color_depth(&info->var, &info->fix);
  515. unsigned int yres;
  516. memset(&fb_logo, 0, sizeof(struct logo_data));
  517. if (info->flags & FBINFO_MISC_TILEBLITTING ||
  518. info->flags & FBINFO_MODULE)
  519. return 0;
  520. if (info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
  521. depth = info->var.blue.length;
  522. if (info->var.red.length < depth)
  523. depth = info->var.red.length;
  524. if (info->var.green.length < depth)
  525. depth = info->var.green.length;
  526. }
  527. if (info->fix.visual == FB_VISUAL_STATIC_PSEUDOCOLOR && depth > 4) {
  528. /* assume console colormap */
  529. depth = 4;
  530. }
  531. /* Return if no suitable logo was found */
  532. fb_logo.logo = fb_find_logo(depth);
  533. if (!fb_logo.logo) {
  534. return 0;
  535. }
  536. if (rotate == FB_ROTATE_UR || rotate == FB_ROTATE_UD)
  537. yres = info->var.yres;
  538. else
  539. yres = info->var.xres;
  540. if (fb_logo.logo->height > yres) {
  541. fb_logo.logo = NULL;
  542. return 0;
  543. }
  544. /* What depth we asked for might be different from what we get */
  545. if (fb_logo.logo->type == LINUX_LOGO_CLUT224)
  546. fb_logo.depth = 8;
  547. else if (fb_logo.logo->type == LINUX_LOGO_VGA16)
  548. fb_logo.depth = 4;
  549. else
  550. fb_logo.depth = 1;
  551. if (fb_logo.depth > 4 && depth > 4) {
  552. switch (info->fix.visual) {
  553. case FB_VISUAL_TRUECOLOR:
  554. fb_logo.needs_truepalette = 1;
  555. break;
  556. case FB_VISUAL_DIRECTCOLOR:
  557. fb_logo.needs_directpalette = 1;
  558. fb_logo.needs_cmapreset = 1;
  559. break;
  560. case FB_VISUAL_PSEUDOCOLOR:
  561. fb_logo.needs_cmapreset = 1;
  562. break;
  563. }
  564. }
  565. return fb_prepare_extra_logos(info, fb_logo.logo->height, yres);
  566. }
  567. int fb_show_logo(struct fb_info *info, int rotate)
  568. {
  569. int y;
  570. y = fb_show_logo_line(info, rotate, fb_logo.logo, 0,
  571. num_online_cpus());
  572. y = fb_show_extra_logos(info, y, rotate);
  573. return y;
  574. }
  575. #else
  576. int fb_prepare_logo(struct fb_info *info, int rotate) { return 0; }
  577. int fb_show_logo(struct fb_info *info, int rotate) { return 0; }
  578. #endif /* CONFIG_LOGO */
  579. EXPORT_SYMBOL(fb_show_logo);
  580. static void *fb_seq_start(struct seq_file *m, loff_t *pos)
  581. {
  582. mutex_lock(&registration_lock);
  583. return (*pos < FB_MAX) ? pos : NULL;
  584. }
  585. static void *fb_seq_next(struct seq_file *m, void *v, loff_t *pos)
  586. {
  587. (*pos)++;
  588. return (*pos < FB_MAX) ? pos : NULL;
  589. }
  590. static void fb_seq_stop(struct seq_file *m, void *v)
  591. {
  592. mutex_unlock(&registration_lock);
  593. }
  594. static int fb_seq_show(struct seq_file *m, void *v)
  595. {
  596. int i = *(loff_t *)v;
  597. struct fb_info *fi = registered_fb[i];
  598. if (fi)
  599. seq_printf(m, "%d %s\n", fi->node, fi->fix.id);
  600. return 0;
  601. }
  602. static const struct seq_operations proc_fb_seq_ops = {
  603. .start = fb_seq_start,
  604. .next = fb_seq_next,
  605. .stop = fb_seq_stop,
  606. .show = fb_seq_show,
  607. };
  608. static int proc_fb_open(struct inode *inode, struct file *file)
  609. {
  610. return seq_open(file, &proc_fb_seq_ops);
  611. }
  612. static const struct file_operations fb_proc_fops = {
  613. .owner = THIS_MODULE,
  614. .open = proc_fb_open,
  615. .read = seq_read,
  616. .llseek = seq_lseek,
  617. .release = seq_release,
  618. };
  619. /*
  620. * We hold a reference to the fb_info in file->private_data,
  621. * but if the current registered fb has changed, we don't
  622. * actually want to use it.
  623. *
  624. * So look up the fb_info using the inode minor number,
  625. * and just verify it against the reference we have.
  626. */
  627. static struct fb_info *file_fb_info(struct file *file)
  628. {
  629. struct inode *inode = file_inode(file);
  630. int fbidx = iminor(inode);
  631. struct fb_info *info = registered_fb[fbidx];
  632. if (info != file->private_data)
  633. info = NULL;
  634. return info;
  635. }
  636. static ssize_t
  637. fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
  638. {
  639. unsigned long p = *ppos;
  640. struct fb_info *info = file_fb_info(file);
  641. u8 *buffer, *dst;
  642. u8 __iomem *src;
  643. int c, cnt = 0, err = 0;
  644. unsigned long total_size;
  645. if (!info || ! info->screen_base)
  646. return -ENODEV;
  647. if (info->state != FBINFO_STATE_RUNNING)
  648. return -EPERM;
  649. if (info->fbops->fb_read)
  650. return info->fbops->fb_read(info, buf, count, ppos);
  651. total_size = info->screen_size;
  652. if (total_size == 0)
  653. total_size = info->fix.smem_len;
  654. if (p >= total_size)
  655. return 0;
  656. if (count >= total_size)
  657. count = total_size;
  658. if (count + p > total_size)
  659. count = total_size - p;
  660. buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count,
  661. GFP_KERNEL);
  662. if (!buffer)
  663. return -ENOMEM;
  664. src = (u8 __iomem *) (info->screen_base + p);
  665. if (info->fbops->fb_sync)
  666. info->fbops->fb_sync(info);
  667. while (count) {
  668. c = (count > PAGE_SIZE) ? PAGE_SIZE : count;
  669. dst = buffer;
  670. fb_memcpy_fromfb(dst, src, c);
  671. dst += c;
  672. src += c;
  673. if (copy_to_user(buf, buffer, c)) {
  674. err = -EFAULT;
  675. break;
  676. }
  677. *ppos += c;
  678. buf += c;
  679. cnt += c;
  680. count -= c;
  681. }
  682. kfree(buffer);
  683. return (err) ? err : cnt;
  684. }
  685. static ssize_t
  686. fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
  687. {
  688. unsigned long p = *ppos;
  689. struct fb_info *info = file_fb_info(file);
  690. u8 *buffer, *src;
  691. u8 __iomem *dst;
  692. int c, cnt = 0, err = 0;
  693. unsigned long total_size;
  694. if (!info || !info->screen_base)
  695. return -ENODEV;
  696. if (info->state != FBINFO_STATE_RUNNING)
  697. return -EPERM;
  698. if (info->fbops->fb_write)
  699. return info->fbops->fb_write(info, buf, count, ppos);
  700. total_size = info->screen_size;
  701. if (total_size == 0)
  702. total_size = info->fix.smem_len;
  703. if (p > total_size)
  704. return -EFBIG;
  705. if (count > total_size) {
  706. err = -EFBIG;
  707. count = total_size;
  708. }
  709. if (count + p > total_size) {
  710. if (!err)
  711. err = -ENOSPC;
  712. count = total_size - p;
  713. }
  714. buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count,
  715. GFP_KERNEL);
  716. if (!buffer)
  717. return -ENOMEM;
  718. dst = (u8 __iomem *) (info->screen_base + p);
  719. if (info->fbops->fb_sync)
  720. info->fbops->fb_sync(info);
  721. while (count) {
  722. c = (count > PAGE_SIZE) ? PAGE_SIZE : count;
  723. src = buffer;
  724. if (copy_from_user(src, buf, c)) {
  725. err = -EFAULT;
  726. break;
  727. }
  728. fb_memcpy_tofb(dst, src, c);
  729. dst += c;
  730. src += c;
  731. *ppos += c;
  732. buf += c;
  733. cnt += c;
  734. count -= c;
  735. }
  736. kfree(buffer);
  737. return (cnt) ? cnt : err;
  738. }
  739. int
  740. fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var)
  741. {
  742. struct fb_fix_screeninfo *fix = &info->fix;
  743. unsigned int yres = info->var.yres;
  744. int err = 0;
  745. if (var->yoffset > 0) {
  746. if (var->vmode & FB_VMODE_YWRAP) {
  747. if (!fix->ywrapstep || (var->yoffset % fix->ywrapstep))
  748. err = -EINVAL;
  749. else
  750. yres = 0;
  751. } else if (!fix->ypanstep || (var->yoffset % fix->ypanstep))
  752. err = -EINVAL;
  753. }
  754. if (var->xoffset > 0 && (!fix->xpanstep ||
  755. (var->xoffset % fix->xpanstep)))
  756. err = -EINVAL;
  757. if (err || !info->fbops->fb_pan_display ||
  758. var->yoffset > info->var.yres_virtual - yres ||
  759. var->xoffset > info->var.xres_virtual - info->var.xres)
  760. return -EINVAL;
  761. if ((err = info->fbops->fb_pan_display(var, info)))
  762. return err;
  763. info->var.xoffset = var->xoffset;
  764. info->var.yoffset = var->yoffset;
  765. if (var->vmode & FB_VMODE_YWRAP)
  766. info->var.vmode |= FB_VMODE_YWRAP;
  767. else
  768. info->var.vmode &= ~FB_VMODE_YWRAP;
  769. return 0;
  770. }
  771. EXPORT_SYMBOL(fb_pan_display);
  772. static int fb_check_caps(struct fb_info *info, struct fb_var_screeninfo *var,
  773. u32 activate)
  774. {
  775. struct fb_event event;
  776. struct fb_blit_caps caps, fbcaps;
  777. int err = 0;
  778. memset(&caps, 0, sizeof(caps));
  779. memset(&fbcaps, 0, sizeof(fbcaps));
  780. caps.flags = (activate & FB_ACTIVATE_ALL) ? 1 : 0;
  781. event.info = info;
  782. event.data = &caps;
  783. fb_notifier_call_chain(FB_EVENT_GET_REQ, &event);
  784. info->fbops->fb_get_caps(info, &fbcaps, var);
  785. if (((fbcaps.x ^ caps.x) & caps.x) ||
  786. ((fbcaps.y ^ caps.y) & caps.y) ||
  787. (fbcaps.len < caps.len))
  788. err = -EINVAL;
  789. return err;
  790. }
  791. int
  792. fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
  793. {
  794. int flags = info->flags;
  795. int ret = 0;
  796. if (var->activate & FB_ACTIVATE_INV_MODE) {
  797. struct fb_videomode mode1, mode2;
  798. fb_var_to_videomode(&mode1, var);
  799. fb_var_to_videomode(&mode2, &info->var);
  800. /* make sure we don't delete the videomode of current var */
  801. ret = fb_mode_is_equal(&mode1, &mode2);
  802. if (!ret) {
  803. struct fb_event event;
  804. event.info = info;
  805. event.data = &mode1;
  806. ret = fb_notifier_call_chain(FB_EVENT_MODE_DELETE, &event);
  807. }
  808. if (!ret)
  809. fb_delete_videomode(&mode1, &info->modelist);
  810. ret = (ret) ? -EINVAL : 0;
  811. goto done;
  812. }
  813. if ((var->activate & FB_ACTIVATE_FORCE) ||
  814. memcmp(&info->var, var, sizeof(struct fb_var_screeninfo))) {
  815. u32 activate = var->activate;
  816. /* When using FOURCC mode, make sure the red, green, blue and
  817. * transp fields are set to 0.
  818. */
  819. if ((info->fix.capabilities & FB_CAP_FOURCC) &&
  820. var->grayscale > 1) {
  821. if (var->red.offset || var->green.offset ||
  822. var->blue.offset || var->transp.offset ||
  823. var->red.length || var->green.length ||
  824. var->blue.length || var->transp.length ||
  825. var->red.msb_right || var->green.msb_right ||
  826. var->blue.msb_right || var->transp.msb_right)
  827. return -EINVAL;
  828. }
  829. if (!info->fbops->fb_check_var) {
  830. *var = info->var;
  831. goto done;
  832. }
  833. ret = info->fbops->fb_check_var(var, info);
  834. if (ret)
  835. goto done;
  836. if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) {
  837. struct fb_var_screeninfo old_var;
  838. struct fb_videomode mode;
  839. if (info->fbops->fb_get_caps) {
  840. ret = fb_check_caps(info, var, activate);
  841. if (ret)
  842. goto done;
  843. }
  844. old_var = info->var;
  845. info->var = *var;
  846. if (info->fbops->fb_set_par) {
  847. ret = info->fbops->fb_set_par(info);
  848. if (ret) {
  849. info->var = old_var;
  850. printk(KERN_WARNING "detected "
  851. "fb_set_par error, "
  852. "error code: %d\n", ret);
  853. goto done;
  854. }
  855. }
  856. fb_pan_display(info, &info->var);
  857. fb_set_cmap(&info->cmap, info);
  858. fb_var_to_videomode(&mode, &info->var);
  859. if (info->modelist.prev && info->modelist.next &&
  860. !list_empty(&info->modelist))
  861. ret = fb_add_videomode(&mode, &info->modelist);
  862. if (!ret && (flags & FBINFO_MISC_USEREVENT)) {
  863. struct fb_event event;
  864. int evnt = (activate & FB_ACTIVATE_ALL) ?
  865. FB_EVENT_MODE_CHANGE_ALL :
  866. FB_EVENT_MODE_CHANGE;
  867. info->flags &= ~FBINFO_MISC_USEREVENT;
  868. event.info = info;
  869. event.data = &mode;
  870. fb_notifier_call_chain(evnt, &event);
  871. }
  872. }
  873. }
  874. done:
  875. return ret;
  876. }
  877. EXPORT_SYMBOL(fb_set_var);
  878. int
  879. fb_blank(struct fb_info *info, int blank)
  880. {
  881. struct fb_event event;
  882. int ret = -EINVAL, early_ret;
  883. if (blank > FB_BLANK_POWERDOWN)
  884. blank = FB_BLANK_POWERDOWN;
  885. event.info = info;
  886. event.data = &blank;
  887. early_ret = fb_notifier_call_chain(FB_EARLY_EVENT_BLANK, &event);
  888. if (info->fbops->fb_blank)
  889. ret = info->fbops->fb_blank(blank, info);
  890. if (!ret)
  891. fb_notifier_call_chain(FB_EVENT_BLANK, &event);
  892. else {
  893. /*
  894. * if fb_blank is failed then revert effects of
  895. * the early blank event.
  896. */
  897. if (!early_ret)
  898. fb_notifier_call_chain(FB_R_EARLY_EVENT_BLANK, &event);
  899. }
  900. return ret;
  901. }
  902. EXPORT_SYMBOL(fb_blank);
  903. static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
  904. unsigned long arg)
  905. {
  906. struct fb_ops *fb;
  907. struct fb_var_screeninfo var;
  908. struct fb_fix_screeninfo fix;
  909. struct fb_con2fbmap con2fb;
  910. struct fb_cmap cmap_from;
  911. struct fb_cmap_user cmap;
  912. struct fb_event event;
  913. void __user *argp = (void __user *)arg;
  914. long ret = 0;
  915. switch (cmd) {
  916. case FBIOGET_VSCREENINFO:
  917. if (!lock_fb_info(info))
  918. return -ENODEV;
  919. var = info->var;
  920. unlock_fb_info(info);
  921. ret = copy_to_user(argp, &var, sizeof(var)) ? -EFAULT : 0;
  922. break;
  923. case FBIOPUT_VSCREENINFO:
  924. if (copy_from_user(&var, argp, sizeof(var)))
  925. return -EFAULT;
  926. console_lock();
  927. if (!lock_fb_info(info)) {
  928. console_unlock();
  929. return -ENODEV;
  930. }
  931. info->flags |= FBINFO_MISC_USEREVENT;
  932. ret = fb_set_var(info, &var);
  933. info->flags &= ~FBINFO_MISC_USEREVENT;
  934. unlock_fb_info(info);
  935. console_unlock();
  936. if (!ret && copy_to_user(argp, &var, sizeof(var)))
  937. ret = -EFAULT;
  938. break;
  939. case FBIOGET_FSCREENINFO:
  940. if (!lock_fb_info(info))
  941. return -ENODEV;
  942. fix = info->fix;
  943. unlock_fb_info(info);
  944. ret = copy_to_user(argp, &fix, sizeof(fix)) ? -EFAULT : 0;
  945. break;
  946. case FBIOPUTCMAP:
  947. if (copy_from_user(&cmap, argp, sizeof(cmap)))
  948. return -EFAULT;
  949. ret = fb_set_user_cmap(&cmap, info);
  950. break;
  951. case FBIOGETCMAP:
  952. if (copy_from_user(&cmap, argp, sizeof(cmap)))
  953. return -EFAULT;
  954. if (!lock_fb_info(info))
  955. return -ENODEV;
  956. cmap_from = info->cmap;
  957. unlock_fb_info(info);
  958. ret = fb_cmap_to_user(&cmap_from, &cmap);
  959. break;
  960. case FBIOPAN_DISPLAY:
  961. if (copy_from_user(&var, argp, sizeof(var)))
  962. return -EFAULT;
  963. console_lock();
  964. if (!lock_fb_info(info)) {
  965. console_unlock();
  966. return -ENODEV;
  967. }
  968. ret = fb_pan_display(info, &var);
  969. unlock_fb_info(info);
  970. console_unlock();
  971. if (ret == 0 && copy_to_user(argp, &var, sizeof(var)))
  972. return -EFAULT;
  973. break;
  974. case FBIO_CURSOR:
  975. ret = -EINVAL;
  976. break;
  977. case FBIOGET_CON2FBMAP:
  978. if (copy_from_user(&con2fb, argp, sizeof(con2fb)))
  979. return -EFAULT;
  980. if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
  981. return -EINVAL;
  982. con2fb.framebuffer = -1;
  983. event.data = &con2fb;
  984. if (!lock_fb_info(info))
  985. return -ENODEV;
  986. event.info = info;
  987. fb_notifier_call_chain(FB_EVENT_GET_CONSOLE_MAP, &event);
  988. unlock_fb_info(info);
  989. ret = copy_to_user(argp, &con2fb, sizeof(con2fb)) ? -EFAULT : 0;
  990. break;
  991. case FBIOPUT_CON2FBMAP:
  992. if (copy_from_user(&con2fb, argp, sizeof(con2fb)))
  993. return -EFAULT;
  994. if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
  995. return -EINVAL;
  996. if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
  997. return -EINVAL;
  998. if (!registered_fb[con2fb.framebuffer])
  999. request_module("fb%d", con2fb.framebuffer);
  1000. if (!registered_fb[con2fb.framebuffer]) {
  1001. ret = -EINVAL;
  1002. break;
  1003. }
  1004. event.data = &con2fb;
  1005. console_lock();
  1006. if (!lock_fb_info(info)) {
  1007. console_unlock();
  1008. return -ENODEV;
  1009. }
  1010. event.info = info;
  1011. ret = fb_notifier_call_chain(FB_EVENT_SET_CONSOLE_MAP, &event);
  1012. unlock_fb_info(info);
  1013. console_unlock();
  1014. break;
  1015. case FBIOBLANK:
  1016. console_lock();
  1017. if (!lock_fb_info(info)) {
  1018. console_unlock();
  1019. return -ENODEV;
  1020. }
  1021. info->flags |= FBINFO_MISC_USEREVENT;
  1022. ret = fb_blank(info, arg);
  1023. info->flags &= ~FBINFO_MISC_USEREVENT;
  1024. unlock_fb_info(info);
  1025. console_unlock();
  1026. break;
  1027. default:
  1028. if (!lock_fb_info(info))
  1029. return -ENODEV;
  1030. fb = info->fbops;
  1031. if (fb->fb_ioctl)
  1032. ret = fb->fb_ioctl(info, cmd, arg);
  1033. else
  1034. ret = -ENOTTY;
  1035. unlock_fb_info(info);
  1036. }
  1037. return ret;
  1038. }
  1039. static long fb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  1040. {
  1041. struct fb_info *info = file_fb_info(file);
  1042. if (!info)
  1043. return -ENODEV;
  1044. return do_fb_ioctl(info, cmd, arg);
  1045. }
  1046. #ifdef CONFIG_COMPAT
  1047. struct fb_fix_screeninfo32 {
  1048. char id[16];
  1049. compat_caddr_t smem_start;
  1050. u32 smem_len;
  1051. u32 type;
  1052. u32 type_aux;
  1053. u32 visual;
  1054. u16 xpanstep;
  1055. u16 ypanstep;
  1056. u16 ywrapstep;
  1057. u32 line_length;
  1058. compat_caddr_t mmio_start;
  1059. u32 mmio_len;
  1060. u32 accel;
  1061. u16 reserved[3];
  1062. };
  1063. struct fb_cmap32 {
  1064. u32 start;
  1065. u32 len;
  1066. compat_caddr_t red;
  1067. compat_caddr_t green;
  1068. compat_caddr_t blue;
  1069. compat_caddr_t transp;
  1070. };
  1071. static int fb_getput_cmap(struct fb_info *info, unsigned int cmd,
  1072. unsigned long arg)
  1073. {
  1074. struct fb_cmap_user __user *cmap;
  1075. struct fb_cmap32 __user *cmap32;
  1076. __u32 data;
  1077. int err;
  1078. cmap = compat_alloc_user_space(sizeof(*cmap));
  1079. cmap32 = compat_ptr(arg);
  1080. if (copy_in_user(&cmap->start, &cmap32->start, 2 * sizeof(__u32)))
  1081. return -EFAULT;
  1082. if (get_user(data, &cmap32->red) ||
  1083. put_user(compat_ptr(data), &cmap->red) ||
  1084. get_user(data, &cmap32->green) ||
  1085. put_user(compat_ptr(data), &cmap->green) ||
  1086. get_user(data, &cmap32->blue) ||
  1087. put_user(compat_ptr(data), &cmap->blue) ||
  1088. get_user(data, &cmap32->transp) ||
  1089. put_user(compat_ptr(data), &cmap->transp))
  1090. return -EFAULT;
  1091. err = do_fb_ioctl(info, cmd, (unsigned long) cmap);
  1092. if (!err) {
  1093. if (copy_in_user(&cmap32->start,
  1094. &cmap->start,
  1095. 2 * sizeof(__u32)))
  1096. err = -EFAULT;
  1097. }
  1098. return err;
  1099. }
  1100. static int do_fscreeninfo_to_user(struct fb_fix_screeninfo *fix,
  1101. struct fb_fix_screeninfo32 __user *fix32)
  1102. {
  1103. __u32 data;
  1104. int err;
  1105. err = copy_to_user(&fix32->id, &fix->id, sizeof(fix32->id));
  1106. data = (__u32) (unsigned long) fix->smem_start;
  1107. err |= put_user(data, &fix32->smem_start);
  1108. err |= put_user(fix->smem_len, &fix32->smem_len);
  1109. err |= put_user(fix->type, &fix32->type);
  1110. err |= put_user(fix->type_aux, &fix32->type_aux);
  1111. err |= put_user(fix->visual, &fix32->visual);
  1112. err |= put_user(fix->xpanstep, &fix32->xpanstep);
  1113. err |= put_user(fix->ypanstep, &fix32->ypanstep);
  1114. err |= put_user(fix->ywrapstep, &fix32->ywrapstep);
  1115. err |= put_user(fix->line_length, &fix32->line_length);
  1116. data = (__u32) (unsigned long) fix->mmio_start;
  1117. err |= put_user(data, &fix32->mmio_start);
  1118. err |= put_user(fix->mmio_len, &fix32->mmio_len);
  1119. err |= put_user(fix->accel, &fix32->accel);
  1120. err |= copy_to_user(fix32->reserved, fix->reserved,
  1121. sizeof(fix->reserved));
  1122. if (err)
  1123. return -EFAULT;
  1124. return 0;
  1125. }
  1126. static int fb_get_fscreeninfo(struct fb_info *info, unsigned int cmd,
  1127. unsigned long arg)
  1128. {
  1129. mm_segment_t old_fs;
  1130. struct fb_fix_screeninfo fix;
  1131. struct fb_fix_screeninfo32 __user *fix32;
  1132. int err;
  1133. fix32 = compat_ptr(arg);
  1134. old_fs = get_fs();
  1135. set_fs(KERNEL_DS);
  1136. err = do_fb_ioctl(info, cmd, (unsigned long) &fix);
  1137. set_fs(old_fs);
  1138. if (!err)
  1139. err = do_fscreeninfo_to_user(&fix, fix32);
  1140. return err;
  1141. }
  1142. static long fb_compat_ioctl(struct file *file, unsigned int cmd,
  1143. unsigned long arg)
  1144. {
  1145. struct fb_info *info = file_fb_info(file);
  1146. struct fb_ops *fb;
  1147. long ret = -ENOIOCTLCMD;
  1148. if (!info)
  1149. return -ENODEV;
  1150. fb = info->fbops;
  1151. switch(cmd) {
  1152. case FBIOGET_VSCREENINFO:
  1153. case FBIOPUT_VSCREENINFO:
  1154. case FBIOPAN_DISPLAY:
  1155. case FBIOGET_CON2FBMAP:
  1156. case FBIOPUT_CON2FBMAP:
  1157. arg = (unsigned long) compat_ptr(arg);
  1158. case FBIOBLANK:
  1159. ret = do_fb_ioctl(info, cmd, arg);
  1160. break;
  1161. case FBIOGET_FSCREENINFO:
  1162. ret = fb_get_fscreeninfo(info, cmd, arg);
  1163. break;
  1164. case FBIOGETCMAP:
  1165. case FBIOPUTCMAP:
  1166. ret = fb_getput_cmap(info, cmd, arg);
  1167. break;
  1168. default:
  1169. if (fb->fb_compat_ioctl)
  1170. ret = fb->fb_compat_ioctl(info, cmd, arg);
  1171. break;
  1172. }
  1173. return ret;
  1174. }
  1175. #endif
  1176. static int
  1177. fb_mmap(struct file *file, struct vm_area_struct * vma)
  1178. {
  1179. struct fb_info *info = file_fb_info(file);
  1180. struct fb_ops *fb;
  1181. unsigned long mmio_pgoff;
  1182. unsigned long start;
  1183. u32 len;
  1184. if (!info)
  1185. return -ENODEV;
  1186. fb = info->fbops;
  1187. if (!fb)
  1188. return -ENODEV;
  1189. mutex_lock(&info->mm_lock);
  1190. if (fb->fb_mmap) {
  1191. int res;
  1192. res = fb->fb_mmap(info, vma);
  1193. mutex_unlock(&info->mm_lock);
  1194. return res;
  1195. }
  1196. /*
  1197. * Ugh. This can be either the frame buffer mapping, or
  1198. * if pgoff points past it, the mmio mapping.
  1199. */
  1200. start = info->fix.smem_start;
  1201. len = info->fix.smem_len;
  1202. mmio_pgoff = PAGE_ALIGN((start & ~PAGE_MASK) + len) >> PAGE_SHIFT;
  1203. if (vma->vm_pgoff >= mmio_pgoff) {
  1204. if (info->var.accel_flags) {
  1205. mutex_unlock(&info->mm_lock);
  1206. return -EINVAL;
  1207. }
  1208. vma->vm_pgoff -= mmio_pgoff;
  1209. start = info->fix.mmio_start;
  1210. len = info->fix.mmio_len;
  1211. }
  1212. mutex_unlock(&info->mm_lock);
  1213. vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
  1214. fb_pgprotect(file, vma, start);
  1215. return vm_iomap_memory(vma, start, len);
  1216. }
  1217. static int
  1218. fb_open(struct inode *inode, struct file *file)
  1219. __acquires(&info->lock)
  1220. __releases(&info->lock)
  1221. {
  1222. int fbidx = iminor(inode);
  1223. struct fb_info *info;
  1224. int res = 0;
  1225. info = get_fb_info(fbidx);
  1226. if (!info) {
  1227. request_module("fb%d", fbidx);
  1228. info = get_fb_info(fbidx);
  1229. if (!info)
  1230. return -ENODEV;
  1231. }
  1232. if (IS_ERR(info))
  1233. return PTR_ERR(info);
  1234. mutex_lock(&info->lock);
  1235. if (!try_module_get(info->fbops->owner)) {
  1236. res = -ENODEV;
  1237. goto out;
  1238. }
  1239. file->private_data = info;
  1240. if (info->fbops->fb_open) {
  1241. res = info->fbops->fb_open(info,1);
  1242. if (res)
  1243. module_put(info->fbops->owner);
  1244. }
  1245. #ifdef CONFIG_FB_DEFERRED_IO
  1246. if (info->fbdefio)
  1247. fb_deferred_io_open(info, inode, file);
  1248. #endif
  1249. out:
  1250. mutex_unlock(&info->lock);
  1251. if (res)
  1252. put_fb_info(info);
  1253. return res;
  1254. }
  1255. static int
  1256. fb_release(struct inode *inode, struct file *file)
  1257. __acquires(&info->lock)
  1258. __releases(&info->lock)
  1259. {
  1260. struct fb_info * const info = file->private_data;
  1261. mutex_lock(&info->lock);
  1262. if (info->fbops->fb_release)
  1263. info->fbops->fb_release(info,1);
  1264. module_put(info->fbops->owner);
  1265. mutex_unlock(&info->lock);
  1266. put_fb_info(info);
  1267. return 0;
  1268. }
  1269. static const struct file_operations fb_fops = {
  1270. .owner = THIS_MODULE,
  1271. .read = fb_read,
  1272. .write = fb_write,
  1273. .unlocked_ioctl = fb_ioctl,
  1274. #ifdef CONFIG_COMPAT
  1275. .compat_ioctl = fb_compat_ioctl,
  1276. #endif
  1277. .mmap = fb_mmap,
  1278. .open = fb_open,
  1279. .release = fb_release,
  1280. #ifdef HAVE_ARCH_FB_UNMAPPED_AREA
  1281. .get_unmapped_area = get_fb_unmapped_area,
  1282. #endif
  1283. #ifdef CONFIG_FB_DEFERRED_IO
  1284. .fsync = fb_deferred_io_fsync,
  1285. #endif
  1286. .llseek = default_llseek,
  1287. };
  1288. struct class *fb_class;
  1289. EXPORT_SYMBOL(fb_class);
  1290. static int fb_check_foreignness(struct fb_info *fi)
  1291. {
  1292. const bool foreign_endian = fi->flags & FBINFO_FOREIGN_ENDIAN;
  1293. fi->flags &= ~FBINFO_FOREIGN_ENDIAN;
  1294. #ifdef __BIG_ENDIAN
  1295. fi->flags |= foreign_endian ? 0 : FBINFO_BE_MATH;
  1296. #else
  1297. fi->flags |= foreign_endian ? FBINFO_BE_MATH : 0;
  1298. #endif /* __BIG_ENDIAN */
  1299. if (fi->flags & FBINFO_BE_MATH && !fb_be_math(fi)) {
  1300. pr_err("%s: enable CONFIG_FB_BIG_ENDIAN to "
  1301. "support this framebuffer\n", fi->fix.id);
  1302. return -ENOSYS;
  1303. } else if (!(fi->flags & FBINFO_BE_MATH) && fb_be_math(fi)) {
  1304. pr_err("%s: enable CONFIG_FB_LITTLE_ENDIAN to "
  1305. "support this framebuffer\n", fi->fix.id);
  1306. return -ENOSYS;
  1307. }
  1308. return 0;
  1309. }
  1310. static bool apertures_overlap(struct aperture *gen, struct aperture *hw)
  1311. {
  1312. /* is the generic aperture base the same as the HW one */
  1313. if (gen->base == hw->base)
  1314. return true;
  1315. /* is the generic aperture base inside the hw base->hw base+size */
  1316. if (gen->base > hw->base && gen->base < hw->base + hw->size)
  1317. return true;
  1318. return false;
  1319. }
  1320. static bool fb_do_apertures_overlap(struct apertures_struct *gena,
  1321. struct apertures_struct *hwa)
  1322. {
  1323. int i, j;
  1324. if (!hwa || !gena)
  1325. return false;
  1326. for (i = 0; i < hwa->count; ++i) {
  1327. struct aperture *h = &hwa->ranges[i];
  1328. for (j = 0; j < gena->count; ++j) {
  1329. struct aperture *g = &gena->ranges[j];
  1330. printk(KERN_DEBUG "checking generic (%llx %llx) vs hw (%llx %llx)\n",
  1331. (unsigned long long)g->base,
  1332. (unsigned long long)g->size,
  1333. (unsigned long long)h->base,
  1334. (unsigned long long)h->size);
  1335. if (apertures_overlap(g, h))
  1336. return true;
  1337. }
  1338. }
  1339. return false;
  1340. }
  1341. static int do_unregister_framebuffer(struct fb_info *fb_info);
  1342. #define VGA_FB_PHYS 0xA0000
  1343. static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
  1344. const char *name, bool primary)
  1345. {
  1346. int i;
  1347. /* check all firmware fbs and kick off if the base addr overlaps */
  1348. for (i = 0 ; i < FB_MAX; i++) {
  1349. struct apertures_struct *gen_aper;
  1350. if (!registered_fb[i])
  1351. continue;
  1352. if (!(registered_fb[i]->flags & FBINFO_MISC_FIRMWARE))
  1353. continue;
  1354. gen_aper = registered_fb[i]->apertures;
  1355. if (fb_do_apertures_overlap(gen_aper, a) ||
  1356. (primary && gen_aper && gen_aper->count &&
  1357. gen_aper->ranges[0].base == VGA_FB_PHYS)) {
  1358. printk(KERN_INFO "fb: conflicting fb hw usage "
  1359. "%s vs %s - removing generic driver\n",
  1360. name, registered_fb[i]->fix.id);
  1361. do_unregister_framebuffer(registered_fb[i]);
  1362. }
  1363. }
  1364. }
  1365. static int do_register_framebuffer(struct fb_info *fb_info)
  1366. {
  1367. int i;
  1368. struct fb_event event;
  1369. struct fb_videomode mode;
  1370. if (fb_check_foreignness(fb_info))
  1371. return -ENOSYS;
  1372. do_remove_conflicting_framebuffers(fb_info->apertures, fb_info->fix.id,
  1373. fb_is_primary_device(fb_info));
  1374. if (num_registered_fb == FB_MAX)
  1375. return -ENXIO;
  1376. num_registered_fb++;
  1377. for (i = 0 ; i < FB_MAX; i++)
  1378. if (!registered_fb[i])
  1379. break;
  1380. fb_info->node = i;
  1381. atomic_set(&fb_info->count, 1);
  1382. mutex_init(&fb_info->lock);
  1383. mutex_init(&fb_info->mm_lock);
  1384. fb_info->dev = device_create(fb_class, fb_info->device,
  1385. MKDEV(FB_MAJOR, i), NULL, "fb%d", i);
  1386. if (IS_ERR(fb_info->dev)) {
  1387. /* Not fatal */
  1388. printk(KERN_WARNING "Unable to create device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->dev));
  1389. fb_info->dev = NULL;
  1390. } else
  1391. fb_init_device(fb_info);
  1392. if (fb_info->pixmap.addr == NULL) {
  1393. fb_info->pixmap.addr = kmalloc(FBPIXMAPSIZE, GFP_KERNEL);
  1394. if (fb_info->pixmap.addr) {
  1395. fb_info->pixmap.size = FBPIXMAPSIZE;
  1396. fb_info->pixmap.buf_align = 1;
  1397. fb_info->pixmap.scan_align = 1;
  1398. fb_info->pixmap.access_align = 32;
  1399. fb_info->pixmap.flags = FB_PIXMAP_DEFAULT;
  1400. }
  1401. }
  1402. fb_info->pixmap.offset = 0;
  1403. if (!fb_info->pixmap.blit_x)
  1404. fb_info->pixmap.blit_x = ~(u32)0;
  1405. if (!fb_info->pixmap.blit_y)
  1406. fb_info->pixmap.blit_y = ~(u32)0;
  1407. if (!fb_info->modelist.prev || !fb_info->modelist.next)
  1408. INIT_LIST_HEAD(&fb_info->modelist);
  1409. if (fb_info->skip_vt_switch)
  1410. pm_vt_switch_required(fb_info->dev, false);
  1411. else
  1412. pm_vt_switch_required(fb_info->dev, true);
  1413. fb_var_to_videomode(&mode, &fb_info->var);
  1414. fb_add_videomode(&mode, &fb_info->modelist);
  1415. registered_fb[i] = fb_info;
  1416. event.info = fb_info;
  1417. console_lock();
  1418. if (!lock_fb_info(fb_info)) {
  1419. console_unlock();
  1420. return -ENODEV;
  1421. }
  1422. fb_notifier_call_chain(FB_EVENT_FB_REGISTERED, &event);
  1423. unlock_fb_info(fb_info);
  1424. console_unlock();
  1425. return 0;
  1426. }
  1427. static int do_unregister_framebuffer(struct fb_info *fb_info)
  1428. {
  1429. struct fb_event event;
  1430. int i, ret = 0;
  1431. i = fb_info->node;
  1432. if (i < 0 || i >= FB_MAX || registered_fb[i] != fb_info)
  1433. return -EINVAL;
  1434. console_lock();
  1435. if (!lock_fb_info(fb_info)) {
  1436. console_unlock();
  1437. return -ENODEV;
  1438. }
  1439. event.info = fb_info;
  1440. ret = fb_notifier_call_chain(FB_EVENT_FB_UNBIND, &event);
  1441. unlock_fb_info(fb_info);
  1442. console_unlock();
  1443. if (ret)
  1444. return -EINVAL;
  1445. pm_vt_switch_unregister(fb_info->dev);
  1446. unlink_framebuffer(fb_info);
  1447. if (fb_info->pixmap.addr &&
  1448. (fb_info->pixmap.flags & FB_PIXMAP_DEFAULT))
  1449. kfree(fb_info->pixmap.addr);
  1450. fb_destroy_modelist(&fb_info->modelist);
  1451. registered_fb[i] = NULL;
  1452. num_registered_fb--;
  1453. fb_cleanup_device(fb_info);
  1454. event.info = fb_info;
  1455. console_lock();
  1456. fb_notifier_call_chain(FB_EVENT_FB_UNREGISTERED, &event);
  1457. console_unlock();
  1458. /* this may free fb info */
  1459. put_fb_info(fb_info);
  1460. return 0;
  1461. }
  1462. int unlink_framebuffer(struct fb_info *fb_info)
  1463. {
  1464. int i;
  1465. i = fb_info->node;
  1466. if (i < 0 || i >= FB_MAX || registered_fb[i] != fb_info)
  1467. return -EINVAL;
  1468. if (fb_info->dev) {
  1469. device_destroy(fb_class, MKDEV(FB_MAJOR, i));
  1470. fb_info->dev = NULL;
  1471. }
  1472. return 0;
  1473. }
  1474. EXPORT_SYMBOL(unlink_framebuffer);
  1475. void remove_conflicting_framebuffers(struct apertures_struct *a,
  1476. const char *name, bool primary)
  1477. {
  1478. mutex_lock(&registration_lock);
  1479. do_remove_conflicting_framebuffers(a, name, primary);
  1480. mutex_unlock(&registration_lock);
  1481. }
  1482. EXPORT_SYMBOL(remove_conflicting_framebuffers);
  1483. /**
  1484. * register_framebuffer - registers a frame buffer device
  1485. * @fb_info: frame buffer info structure
  1486. *
  1487. * Registers a frame buffer device @fb_info.
  1488. *
  1489. * Returns negative errno on error, or zero for success.
  1490. *
  1491. */
  1492. int
  1493. register_framebuffer(struct fb_info *fb_info)
  1494. {
  1495. int ret;
  1496. mutex_lock(&registration_lock);
  1497. ret = do_register_framebuffer(fb_info);
  1498. mutex_unlock(&registration_lock);
  1499. return ret;
  1500. }
  1501. EXPORT_SYMBOL(register_framebuffer);
  1502. /**
  1503. * unregister_framebuffer - releases a frame buffer device
  1504. * @fb_info: frame buffer info structure
  1505. *
  1506. * Unregisters a frame buffer device @fb_info.
  1507. *
  1508. * Returns negative errno on error, or zero for success.
  1509. *
  1510. * This function will also notify the framebuffer console
  1511. * to release the driver.
  1512. *
  1513. * This is meant to be called within a driver's module_exit()
  1514. * function. If this is called outside module_exit(), ensure
  1515. * that the driver implements fb_open() and fb_release() to
  1516. * check that no processes are using the device.
  1517. */
  1518. int
  1519. unregister_framebuffer(struct fb_info *fb_info)
  1520. {
  1521. int ret;
  1522. mutex_lock(&registration_lock);
  1523. ret = do_unregister_framebuffer(fb_info);
  1524. mutex_unlock(&registration_lock);
  1525. return ret;
  1526. }
  1527. EXPORT_SYMBOL(unregister_framebuffer);
  1528. /**
  1529. * fb_set_suspend - low level driver signals suspend
  1530. * @info: framebuffer affected
  1531. * @state: 0 = resuming, !=0 = suspending
  1532. *
  1533. * This is meant to be used by low level drivers to
  1534. * signal suspend/resume to the core & clients.
  1535. * It must be called with the console semaphore held
  1536. */
  1537. void fb_set_suspend(struct fb_info *info, int state)
  1538. {
  1539. struct fb_event event;
  1540. event.info = info;
  1541. if (state) {
  1542. fb_notifier_call_chain(FB_EVENT_SUSPEND, &event);
  1543. info->state = FBINFO_STATE_SUSPENDED;
  1544. } else {
  1545. info->state = FBINFO_STATE_RUNNING;
  1546. fb_notifier_call_chain(FB_EVENT_RESUME, &event);
  1547. }
  1548. }
  1549. EXPORT_SYMBOL(fb_set_suspend);
  1550. /**
  1551. * fbmem_init - init frame buffer subsystem
  1552. *
  1553. * Initialize the frame buffer subsystem.
  1554. *
  1555. * NOTE: This function is _only_ to be called by drivers/char/mem.c.
  1556. *
  1557. */
  1558. static int __init
  1559. fbmem_init(void)
  1560. {
  1561. proc_create("fb", 0, NULL, &fb_proc_fops);
  1562. if (register_chrdev(FB_MAJOR,"fb",&fb_fops))
  1563. printk("unable to get major %d for fb devs\n", FB_MAJOR);
  1564. fb_class = class_create(THIS_MODULE, "graphics");
  1565. if (IS_ERR(fb_class)) {
  1566. printk(KERN_WARNING "Unable to create fb class; errno = %ld\n", PTR_ERR(fb_class));
  1567. fb_class = NULL;
  1568. }
  1569. return 0;
  1570. }
  1571. #ifdef MODULE
  1572. module_init(fbmem_init);
  1573. static void __exit
  1574. fbmem_exit(void)
  1575. {
  1576. remove_proc_entry("fb", NULL);
  1577. class_destroy(fb_class);
  1578. unregister_chrdev(FB_MAJOR, "fb");
  1579. }
  1580. module_exit(fbmem_exit);
  1581. MODULE_LICENSE("GPL");
  1582. MODULE_DESCRIPTION("Framebuffer base");
  1583. #else
  1584. subsys_initcall(fbmem_init);
  1585. #endif
  1586. int fb_new_modelist(struct fb_info *info)
  1587. {
  1588. struct fb_event event;
  1589. struct fb_var_screeninfo var = info->var;
  1590. struct list_head *pos, *n;
  1591. struct fb_modelist *modelist;
  1592. struct fb_videomode *m, mode;
  1593. int err = 1;
  1594. list_for_each_safe(pos, n, &info->modelist) {
  1595. modelist = list_entry(pos, struct fb_modelist, list);
  1596. m = &modelist->mode;
  1597. fb_videomode_to_var(&var, m);
  1598. var.activate = FB_ACTIVATE_TEST;
  1599. err = fb_set_var(info, &var);
  1600. fb_var_to_videomode(&mode, &var);
  1601. if (err || !fb_mode_is_equal(m, &mode)) {
  1602. list_del(pos);
  1603. kfree(pos);
  1604. }
  1605. }
  1606. err = 1;
  1607. if (!list_empty(&info->modelist)) {
  1608. event.info = info;
  1609. err = fb_notifier_call_chain(FB_EVENT_NEW_MODELIST, &event);
  1610. }
  1611. return err;
  1612. }
  1613. static char *video_options[FB_MAX] __read_mostly;
  1614. static int ofonly __read_mostly;
  1615. /**
  1616. * fb_get_options - get kernel boot parameters
  1617. * @name: framebuffer name as it would appear in
  1618. * the boot parameter line
  1619. * (video=<name>:<options>)
  1620. * @option: the option will be stored here
  1621. *
  1622. * NOTE: Needed to maintain backwards compatibility
  1623. */
  1624. int fb_get_options(const char *name, char **option)
  1625. {
  1626. char *opt, *options = NULL;
  1627. int retval = 0;
  1628. int name_len = strlen(name), i;
  1629. if (name_len && ofonly && strncmp(name, "offb", 4))
  1630. retval = 1;
  1631. if (name_len && !retval) {
  1632. for (i = 0; i < FB_MAX; i++) {
  1633. if (video_options[i] == NULL)
  1634. continue;
  1635. if (!video_options[i][0])
  1636. continue;
  1637. opt = video_options[i];
  1638. if (!strncmp(name, opt, name_len) &&
  1639. opt[name_len] == ':')
  1640. options = opt + name_len + 1;
  1641. }
  1642. }
  1643. if (options && !strncmp(options, "off", 3))
  1644. retval = 1;
  1645. if (option)
  1646. *option = options;
  1647. return retval;
  1648. }
  1649. EXPORT_SYMBOL(fb_get_options);
  1650. #ifndef MODULE
  1651. /**
  1652. * video_setup - process command line options
  1653. * @options: string of options
  1654. *
  1655. * Process command line options for frame buffer subsystem.
  1656. *
  1657. * NOTE: This function is a __setup and __init function.
  1658. * It only stores the options. Drivers have to call
  1659. * fb_get_options() as necessary.
  1660. *
  1661. * Returns zero.
  1662. *
  1663. */
  1664. static int __init video_setup(char *options)
  1665. {
  1666. int i, global = 0;
  1667. if (!options || !*options)
  1668. global = 1;
  1669. if (!global && !strncmp(options, "ofonly", 6)) {
  1670. ofonly = 1;
  1671. global = 1;
  1672. }
  1673. if (!global && !strchr(options, ':')) {
  1674. fb_mode_option = options;
  1675. global = 1;
  1676. }
  1677. if (!global) {
  1678. for (i = 0; i < FB_MAX; i++) {
  1679. if (video_options[i] == NULL) {
  1680. video_options[i] = options;
  1681. break;
  1682. }
  1683. }
  1684. }
  1685. return 1;
  1686. }
  1687. __setup("video=", video_setup);
  1688. #endif
  1689. MODULE_LICENSE("GPL");