drm_framebuffer.c 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235
  1. /*
  2. * Copyright (c) 2016 Intel Corporation
  3. *
  4. * Permission to use, copy, modify, distribute, and sell this software and its
  5. * documentation for any purpose is hereby granted without fee, provided that
  6. * the above copyright notice appear in all copies and that both that copyright
  7. * notice and this permission notice appear in supporting documentation, and
  8. * that the name of the copyright holders not be used in advertising or
  9. * publicity pertaining to distribution of the software without specific,
  10. * written prior permission. The copyright holders make no representations
  11. * about the suitability of this software for any purpose. It is provided "as
  12. * is" without express or implied warranty.
  13. *
  14. * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15. * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  16. * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17. * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18. * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  19. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  20. * OF THIS SOFTWARE.
  21. */
  22. #include <linux/export.h>
  23. #include <linux/uaccess.h>
  24. #include <drm/drm_atomic.h>
  25. #include <drm/drm_atomic_uapi.h>
  26. #include <drm/drm_auth.h>
  27. #include <drm/drm_debugfs.h>
  28. #include <drm/drm_drv.h>
  29. #include <drm/drm_file.h>
  30. #include <drm/drm_fourcc.h>
  31. #include <drm/drm_framebuffer.h>
  32. #include <drm/drm_gem.h>
  33. #include <drm/drm_print.h>
  34. #include <drm/drm_util.h>
  35. #include "drm_crtc_internal.h"
  36. #include "drm_internal.h"
  37. /**
  38. * DOC: overview
  39. *
  40. * Frame buffers are abstract memory objects that provide a source of pixels to
  41. * scanout to a CRTC. Applications explicitly request the creation of frame
  42. * buffers through the DRM_IOCTL_MODE_ADDFB(2) ioctls and receive an opaque
  43. * handle that can be passed to the KMS CRTC control, plane configuration and
  44. * page flip functions.
  45. *
  46. * Frame buffers rely on the underlying memory manager for allocating backing
  47. * storage. When creating a frame buffer applications pass a memory handle
  48. * (or a list of memory handles for multi-planar formats) through the
  49. * &struct drm_mode_fb_cmd2 argument. For drivers using GEM as their userspace
  50. * buffer management interface this would be a GEM handle. Drivers are however
  51. * free to use their own backing storage object handles, e.g. vmwgfx directly
  52. * exposes special TTM handles to userspace and so expects TTM handles in the
  53. * create ioctl and not GEM handles.
  54. *
  55. * Framebuffers are tracked with &struct drm_framebuffer. They are published
  56. * using drm_framebuffer_init() - after calling that function userspace can use
  57. * and access the framebuffer object. The helper function
  58. * drm_helper_mode_fill_fb_struct() can be used to pre-fill the required
  59. * metadata fields.
  60. *
  61. * The lifetime of a drm framebuffer is controlled with a reference count,
  62. * drivers can grab additional references with drm_framebuffer_get() and drop
  63. * them again with drm_framebuffer_put(). For driver-private framebuffers for
  64. * which the last reference is never dropped (e.g. for the fbdev framebuffer
  65. * when the struct &struct drm_framebuffer is embedded into the fbdev helper
  66. * struct) drivers can manually clean up a framebuffer at module unload time
  67. * with drm_framebuffer_unregister_private(). But doing this is not
  68. * recommended, and it's better to have a normal free-standing &struct
  69. * drm_framebuffer.
  70. */
  71. int drm_framebuffer_check_src_coords(uint32_t src_x, uint32_t src_y,
  72. uint32_t src_w, uint32_t src_h,
  73. const struct drm_framebuffer *fb)
  74. {
  75. unsigned int fb_width, fb_height;
  76. fb_width = fb->width << 16;
  77. fb_height = fb->height << 16;
  78. /* Make sure source coordinates are inside the fb. */
  79. if (src_w > fb_width ||
  80. src_x > fb_width - src_w ||
  81. src_h > fb_height ||
  82. src_y > fb_height - src_h) {
  83. drm_dbg_kms(fb->dev, "Invalid source coordinates "
  84. "%u.%06ux%u.%06u+%u.%06u+%u.%06u (fb %ux%u)\n",
  85. src_w >> 16, ((src_w & 0xffff) * 15625) >> 10,
  86. src_h >> 16, ((src_h & 0xffff) * 15625) >> 10,
  87. src_x >> 16, ((src_x & 0xffff) * 15625) >> 10,
  88. src_y >> 16, ((src_y & 0xffff) * 15625) >> 10,
  89. fb->width, fb->height);
  90. return -ENOSPC;
  91. }
  92. return 0;
  93. }
  94. /**
  95. * drm_mode_addfb - add an FB to the graphics configuration
  96. * @dev: drm device for the ioctl
  97. * @or: pointer to request structure
  98. * @file_priv: drm file
  99. *
  100. * Add a new FB to the specified CRTC, given a user request. This is the
  101. * original addfb ioctl which only supported RGB formats.
  102. *
  103. * Called by the user via ioctl, or by an in-kernel client.
  104. *
  105. * Returns:
  106. * Zero on success, negative errno on failure.
  107. */
  108. int drm_mode_addfb(struct drm_device *dev, struct drm_mode_fb_cmd *or,
  109. struct drm_file *file_priv)
  110. {
  111. struct drm_mode_fb_cmd2 r = {};
  112. int ret;
  113. if (!drm_core_check_feature(dev, DRIVER_MODESET))
  114. return -EOPNOTSUPP;
  115. r.pixel_format = drm_driver_legacy_fb_format(dev, or->bpp, or->depth);
  116. if (r.pixel_format == DRM_FORMAT_INVALID) {
  117. drm_dbg_kms(dev, "bad {bpp:%d, depth:%d}\n", or->bpp, or->depth);
  118. return -EINVAL;
  119. }
  120. /* convert to new format and call new ioctl */
  121. r.fb_id = or->fb_id;
  122. r.width = or->width;
  123. r.height = or->height;
  124. r.pitches[0] = or->pitch;
  125. r.handles[0] = or->handle;
  126. ret = drm_mode_addfb2(dev, &r, file_priv);
  127. if (ret)
  128. return ret;
  129. or->fb_id = r.fb_id;
  130. return 0;
  131. }
  132. int drm_mode_addfb_ioctl(struct drm_device *dev,
  133. void *data, struct drm_file *file_priv)
  134. {
  135. return drm_mode_addfb(dev, data, file_priv);
  136. }
  137. static int framebuffer_check(struct drm_device *dev,
  138. const struct drm_mode_fb_cmd2 *r)
  139. {
  140. const struct drm_format_info *info;
  141. int i;
  142. /* check if the format is supported at all */
  143. if (!__drm_format_info(r->pixel_format)) {
  144. drm_dbg_kms(dev, "bad framebuffer format %p4cc\n",
  145. &r->pixel_format);
  146. return -EINVAL;
  147. }
  148. if (r->width == 0) {
  149. drm_dbg_kms(dev, "bad framebuffer width %u\n", r->width);
  150. return -EINVAL;
  151. }
  152. if (r->height == 0) {
  153. drm_dbg_kms(dev, "bad framebuffer height %u\n", r->height);
  154. return -EINVAL;
  155. }
  156. /* now let the driver pick its own format info */
  157. info = drm_get_format_info(dev, r);
  158. for (i = 0; i < info->num_planes; i++) {
  159. unsigned int width = drm_format_info_plane_width(info, r->width, i);
  160. unsigned int height = drm_format_info_plane_height(info, r->height, i);
  161. unsigned int block_size = info->char_per_block[i];
  162. u64 min_pitch = drm_format_info_min_pitch(info, i, width);
  163. if (!block_size && (r->modifier[i] == DRM_FORMAT_MOD_LINEAR)) {
  164. drm_dbg_kms(dev, "Format requires non-linear modifier for plane %d\n", i);
  165. return -EINVAL;
  166. }
  167. if (!r->handles[i]) {
  168. drm_dbg_kms(dev, "no buffer object handle for plane %d\n", i);
  169. return -EINVAL;
  170. }
  171. if (min_pitch > UINT_MAX)
  172. return -ERANGE;
  173. if ((uint64_t) height * r->pitches[i] + r->offsets[i] > UINT_MAX)
  174. return -ERANGE;
  175. if (block_size && r->pitches[i] < min_pitch) {
  176. drm_dbg_kms(dev, "bad pitch %u for plane %d\n", r->pitches[i], i);
  177. return -EINVAL;
  178. }
  179. if (r->modifier[i] && !(r->flags & DRM_MODE_FB_MODIFIERS)) {
  180. drm_dbg_kms(dev, "bad fb modifier %llu for plane %d\n",
  181. r->modifier[i], i);
  182. return -EINVAL;
  183. }
  184. if (r->flags & DRM_MODE_FB_MODIFIERS &&
  185. r->modifier[i] != r->modifier[0]) {
  186. drm_dbg_kms(dev, "bad fb modifier %llu for plane %d\n",
  187. r->modifier[i], i);
  188. return -EINVAL;
  189. }
  190. /* modifier specific checks: */
  191. switch (r->modifier[i]) {
  192. case DRM_FORMAT_MOD_SAMSUNG_64_32_TILE:
  193. /* NOTE: the pitch restriction may be lifted later if it turns
  194. * out that no hw has this restriction:
  195. */
  196. if (r->pixel_format != DRM_FORMAT_NV12 ||
  197. width % 128 || height % 32 ||
  198. r->pitches[i] % 128) {
  199. drm_dbg_kms(dev, "bad modifier data for plane %d\n", i);
  200. return -EINVAL;
  201. }
  202. break;
  203. default:
  204. break;
  205. }
  206. }
  207. for (i = info->num_planes; i < 4; i++) {
  208. if (r->modifier[i]) {
  209. drm_dbg_kms(dev, "non-zero modifier for unused plane %d\n", i);
  210. return -EINVAL;
  211. }
  212. /* Pre-FB_MODIFIERS userspace didn't clear the structs properly. */
  213. if (!(r->flags & DRM_MODE_FB_MODIFIERS))
  214. continue;
  215. if (r->handles[i]) {
  216. drm_dbg_kms(dev, "buffer object handle for unused plane %d\n", i);
  217. return -EINVAL;
  218. }
  219. if (r->pitches[i]) {
  220. drm_dbg_kms(dev, "non-zero pitch for unused plane %d\n", i);
  221. return -EINVAL;
  222. }
  223. if (r->offsets[i]) {
  224. drm_dbg_kms(dev, "non-zero offset for unused plane %d\n", i);
  225. return -EINVAL;
  226. }
  227. }
  228. return 0;
  229. }
  230. struct drm_framebuffer *
  231. drm_internal_framebuffer_create(struct drm_device *dev,
  232. const struct drm_mode_fb_cmd2 *r,
  233. struct drm_file *file_priv)
  234. {
  235. struct drm_mode_config *config = &dev->mode_config;
  236. struct drm_framebuffer *fb;
  237. int ret;
  238. if (r->flags & ~(DRM_MODE_FB_INTERLACED | DRM_MODE_FB_MODIFIERS)) {
  239. drm_dbg_kms(dev, "bad framebuffer flags 0x%08x\n", r->flags);
  240. return ERR_PTR(-EINVAL);
  241. }
  242. if ((config->min_width > r->width) || (r->width > config->max_width)) {
  243. drm_dbg_kms(dev, "bad framebuffer width %d, should be >= %d && <= %d\n",
  244. r->width, config->min_width, config->max_width);
  245. return ERR_PTR(-EINVAL);
  246. }
  247. if ((config->min_height > r->height) || (r->height > config->max_height)) {
  248. drm_dbg_kms(dev, "bad framebuffer height %d, should be >= %d && <= %d\n",
  249. r->height, config->min_height, config->max_height);
  250. return ERR_PTR(-EINVAL);
  251. }
  252. if (r->flags & DRM_MODE_FB_MODIFIERS &&
  253. dev->mode_config.fb_modifiers_not_supported) {
  254. drm_dbg_kms(dev, "driver does not support fb modifiers\n");
  255. return ERR_PTR(-EINVAL);
  256. }
  257. ret = framebuffer_check(dev, r);
  258. if (ret)
  259. return ERR_PTR(ret);
  260. fb = dev->mode_config.funcs->fb_create(dev, file_priv, r);
  261. if (IS_ERR(fb)) {
  262. drm_dbg_kms(dev, "could not create framebuffer\n");
  263. return fb;
  264. }
  265. return fb;
  266. }
  267. EXPORT_SYMBOL_FOR_TESTS_ONLY(drm_internal_framebuffer_create);
  268. /**
  269. * drm_mode_addfb2 - add an FB to the graphics configuration
  270. * @dev: drm device for the ioctl
  271. * @data: data pointer for the ioctl
  272. * @file_priv: drm file for the ioctl call
  273. *
  274. * Add a new FB to the specified CRTC, given a user request with format. This is
  275. * the 2nd version of the addfb ioctl, which supports multi-planar framebuffers
  276. * and uses fourcc codes as pixel format specifiers.
  277. *
  278. * Called by the user via ioctl.
  279. *
  280. * Returns:
  281. * Zero on success, negative errno on failure.
  282. */
  283. int drm_mode_addfb2(struct drm_device *dev,
  284. void *data, struct drm_file *file_priv)
  285. {
  286. struct drm_mode_fb_cmd2 *r = data;
  287. struct drm_framebuffer *fb;
  288. if (!drm_core_check_feature(dev, DRIVER_MODESET))
  289. return -EOPNOTSUPP;
  290. fb = drm_internal_framebuffer_create(dev, r, file_priv);
  291. if (IS_ERR(fb))
  292. return PTR_ERR(fb);
  293. drm_dbg_kms(dev, "[FB:%d]\n", fb->base.id);
  294. r->fb_id = fb->base.id;
  295. /* Transfer ownership to the filp for reaping on close */
  296. mutex_lock(&file_priv->fbs_lock);
  297. list_add(&fb->filp_head, &file_priv->fbs);
  298. mutex_unlock(&file_priv->fbs_lock);
  299. return 0;
  300. }
  301. int drm_mode_addfb2_ioctl(struct drm_device *dev,
  302. void *data, struct drm_file *file_priv)
  303. {
  304. #ifdef __BIG_ENDIAN
  305. if (!dev->mode_config.quirk_addfb_prefer_host_byte_order) {
  306. /*
  307. * Drivers must set the
  308. * quirk_addfb_prefer_host_byte_order quirk to make
  309. * the drm_mode_addfb() compat code work correctly on
  310. * bigendian machines.
  311. *
  312. * If they don't they interpret pixel_format values
  313. * incorrectly for bug compatibility, which in turn
  314. * implies the ADDFB2 ioctl does not work correctly
  315. * then. So block it to make userspace fallback to
  316. * ADDFB.
  317. */
  318. drm_dbg_kms(dev, "addfb2 broken on bigendian");
  319. return -EOPNOTSUPP;
  320. }
  321. #endif
  322. return drm_mode_addfb2(dev, data, file_priv);
  323. }
  324. struct drm_mode_rmfb_work {
  325. struct work_struct work;
  326. struct list_head fbs;
  327. };
  328. static void drm_mode_rmfb_work_fn(struct work_struct *w)
  329. {
  330. struct drm_mode_rmfb_work *arg = container_of(w, typeof(*arg), work);
  331. while (!list_empty(&arg->fbs)) {
  332. struct drm_framebuffer *fb =
  333. list_first_entry(&arg->fbs, typeof(*fb), filp_head);
  334. drm_dbg_kms(fb->dev,
  335. "Removing [FB:%d] from all active usage due to RMFB ioctl\n",
  336. fb->base.id);
  337. list_del_init(&fb->filp_head);
  338. drm_framebuffer_remove(fb);
  339. }
  340. }
  341. static int drm_mode_closefb(struct drm_framebuffer *fb,
  342. struct drm_file *file_priv)
  343. {
  344. struct drm_framebuffer *fbl;
  345. bool found = false;
  346. mutex_lock(&file_priv->fbs_lock);
  347. list_for_each_entry(fbl, &file_priv->fbs, filp_head)
  348. if (fb == fbl)
  349. found = true;
  350. if (!found) {
  351. mutex_unlock(&file_priv->fbs_lock);
  352. return -ENOENT;
  353. }
  354. list_del_init(&fb->filp_head);
  355. mutex_unlock(&file_priv->fbs_lock);
  356. /* Drop the reference that was stored in the fbs list */
  357. drm_framebuffer_put(fb);
  358. return 0;
  359. }
  360. /**
  361. * drm_mode_rmfb - remove an FB from the configuration
  362. * @dev: drm device
  363. * @fb_id: id of framebuffer to remove
  364. * @file_priv: drm file
  365. *
  366. * Remove the specified FB.
  367. *
  368. * Called by the user via ioctl, or by an in-kernel client.
  369. *
  370. * Returns:
  371. * Zero on success, negative errno on failure.
  372. */
  373. int drm_mode_rmfb(struct drm_device *dev, u32 fb_id,
  374. struct drm_file *file_priv)
  375. {
  376. struct drm_framebuffer *fb;
  377. int ret;
  378. if (!drm_core_check_feature(dev, DRIVER_MODESET))
  379. return -EOPNOTSUPP;
  380. fb = drm_framebuffer_lookup(dev, file_priv, fb_id);
  381. if (!fb)
  382. return -ENOENT;
  383. ret = drm_mode_closefb(fb, file_priv);
  384. if (ret != 0) {
  385. drm_framebuffer_put(fb);
  386. return ret;
  387. }
  388. /*
  389. * drm_framebuffer_remove may fail with -EINTR on pending signals,
  390. * so run this in a separate stack as there's no way to correctly
  391. * handle this after the fb is already removed from the lookup table.
  392. */
  393. if (drm_framebuffer_read_refcount(fb) > 1) {
  394. struct drm_mode_rmfb_work arg;
  395. INIT_WORK_ONSTACK(&arg.work, drm_mode_rmfb_work_fn);
  396. INIT_LIST_HEAD(&arg.fbs);
  397. drm_WARN_ON(dev, !list_empty(&fb->filp_head));
  398. list_add_tail(&fb->filp_head, &arg.fbs);
  399. schedule_work(&arg.work);
  400. flush_work(&arg.work);
  401. destroy_work_on_stack(&arg.work);
  402. } else
  403. drm_framebuffer_put(fb);
  404. return 0;
  405. }
  406. int drm_mode_rmfb_ioctl(struct drm_device *dev,
  407. void *data, struct drm_file *file_priv)
  408. {
  409. uint32_t *fb_id = data;
  410. return drm_mode_rmfb(dev, *fb_id, file_priv);
  411. }
  412. int drm_mode_closefb_ioctl(struct drm_device *dev,
  413. void *data, struct drm_file *file_priv)
  414. {
  415. struct drm_mode_closefb *r = data;
  416. struct drm_framebuffer *fb;
  417. int ret;
  418. if (!drm_core_check_feature(dev, DRIVER_MODESET))
  419. return -EOPNOTSUPP;
  420. if (r->pad)
  421. return -EINVAL;
  422. fb = drm_framebuffer_lookup(dev, file_priv, r->fb_id);
  423. if (!fb)
  424. return -ENOENT;
  425. ret = drm_mode_closefb(fb, file_priv);
  426. drm_framebuffer_put(fb);
  427. return ret;
  428. }
  429. /**
  430. * drm_mode_getfb - get FB info
  431. * @dev: drm device for the ioctl
  432. * @data: data pointer for the ioctl
  433. * @file_priv: drm file for the ioctl call
  434. *
  435. * Lookup the FB given its ID and return info about it.
  436. *
  437. * Called by the user via ioctl.
  438. *
  439. * Returns:
  440. * Zero on success, negative errno on failure.
  441. */
  442. int drm_mode_getfb(struct drm_device *dev,
  443. void *data, struct drm_file *file_priv)
  444. {
  445. struct drm_mode_fb_cmd *r = data;
  446. struct drm_framebuffer *fb;
  447. int ret;
  448. if (!drm_core_check_feature(dev, DRIVER_MODESET))
  449. return -EOPNOTSUPP;
  450. fb = drm_framebuffer_lookup(dev, file_priv, r->fb_id);
  451. if (!fb)
  452. return -ENOENT;
  453. /* Multi-planar framebuffers need getfb2. */
  454. if (fb->format->num_planes > 1) {
  455. ret = -EINVAL;
  456. goto out;
  457. }
  458. if (!fb->funcs->create_handle) {
  459. ret = -ENODEV;
  460. goto out;
  461. }
  462. r->height = fb->height;
  463. r->width = fb->width;
  464. r->depth = fb->format->depth;
  465. r->bpp = drm_format_info_bpp(fb->format, 0);
  466. r->pitch = fb->pitches[0];
  467. /* GET_FB() is an unprivileged ioctl so we must not return a
  468. * buffer-handle to non-master processes! For
  469. * backwards-compatibility reasons, we cannot make GET_FB() privileged,
  470. * so just return an invalid handle for non-masters.
  471. */
  472. if (!drm_is_current_master(file_priv) && !capable(CAP_SYS_ADMIN)) {
  473. r->handle = 0;
  474. ret = 0;
  475. goto out;
  476. }
  477. ret = fb->funcs->create_handle(fb, file_priv, &r->handle);
  478. out:
  479. drm_framebuffer_put(fb);
  480. return ret;
  481. }
  482. /**
  483. * drm_mode_getfb2_ioctl - get extended FB info
  484. * @dev: drm device for the ioctl
  485. * @data: data pointer for the ioctl
  486. * @file_priv: drm file for the ioctl call
  487. *
  488. * Lookup the FB given its ID and return info about it.
  489. *
  490. * Called by the user via ioctl.
  491. *
  492. * Returns:
  493. * Zero on success, negative errno on failure.
  494. */
  495. int drm_mode_getfb2_ioctl(struct drm_device *dev,
  496. void *data, struct drm_file *file_priv)
  497. {
  498. struct drm_mode_fb_cmd2 *r = data;
  499. struct drm_framebuffer *fb;
  500. unsigned int i;
  501. int ret = 0;
  502. if (!drm_core_check_feature(dev, DRIVER_MODESET))
  503. return -EINVAL;
  504. fb = drm_framebuffer_lookup(dev, file_priv, r->fb_id);
  505. if (!fb)
  506. return -ENOENT;
  507. /* For multi-plane framebuffers, we require the driver to place the
  508. * GEM objects directly in the drm_framebuffer. For single-plane
  509. * framebuffers, we can fall back to create_handle.
  510. */
  511. if (!fb->obj[0] &&
  512. (fb->format->num_planes > 1 || !fb->funcs->create_handle)) {
  513. ret = -ENODEV;
  514. goto out;
  515. }
  516. r->height = fb->height;
  517. r->width = fb->width;
  518. r->pixel_format = fb->format->format;
  519. r->flags = 0;
  520. if (!dev->mode_config.fb_modifiers_not_supported)
  521. r->flags |= DRM_MODE_FB_MODIFIERS;
  522. for (i = 0; i < ARRAY_SIZE(r->handles); i++) {
  523. r->handles[i] = 0;
  524. r->pitches[i] = 0;
  525. r->offsets[i] = 0;
  526. r->modifier[i] = 0;
  527. }
  528. for (i = 0; i < fb->format->num_planes; i++) {
  529. r->pitches[i] = fb->pitches[i];
  530. r->offsets[i] = fb->offsets[i];
  531. if (!dev->mode_config.fb_modifiers_not_supported)
  532. r->modifier[i] = fb->modifier;
  533. }
  534. /* GET_FB2() is an unprivileged ioctl so we must not return a
  535. * buffer-handle to non master/root processes! To match GET_FB()
  536. * just return invalid handles (0) for non masters/root
  537. * rather than making GET_FB2() privileged.
  538. */
  539. if (!drm_is_current_master(file_priv) && !capable(CAP_SYS_ADMIN)) {
  540. ret = 0;
  541. goto out;
  542. }
  543. for (i = 0; i < fb->format->num_planes; i++) {
  544. int j;
  545. /* If we reuse the same object for multiple planes, also
  546. * return the same handle.
  547. */
  548. for (j = 0; j < i; j++) {
  549. if (fb->obj[i] == fb->obj[j]) {
  550. r->handles[i] = r->handles[j];
  551. break;
  552. }
  553. }
  554. if (r->handles[i])
  555. continue;
  556. if (fb->obj[i]) {
  557. ret = drm_gem_handle_create(file_priv, fb->obj[i],
  558. &r->handles[i]);
  559. } else {
  560. WARN_ON(i > 0);
  561. ret = fb->funcs->create_handle(fb, file_priv,
  562. &r->handles[i]);
  563. }
  564. if (ret != 0)
  565. goto out;
  566. }
  567. out:
  568. if (ret != 0) {
  569. /* Delete any previously-created handles on failure. */
  570. for (i = 0; i < ARRAY_SIZE(r->handles); i++) {
  571. int j;
  572. if (r->handles[i])
  573. drm_gem_handle_delete(file_priv, r->handles[i]);
  574. /* Zero out any handles identical to the one we just
  575. * deleted.
  576. */
  577. for (j = i + 1; j < ARRAY_SIZE(r->handles); j++) {
  578. if (r->handles[j] == r->handles[i])
  579. r->handles[j] = 0;
  580. }
  581. }
  582. }
  583. drm_framebuffer_put(fb);
  584. return ret;
  585. }
  586. /**
  587. * drm_mode_dirtyfb_ioctl - flush frontbuffer rendering on an FB
  588. * @dev: drm device for the ioctl
  589. * @data: data pointer for the ioctl
  590. * @file_priv: drm file for the ioctl call
  591. *
  592. * Lookup the FB and flush out the damaged area supplied by userspace as a clip
  593. * rectangle list. Generic userspace which does frontbuffer rendering must call
  594. * this ioctl to flush out the changes on manual-update display outputs, e.g.
  595. * usb display-link, mipi manual update panels or edp panel self refresh modes.
  596. *
  597. * Modesetting drivers which always update the frontbuffer do not need to
  598. * implement the corresponding &drm_framebuffer_funcs.dirty callback.
  599. *
  600. * Called by the user via ioctl.
  601. *
  602. * Returns:
  603. * Zero on success, negative errno on failure.
  604. */
  605. int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
  606. void *data, struct drm_file *file_priv)
  607. {
  608. struct drm_clip_rect __user *clips_ptr;
  609. struct drm_clip_rect *clips = NULL;
  610. struct drm_mode_fb_dirty_cmd *r = data;
  611. struct drm_framebuffer *fb;
  612. unsigned flags;
  613. int num_clips;
  614. int ret;
  615. if (!drm_core_check_feature(dev, DRIVER_MODESET))
  616. return -EOPNOTSUPP;
  617. fb = drm_framebuffer_lookup(dev, file_priv, r->fb_id);
  618. if (!fb)
  619. return -ENOENT;
  620. num_clips = r->num_clips;
  621. clips_ptr = (struct drm_clip_rect __user *)(unsigned long)r->clips_ptr;
  622. if (!num_clips != !clips_ptr) {
  623. ret = -EINVAL;
  624. goto out_err1;
  625. }
  626. flags = DRM_MODE_FB_DIRTY_FLAGS & r->flags;
  627. /* If userspace annotates copy, clips must come in pairs */
  628. if (flags & DRM_MODE_FB_DIRTY_ANNOTATE_COPY && (num_clips % 2)) {
  629. ret = -EINVAL;
  630. goto out_err1;
  631. }
  632. if (num_clips && clips_ptr) {
  633. if (num_clips < 0 || num_clips > DRM_MODE_FB_DIRTY_MAX_CLIPS) {
  634. ret = -EINVAL;
  635. goto out_err1;
  636. }
  637. clips = kcalloc(num_clips, sizeof(*clips), GFP_KERNEL);
  638. if (!clips) {
  639. ret = -ENOMEM;
  640. goto out_err1;
  641. }
  642. ret = copy_from_user(clips, clips_ptr,
  643. num_clips * sizeof(*clips));
  644. if (ret) {
  645. ret = -EFAULT;
  646. goto out_err2;
  647. }
  648. }
  649. if (fb->funcs->dirty) {
  650. ret = fb->funcs->dirty(fb, file_priv, flags, r->color,
  651. clips, num_clips);
  652. } else {
  653. ret = -ENOSYS;
  654. }
  655. out_err2:
  656. kfree(clips);
  657. out_err1:
  658. drm_framebuffer_put(fb);
  659. return ret;
  660. }
  661. /**
  662. * drm_fb_release - remove and free the FBs on this file
  663. * @priv: drm file for the ioctl
  664. *
  665. * Destroy all the FBs associated with @filp.
  666. *
  667. * Called by the user via ioctl.
  668. *
  669. * Returns:
  670. * Zero on success, negative errno on failure.
  671. */
  672. void drm_fb_release(struct drm_file *priv)
  673. {
  674. struct drm_framebuffer *fb, *tfb;
  675. struct drm_mode_rmfb_work arg;
  676. INIT_LIST_HEAD(&arg.fbs);
  677. /*
  678. * When the file gets released that means no one else can access the fb
  679. * list any more, so no need to grab fpriv->fbs_lock. And we need to
  680. * avoid upsetting lockdep since the universal cursor code adds a
  681. * framebuffer while holding mutex locks.
  682. *
  683. * Note that a real deadlock between fpriv->fbs_lock and the modeset
  684. * locks is impossible here since no one else but this function can get
  685. * at it any more.
  686. */
  687. list_for_each_entry_safe(fb, tfb, &priv->fbs, filp_head) {
  688. if (drm_framebuffer_read_refcount(fb) > 1) {
  689. list_move_tail(&fb->filp_head, &arg.fbs);
  690. } else {
  691. list_del_init(&fb->filp_head);
  692. /* This drops the fpriv->fbs reference. */
  693. drm_framebuffer_put(fb);
  694. }
  695. }
  696. if (!list_empty(&arg.fbs)) {
  697. INIT_WORK_ONSTACK(&arg.work, drm_mode_rmfb_work_fn);
  698. schedule_work(&arg.work);
  699. flush_work(&arg.work);
  700. destroy_work_on_stack(&arg.work);
  701. }
  702. }
  703. void drm_framebuffer_free(struct kref *kref)
  704. {
  705. struct drm_framebuffer *fb =
  706. container_of(kref, struct drm_framebuffer, base.refcount);
  707. struct drm_device *dev = fb->dev;
  708. drm_WARN_ON(dev, !list_empty(&fb->filp_head));
  709. /*
  710. * The lookup idr holds a weak reference, which has not necessarily been
  711. * removed at this point. Check for that.
  712. */
  713. drm_mode_object_unregister(dev, &fb->base);
  714. fb->funcs->destroy(fb);
  715. }
  716. /**
  717. * drm_framebuffer_init - initialize a framebuffer
  718. * @dev: DRM device
  719. * @fb: framebuffer to be initialized
  720. * @funcs: ... with these functions
  721. *
  722. * Allocates an ID for the framebuffer's parent mode object, sets its mode
  723. * functions & device file and adds it to the master fd list.
  724. *
  725. * IMPORTANT:
  726. * This functions publishes the fb and makes it available for concurrent access
  727. * by other users. Which means by this point the fb _must_ be fully set up -
  728. * since all the fb attributes are invariant over its lifetime, no further
  729. * locking but only correct reference counting is required.
  730. *
  731. * Returns:
  732. * Zero on success, error code on failure.
  733. */
  734. int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb,
  735. const struct drm_framebuffer_funcs *funcs)
  736. {
  737. unsigned int i;
  738. int ret;
  739. bool exists;
  740. if (WARN_ON_ONCE(fb->dev != dev || !fb->format))
  741. return -EINVAL;
  742. for (i = 0; i < fb->format->num_planes; i++) {
  743. if (drm_WARN_ON_ONCE(dev, fb->internal_flags & DRM_FRAMEBUFFER_HAS_HANDLE_REF(i)))
  744. fb->internal_flags &= ~DRM_FRAMEBUFFER_HAS_HANDLE_REF(i);
  745. if (fb->obj[i]) {
  746. exists = drm_gem_object_handle_get_if_exists_unlocked(fb->obj[i]);
  747. if (exists)
  748. fb->internal_flags |= DRM_FRAMEBUFFER_HAS_HANDLE_REF(i);
  749. }
  750. }
  751. INIT_LIST_HEAD(&fb->filp_head);
  752. fb->funcs = funcs;
  753. strcpy(fb->comm, current->comm);
  754. ret = __drm_mode_object_add(dev, &fb->base, DRM_MODE_OBJECT_FB,
  755. false, drm_framebuffer_free);
  756. if (ret)
  757. goto err;
  758. mutex_lock(&dev->mode_config.fb_lock);
  759. dev->mode_config.num_fb++;
  760. list_add(&fb->head, &dev->mode_config.fb_list);
  761. mutex_unlock(&dev->mode_config.fb_lock);
  762. drm_mode_object_register(dev, &fb->base);
  763. return 0;
  764. err:
  765. for (i = 0; i < fb->format->num_planes; i++) {
  766. if (fb->internal_flags & DRM_FRAMEBUFFER_HAS_HANDLE_REF(i)) {
  767. drm_gem_object_handle_put_unlocked(fb->obj[i]);
  768. fb->internal_flags &= ~DRM_FRAMEBUFFER_HAS_HANDLE_REF(i);
  769. }
  770. }
  771. return ret;
  772. }
  773. EXPORT_SYMBOL(drm_framebuffer_init);
  774. /**
  775. * drm_framebuffer_lookup - look up a drm framebuffer and grab a reference
  776. * @dev: drm device
  777. * @file_priv: drm file to check for lease against.
  778. * @id: id of the fb object
  779. *
  780. * If successful, this grabs an additional reference to the framebuffer -
  781. * callers need to make sure to eventually unreference the returned framebuffer
  782. * again, using drm_framebuffer_put().
  783. */
  784. struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev,
  785. struct drm_file *file_priv,
  786. uint32_t id)
  787. {
  788. struct drm_mode_object *obj;
  789. struct drm_framebuffer *fb = NULL;
  790. obj = __drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_FB);
  791. if (obj)
  792. fb = obj_to_fb(obj);
  793. return fb;
  794. }
  795. EXPORT_SYMBOL(drm_framebuffer_lookup);
  796. /**
  797. * drm_framebuffer_unregister_private - unregister a private fb from the lookup idr
  798. * @fb: fb to unregister
  799. *
  800. * Drivers need to call this when cleaning up driver-private framebuffers, e.g.
  801. * those used for fbdev. Note that the caller must hold a reference of its own,
  802. * i.e. the object may not be destroyed through this call (since it'll lead to a
  803. * locking inversion).
  804. *
  805. * NOTE: This function is deprecated. For driver-private framebuffers it is not
  806. * recommended to embed a framebuffer struct info fbdev struct, instead, a
  807. * framebuffer pointer is preferred and drm_framebuffer_put() should be called
  808. * when the framebuffer is to be cleaned up.
  809. */
  810. void drm_framebuffer_unregister_private(struct drm_framebuffer *fb)
  811. {
  812. struct drm_device *dev;
  813. if (!fb)
  814. return;
  815. dev = fb->dev;
  816. /* Mark fb as reaped and drop idr ref. */
  817. drm_mode_object_unregister(dev, &fb->base);
  818. }
  819. EXPORT_SYMBOL(drm_framebuffer_unregister_private);
  820. /**
  821. * drm_framebuffer_cleanup - remove a framebuffer object
  822. * @fb: framebuffer to remove
  823. *
  824. * Cleanup framebuffer. This function is intended to be used from the drivers
  825. * &drm_framebuffer_funcs.destroy callback. It can also be used to clean up
  826. * driver private framebuffers embedded into a larger structure.
  827. *
  828. * Note that this function does not remove the fb from active usage - if it is
  829. * still used anywhere, hilarity can ensue since userspace could call getfb on
  830. * the id and get back -EINVAL. Obviously no concern at driver unload time.
  831. *
  832. * Also, the framebuffer will not be removed from the lookup idr - for
  833. * user-created framebuffers this will happen in the rmfb ioctl. For
  834. * driver-private objects (e.g. for fbdev) drivers need to explicitly call
  835. * drm_framebuffer_unregister_private.
  836. */
  837. void drm_framebuffer_cleanup(struct drm_framebuffer *fb)
  838. {
  839. struct drm_device *dev = fb->dev;
  840. unsigned int i;
  841. for (i = 0; i < fb->format->num_planes; i++) {
  842. if (fb->internal_flags & DRM_FRAMEBUFFER_HAS_HANDLE_REF(i))
  843. drm_gem_object_handle_put_unlocked(fb->obj[i]);
  844. }
  845. mutex_lock(&dev->mode_config.fb_lock);
  846. list_del(&fb->head);
  847. dev->mode_config.num_fb--;
  848. mutex_unlock(&dev->mode_config.fb_lock);
  849. }
  850. EXPORT_SYMBOL(drm_framebuffer_cleanup);
  851. static int atomic_remove_fb(struct drm_framebuffer *fb)
  852. {
  853. struct drm_modeset_acquire_ctx ctx;
  854. struct drm_device *dev = fb->dev;
  855. struct drm_atomic_state *state;
  856. struct drm_plane *plane;
  857. struct drm_connector *conn __maybe_unused;
  858. struct drm_connector_state *conn_state;
  859. int i, ret;
  860. unsigned plane_mask;
  861. bool disable_crtcs = false;
  862. retry_disable:
  863. drm_modeset_acquire_init(&ctx, 0);
  864. state = drm_atomic_state_alloc(dev);
  865. if (!state) {
  866. ret = -ENOMEM;
  867. goto out;
  868. }
  869. state->acquire_ctx = &ctx;
  870. retry:
  871. plane_mask = 0;
  872. ret = drm_modeset_lock_all_ctx(dev, &ctx);
  873. if (ret)
  874. goto unlock;
  875. drm_for_each_plane(plane, dev) {
  876. struct drm_plane_state *plane_state;
  877. if (plane->state->fb != fb)
  878. continue;
  879. drm_dbg_kms(dev,
  880. "Disabling [PLANE:%d:%s] because [FB:%d] is removed\n",
  881. plane->base.id, plane->name, fb->base.id);
  882. plane_state = drm_atomic_get_plane_state(state, plane);
  883. if (IS_ERR(plane_state)) {
  884. ret = PTR_ERR(plane_state);
  885. goto unlock;
  886. }
  887. if (disable_crtcs && plane_state->crtc->primary == plane) {
  888. struct drm_crtc_state *crtc_state;
  889. drm_dbg_kms(dev,
  890. "Disabling [CRTC:%d:%s] because [FB:%d] is removed\n",
  891. plane_state->crtc->base.id,
  892. plane_state->crtc->name, fb->base.id);
  893. crtc_state = drm_atomic_get_existing_crtc_state(state, plane_state->crtc);
  894. ret = drm_atomic_add_affected_connectors(state, plane_state->crtc);
  895. if (ret)
  896. goto unlock;
  897. crtc_state->active = false;
  898. ret = drm_atomic_set_mode_for_crtc(crtc_state, NULL);
  899. if (ret)
  900. goto unlock;
  901. }
  902. drm_atomic_set_fb_for_plane(plane_state, NULL);
  903. ret = drm_atomic_set_crtc_for_plane(plane_state, NULL);
  904. if (ret)
  905. goto unlock;
  906. plane_mask |= drm_plane_mask(plane);
  907. }
  908. /* This list is only filled when disable_crtcs is set. */
  909. for_each_new_connector_in_state(state, conn, conn_state, i) {
  910. ret = drm_atomic_set_crtc_for_connector(conn_state, NULL);
  911. if (ret)
  912. goto unlock;
  913. }
  914. if (plane_mask)
  915. ret = drm_atomic_commit(state);
  916. unlock:
  917. if (ret == -EDEADLK) {
  918. drm_atomic_state_clear(state);
  919. drm_modeset_backoff(&ctx);
  920. goto retry;
  921. }
  922. drm_atomic_state_put(state);
  923. out:
  924. drm_modeset_drop_locks(&ctx);
  925. drm_modeset_acquire_fini(&ctx);
  926. if (ret == -EINVAL && !disable_crtcs) {
  927. disable_crtcs = true;
  928. goto retry_disable;
  929. }
  930. return ret;
  931. }
  932. static void legacy_remove_fb(struct drm_framebuffer *fb)
  933. {
  934. struct drm_device *dev = fb->dev;
  935. struct drm_crtc *crtc;
  936. struct drm_plane *plane;
  937. drm_modeset_lock_all(dev);
  938. /* remove from any CRTC */
  939. drm_for_each_crtc(crtc, dev) {
  940. if (crtc->primary->fb == fb) {
  941. drm_dbg_kms(dev,
  942. "Disabling [CRTC:%d:%s] because [FB:%d] is removed\n",
  943. crtc->base.id, crtc->name, fb->base.id);
  944. /* should turn off the crtc */
  945. if (drm_crtc_force_disable(crtc))
  946. DRM_ERROR("failed to reset crtc %p when fb was deleted\n", crtc);
  947. }
  948. }
  949. drm_for_each_plane(plane, dev) {
  950. if (plane->fb == fb) {
  951. drm_dbg_kms(dev,
  952. "Disabling [PLANE:%d:%s] because [FB:%d] is removed\n",
  953. plane->base.id, plane->name, fb->base.id);
  954. drm_plane_force_disable(plane);
  955. }
  956. }
  957. drm_modeset_unlock_all(dev);
  958. }
  959. /**
  960. * drm_framebuffer_remove - remove and unreference a framebuffer object
  961. * @fb: framebuffer to remove
  962. *
  963. * Scans all the CRTCs and planes in @dev's mode_config. If they're
  964. * using @fb, removes it, setting it to NULL. Then drops the reference to the
  965. * passed-in framebuffer. Might take the modeset locks.
  966. *
  967. * Note that this function optimizes the cleanup away if the caller holds the
  968. * last reference to the framebuffer. It is also guaranteed to not take the
  969. * modeset locks in this case.
  970. */
  971. void drm_framebuffer_remove(struct drm_framebuffer *fb)
  972. {
  973. struct drm_device *dev;
  974. if (!fb)
  975. return;
  976. dev = fb->dev;
  977. drm_WARN_ON(dev, !list_empty(&fb->filp_head));
  978. /*
  979. * drm ABI mandates that we remove any deleted framebuffers from active
  980. * usage. But since most sane clients only remove framebuffers they no
  981. * longer need, try to optimize this away.
  982. *
  983. * Since we're holding a reference ourselves, observing a refcount of 1
  984. * means that we're the last holder and can skip it. Also, the refcount
  985. * can never increase from 1 again, so we don't need any barriers or
  986. * locks.
  987. *
  988. * Note that userspace could try to race with use and instate a new
  989. * usage _after_ we've cleared all current ones. End result will be an
  990. * in-use fb with fb-id == 0. Userspace is allowed to shoot its own foot
  991. * in this manner.
  992. */
  993. if (drm_framebuffer_read_refcount(fb) > 1) {
  994. if (drm_drv_uses_atomic_modeset(dev)) {
  995. int ret = atomic_remove_fb(fb);
  996. WARN(ret, "atomic remove_fb failed with %i\n", ret);
  997. } else
  998. legacy_remove_fb(fb);
  999. }
  1000. drm_framebuffer_put(fb);
  1001. }
  1002. EXPORT_SYMBOL(drm_framebuffer_remove);
  1003. void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,
  1004. const struct drm_framebuffer *fb)
  1005. {
  1006. unsigned int i;
  1007. drm_printf_indent(p, indent, "allocated by = %s\n", fb->comm);
  1008. drm_printf_indent(p, indent, "refcount=%u\n",
  1009. drm_framebuffer_read_refcount(fb));
  1010. drm_printf_indent(p, indent, "format=%p4cc\n", &fb->format->format);
  1011. drm_printf_indent(p, indent, "modifier=0x%llx\n", fb->modifier);
  1012. drm_printf_indent(p, indent, "size=%ux%u\n", fb->width, fb->height);
  1013. drm_printf_indent(p, indent, "layers:\n");
  1014. for (i = 0; i < fb->format->num_planes; i++) {
  1015. drm_printf_indent(p, indent + 1, "size[%u]=%dx%d\n", i,
  1016. drm_format_info_plane_width(fb->format, fb->width, i),
  1017. drm_format_info_plane_height(fb->format, fb->height, i));
  1018. drm_printf_indent(p, indent + 1, "pitch[%u]=%u\n", i, fb->pitches[i]);
  1019. drm_printf_indent(p, indent + 1, "offset[%u]=%u\n", i, fb->offsets[i]);
  1020. drm_printf_indent(p, indent + 1, "obj[%u]:%s\n", i,
  1021. fb->obj[i] ? "" : "(null)");
  1022. if (fb->obj[i])
  1023. drm_gem_print_info(p, indent + 2, fb->obj[i]);
  1024. }
  1025. }
  1026. #ifdef CONFIG_DEBUG_FS
  1027. static int drm_framebuffer_info(struct seq_file *m, void *data)
  1028. {
  1029. struct drm_debugfs_entry *entry = m->private;
  1030. struct drm_device *dev = entry->dev;
  1031. struct drm_printer p = drm_seq_file_printer(m);
  1032. struct drm_framebuffer *fb;
  1033. mutex_lock(&dev->mode_config.fb_lock);
  1034. drm_for_each_fb(fb, dev) {
  1035. drm_printf(&p, "framebuffer[%u]:\n", fb->base.id);
  1036. drm_framebuffer_print_info(&p, 1, fb);
  1037. }
  1038. mutex_unlock(&dev->mode_config.fb_lock);
  1039. return 0;
  1040. }
  1041. static const struct drm_debugfs_info drm_framebuffer_debugfs_list[] = {
  1042. { "framebuffer", drm_framebuffer_info, 0 },
  1043. };
  1044. void drm_framebuffer_debugfs_init(struct drm_device *dev)
  1045. {
  1046. drm_debugfs_add_files(dev, drm_framebuffer_debugfs_list,
  1047. ARRAY_SIZE(drm_framebuffer_debugfs_list));
  1048. }
  1049. #endif