exynos_drm_scaler.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. /*
  2. * Copyright (C) 2017 Samsung Electronics Co.Ltd
  3. * Author:
  4. * Andrzej Pietrasiewicz <andrzej.p@samsung.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundationr
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/component.h>
  12. #include <linux/err.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/io.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/clk.h>
  17. #include <linux/of_device.h>
  18. #include <linux/pm_runtime.h>
  19. #include <drm/drmP.h>
  20. #include <drm/exynos_drm.h>
  21. #include "regs-scaler.h"
  22. #include "exynos_drm_fb.h"
  23. #include "exynos_drm_drv.h"
  24. #include "exynos_drm_iommu.h"
  25. #include "exynos_drm_ipp.h"
  26. #define scaler_read(offset) readl(scaler->regs + (offset))
  27. #define scaler_write(cfg, offset) writel(cfg, scaler->regs + (offset))
  28. #define SCALER_MAX_CLK 4
  29. #define SCALER_AUTOSUSPEND_DELAY 2000
  30. struct scaler_data {
  31. const char *clk_name[SCALER_MAX_CLK];
  32. unsigned int num_clk;
  33. const struct exynos_drm_ipp_formats *formats;
  34. unsigned int num_formats;
  35. };
  36. struct scaler_context {
  37. struct exynos_drm_ipp ipp;
  38. struct drm_device *drm_dev;
  39. struct device *dev;
  40. void __iomem *regs;
  41. struct clk *clock[SCALER_MAX_CLK];
  42. struct exynos_drm_ipp_task *task;
  43. const struct scaler_data *scaler_data;
  44. };
  45. static u32 scaler_get_format(u32 drm_fmt)
  46. {
  47. switch (drm_fmt) {
  48. case DRM_FORMAT_NV21:
  49. return SCALER_YUV420_2P_UV;
  50. case DRM_FORMAT_NV12:
  51. return SCALER_YUV420_2P_VU;
  52. case DRM_FORMAT_YUV420:
  53. return SCALER_YUV420_3P;
  54. case DRM_FORMAT_YUYV:
  55. return SCALER_YUV422_1P_YUYV;
  56. case DRM_FORMAT_UYVY:
  57. return SCALER_YUV422_1P_UYVY;
  58. case DRM_FORMAT_YVYU:
  59. return SCALER_YUV422_1P_YVYU;
  60. case DRM_FORMAT_NV61:
  61. return SCALER_YUV422_2P_UV;
  62. case DRM_FORMAT_NV16:
  63. return SCALER_YUV422_2P_VU;
  64. case DRM_FORMAT_YUV422:
  65. return SCALER_YUV422_3P;
  66. case DRM_FORMAT_NV42:
  67. return SCALER_YUV444_2P_UV;
  68. case DRM_FORMAT_NV24:
  69. return SCALER_YUV444_2P_VU;
  70. case DRM_FORMAT_YUV444:
  71. return SCALER_YUV444_3P;
  72. case DRM_FORMAT_RGB565:
  73. return SCALER_RGB_565;
  74. case DRM_FORMAT_XRGB1555:
  75. return SCALER_ARGB1555;
  76. case DRM_FORMAT_ARGB1555:
  77. return SCALER_ARGB1555;
  78. case DRM_FORMAT_XRGB4444:
  79. return SCALER_ARGB4444;
  80. case DRM_FORMAT_ARGB4444:
  81. return SCALER_ARGB4444;
  82. case DRM_FORMAT_XRGB8888:
  83. return SCALER_ARGB8888;
  84. case DRM_FORMAT_ARGB8888:
  85. return SCALER_ARGB8888;
  86. case DRM_FORMAT_RGBX8888:
  87. return SCALER_RGBA8888;
  88. case DRM_FORMAT_RGBA8888:
  89. return SCALER_RGBA8888;
  90. default:
  91. break;
  92. }
  93. return 0;
  94. }
  95. static inline void scaler_enable_int(struct scaler_context *scaler)
  96. {
  97. u32 val;
  98. val = SCALER_INT_EN_TIMEOUT |
  99. SCALER_INT_EN_ILLEGAL_BLEND |
  100. SCALER_INT_EN_ILLEGAL_RATIO |
  101. SCALER_INT_EN_ILLEGAL_DST_HEIGHT |
  102. SCALER_INT_EN_ILLEGAL_DST_WIDTH |
  103. SCALER_INT_EN_ILLEGAL_DST_V_POS |
  104. SCALER_INT_EN_ILLEGAL_DST_H_POS |
  105. SCALER_INT_EN_ILLEGAL_DST_C_SPAN |
  106. SCALER_INT_EN_ILLEGAL_DST_Y_SPAN |
  107. SCALER_INT_EN_ILLEGAL_DST_CR_BASE |
  108. SCALER_INT_EN_ILLEGAL_DST_CB_BASE |
  109. SCALER_INT_EN_ILLEGAL_DST_Y_BASE |
  110. SCALER_INT_EN_ILLEGAL_DST_COLOR |
  111. SCALER_INT_EN_ILLEGAL_SRC_HEIGHT |
  112. SCALER_INT_EN_ILLEGAL_SRC_WIDTH |
  113. SCALER_INT_EN_ILLEGAL_SRC_CV_POS |
  114. SCALER_INT_EN_ILLEGAL_SRC_CH_POS |
  115. SCALER_INT_EN_ILLEGAL_SRC_YV_POS |
  116. SCALER_INT_EN_ILLEGAL_SRC_YH_POS |
  117. SCALER_INT_EN_ILLEGAL_DST_SPAN |
  118. SCALER_INT_EN_ILLEGAL_SRC_Y_SPAN |
  119. SCALER_INT_EN_ILLEGAL_SRC_CR_BASE |
  120. SCALER_INT_EN_ILLEGAL_SRC_CB_BASE |
  121. SCALER_INT_EN_ILLEGAL_SRC_Y_BASE |
  122. SCALER_INT_EN_ILLEGAL_SRC_COLOR |
  123. SCALER_INT_EN_FRAME_END;
  124. scaler_write(val, SCALER_INT_EN);
  125. }
  126. static inline void scaler_set_src_fmt(struct scaler_context *scaler,
  127. u32 src_fmt)
  128. {
  129. u32 val;
  130. val = SCALER_SRC_CFG_SET_COLOR_FORMAT(src_fmt);
  131. scaler_write(val, SCALER_SRC_CFG);
  132. }
  133. static inline void scaler_set_src_base(struct scaler_context *scaler,
  134. struct exynos_drm_ipp_buffer *src_buf)
  135. {
  136. static unsigned int bases[] = {
  137. SCALER_SRC_Y_BASE,
  138. SCALER_SRC_CB_BASE,
  139. SCALER_SRC_CR_BASE,
  140. };
  141. int i;
  142. for (i = 0; i < src_buf->format->num_planes; ++i)
  143. scaler_write(src_buf->dma_addr[i], bases[i]);
  144. }
  145. static inline void scaler_set_src_span(struct scaler_context *scaler,
  146. struct exynos_drm_ipp_buffer *src_buf)
  147. {
  148. u32 val;
  149. val = SCALER_SRC_SPAN_SET_Y_SPAN(src_buf->buf.pitch[0] /
  150. src_buf->format->cpp[0]);
  151. if (src_buf->format->num_planes > 1)
  152. val |= SCALER_SRC_SPAN_SET_C_SPAN(src_buf->buf.pitch[1]);
  153. scaler_write(val, SCALER_SRC_SPAN);
  154. }
  155. static inline void scaler_set_src_luma_pos(struct scaler_context *scaler,
  156. struct drm_exynos_ipp_task_rect *src_pos)
  157. {
  158. u32 val;
  159. val = SCALER_SRC_Y_POS_SET_YH_POS(src_pos->x << 2);
  160. val |= SCALER_SRC_Y_POS_SET_YV_POS(src_pos->y << 2);
  161. scaler_write(val, SCALER_SRC_Y_POS);
  162. scaler_write(val, SCALER_SRC_C_POS); /* ATTENTION! */
  163. }
  164. static inline void scaler_set_src_wh(struct scaler_context *scaler,
  165. struct drm_exynos_ipp_task_rect *src_pos)
  166. {
  167. u32 val;
  168. val = SCALER_SRC_WH_SET_WIDTH(src_pos->w);
  169. val |= SCALER_SRC_WH_SET_HEIGHT(src_pos->h);
  170. scaler_write(val, SCALER_SRC_WH);
  171. }
  172. static inline void scaler_set_dst_fmt(struct scaler_context *scaler,
  173. u32 dst_fmt)
  174. {
  175. u32 val;
  176. val = SCALER_DST_CFG_SET_COLOR_FORMAT(dst_fmt);
  177. scaler_write(val, SCALER_DST_CFG);
  178. }
  179. static inline void scaler_set_dst_base(struct scaler_context *scaler,
  180. struct exynos_drm_ipp_buffer *dst_buf)
  181. {
  182. static unsigned int bases[] = {
  183. SCALER_DST_Y_BASE,
  184. SCALER_DST_CB_BASE,
  185. SCALER_DST_CR_BASE,
  186. };
  187. int i;
  188. for (i = 0; i < dst_buf->format->num_planes; ++i)
  189. scaler_write(dst_buf->dma_addr[i], bases[i]);
  190. }
  191. static inline void scaler_set_dst_span(struct scaler_context *scaler,
  192. struct exynos_drm_ipp_buffer *dst_buf)
  193. {
  194. u32 val;
  195. val = SCALER_DST_SPAN_SET_Y_SPAN(dst_buf->buf.pitch[0] /
  196. dst_buf->format->cpp[0]);
  197. if (dst_buf->format->num_planes > 1)
  198. val |= SCALER_DST_SPAN_SET_C_SPAN(dst_buf->buf.pitch[1]);
  199. scaler_write(val, SCALER_DST_SPAN);
  200. }
  201. static inline void scaler_set_dst_luma_pos(struct scaler_context *scaler,
  202. struct drm_exynos_ipp_task_rect *dst_pos)
  203. {
  204. u32 val;
  205. val = SCALER_DST_WH_SET_WIDTH(dst_pos->w);
  206. val |= SCALER_DST_WH_SET_HEIGHT(dst_pos->h);
  207. scaler_write(val, SCALER_DST_WH);
  208. }
  209. static inline void scaler_set_dst_wh(struct scaler_context *scaler,
  210. struct drm_exynos_ipp_task_rect *dst_pos)
  211. {
  212. u32 val;
  213. val = SCALER_DST_POS_SET_H_POS(dst_pos->x);
  214. val |= SCALER_DST_POS_SET_V_POS(dst_pos->y);
  215. scaler_write(val, SCALER_DST_POS);
  216. }
  217. static inline void scaler_set_hv_ratio(struct scaler_context *scaler,
  218. unsigned int rotation,
  219. struct drm_exynos_ipp_task_rect *src_pos,
  220. struct drm_exynos_ipp_task_rect *dst_pos)
  221. {
  222. u32 val, h_ratio, v_ratio;
  223. if (drm_rotation_90_or_270(rotation)) {
  224. h_ratio = (src_pos->h << 16) / dst_pos->w;
  225. v_ratio = (src_pos->w << 16) / dst_pos->h;
  226. } else {
  227. h_ratio = (src_pos->w << 16) / dst_pos->w;
  228. v_ratio = (src_pos->h << 16) / dst_pos->h;
  229. }
  230. val = SCALER_H_RATIO_SET(h_ratio);
  231. scaler_write(val, SCALER_H_RATIO);
  232. val = SCALER_V_RATIO_SET(v_ratio);
  233. scaler_write(val, SCALER_V_RATIO);
  234. }
  235. static inline void scaler_set_rotation(struct scaler_context *scaler,
  236. unsigned int rotation)
  237. {
  238. u32 val = 0;
  239. if (rotation & DRM_MODE_ROTATE_90)
  240. val |= SCALER_ROT_CFG_SET_ROTMODE(SCALER_ROT_MODE_90);
  241. else if (rotation & DRM_MODE_ROTATE_180)
  242. val |= SCALER_ROT_CFG_SET_ROTMODE(SCALER_ROT_MODE_180);
  243. else if (rotation & DRM_MODE_ROTATE_270)
  244. val |= SCALER_ROT_CFG_SET_ROTMODE(SCALER_ROT_MODE_270);
  245. if (rotation & DRM_MODE_REFLECT_X)
  246. val |= SCALER_ROT_CFG_FLIP_X_EN;
  247. if (rotation & DRM_MODE_REFLECT_Y)
  248. val |= SCALER_ROT_CFG_FLIP_Y_EN;
  249. scaler_write(val, SCALER_ROT_CFG);
  250. }
  251. static inline void scaler_set_csc(struct scaler_context *scaler,
  252. const struct drm_format_info *fmt)
  253. {
  254. static const u32 csc_mtx[2][3][3] = {
  255. { /* YCbCr to RGB */
  256. {0x254, 0x000, 0x331},
  257. {0x254, 0xf38, 0xe60},
  258. {0x254, 0x409, 0x000},
  259. },
  260. { /* RGB to YCbCr */
  261. {0x084, 0x102, 0x032},
  262. {0xfb4, 0xf6b, 0x0e1},
  263. {0x0e1, 0xf44, 0xfdc},
  264. },
  265. };
  266. int i, j, dir;
  267. switch (fmt->format) {
  268. case DRM_FORMAT_RGB565:
  269. case DRM_FORMAT_XRGB1555:
  270. case DRM_FORMAT_ARGB1555:
  271. case DRM_FORMAT_XRGB4444:
  272. case DRM_FORMAT_ARGB4444:
  273. case DRM_FORMAT_XRGB8888:
  274. case DRM_FORMAT_ARGB8888:
  275. case DRM_FORMAT_RGBX8888:
  276. case DRM_FORMAT_RGBA8888:
  277. dir = 1;
  278. break;
  279. default:
  280. dir = 0;
  281. }
  282. for (i = 0; i < 3; i++)
  283. for (j = 0; j < 3; j++)
  284. scaler_write(csc_mtx[dir][i][j], SCALER_CSC_COEF(j, i));
  285. }
  286. static inline void scaler_set_timer(struct scaler_context *scaler,
  287. unsigned int timer, unsigned int divider)
  288. {
  289. u32 val;
  290. val = SCALER_TIMEOUT_CTRL_TIMER_ENABLE;
  291. val |= SCALER_TIMEOUT_CTRL_SET_TIMER_VALUE(timer);
  292. val |= SCALER_TIMEOUT_CTRL_SET_TIMER_DIV(divider);
  293. scaler_write(val, SCALER_TIMEOUT_CTRL);
  294. }
  295. static inline void scaler_start_hw(struct scaler_context *scaler)
  296. {
  297. scaler_write(SCALER_CFG_START_CMD, SCALER_CFG);
  298. }
  299. static int scaler_commit(struct exynos_drm_ipp *ipp,
  300. struct exynos_drm_ipp_task *task)
  301. {
  302. struct scaler_context *scaler =
  303. container_of(ipp, struct scaler_context, ipp);
  304. u32 src_fmt = scaler_get_format(task->src.buf.fourcc);
  305. struct drm_exynos_ipp_task_rect *src_pos = &task->src.rect;
  306. u32 dst_fmt = scaler_get_format(task->dst.buf.fourcc);
  307. struct drm_exynos_ipp_task_rect *dst_pos = &task->dst.rect;
  308. scaler->task = task;
  309. pm_runtime_get_sync(scaler->dev);
  310. scaler_set_src_fmt(scaler, src_fmt);
  311. scaler_set_src_base(scaler, &task->src);
  312. scaler_set_src_span(scaler, &task->src);
  313. scaler_set_src_luma_pos(scaler, src_pos);
  314. scaler_set_src_wh(scaler, src_pos);
  315. scaler_set_dst_fmt(scaler, dst_fmt);
  316. scaler_set_dst_base(scaler, &task->dst);
  317. scaler_set_dst_span(scaler, &task->dst);
  318. scaler_set_dst_luma_pos(scaler, dst_pos);
  319. scaler_set_dst_wh(scaler, dst_pos);
  320. scaler_set_hv_ratio(scaler, task->transform.rotation, src_pos, dst_pos);
  321. scaler_set_rotation(scaler, task->transform.rotation);
  322. scaler_set_csc(scaler, task->src.format);
  323. scaler_set_timer(scaler, 0xffff, 0xf);
  324. scaler_enable_int(scaler);
  325. scaler_start_hw(scaler);
  326. return 0;
  327. }
  328. static struct exynos_drm_ipp_funcs ipp_funcs = {
  329. .commit = scaler_commit,
  330. };
  331. static inline void scaler_disable_int(struct scaler_context *scaler)
  332. {
  333. scaler_write(0, SCALER_INT_EN);
  334. }
  335. static inline u32 scaler_get_int_status(struct scaler_context *scaler)
  336. {
  337. return scaler_read(SCALER_INT_STATUS);
  338. }
  339. static inline bool scaler_task_done(u32 val)
  340. {
  341. return val & SCALER_INT_STATUS_FRAME_END ? 0 : -EINVAL;
  342. }
  343. static irqreturn_t scaler_irq_handler(int irq, void *arg)
  344. {
  345. struct scaler_context *scaler = arg;
  346. u32 val = scaler_get_int_status(scaler);
  347. scaler_disable_int(scaler);
  348. if (scaler->task) {
  349. struct exynos_drm_ipp_task *task = scaler->task;
  350. scaler->task = NULL;
  351. pm_runtime_mark_last_busy(scaler->dev);
  352. pm_runtime_put_autosuspend(scaler->dev);
  353. exynos_drm_ipp_task_done(task, scaler_task_done(val));
  354. }
  355. return IRQ_HANDLED;
  356. }
  357. static int scaler_bind(struct device *dev, struct device *master, void *data)
  358. {
  359. struct scaler_context *scaler = dev_get_drvdata(dev);
  360. struct drm_device *drm_dev = data;
  361. struct exynos_drm_ipp *ipp = &scaler->ipp;
  362. scaler->drm_dev = drm_dev;
  363. drm_iommu_attach_device(drm_dev, dev);
  364. exynos_drm_ipp_register(drm_dev, ipp, &ipp_funcs,
  365. DRM_EXYNOS_IPP_CAP_CROP | DRM_EXYNOS_IPP_CAP_ROTATE |
  366. DRM_EXYNOS_IPP_CAP_SCALE | DRM_EXYNOS_IPP_CAP_CONVERT,
  367. scaler->scaler_data->formats,
  368. scaler->scaler_data->num_formats, "scaler");
  369. dev_info(dev, "The exynos scaler has been probed successfully\n");
  370. return 0;
  371. }
  372. static void scaler_unbind(struct device *dev, struct device *master,
  373. void *data)
  374. {
  375. struct scaler_context *scaler = dev_get_drvdata(dev);
  376. struct drm_device *drm_dev = data;
  377. struct exynos_drm_ipp *ipp = &scaler->ipp;
  378. exynos_drm_ipp_unregister(drm_dev, ipp);
  379. drm_iommu_detach_device(scaler->drm_dev, scaler->dev);
  380. }
  381. static const struct component_ops scaler_component_ops = {
  382. .bind = scaler_bind,
  383. .unbind = scaler_unbind,
  384. };
  385. static int scaler_probe(struct platform_device *pdev)
  386. {
  387. struct device *dev = &pdev->dev;
  388. struct resource *regs_res;
  389. struct scaler_context *scaler;
  390. int irq;
  391. int ret, i;
  392. scaler = devm_kzalloc(dev, sizeof(*scaler), GFP_KERNEL);
  393. if (!scaler)
  394. return -ENOMEM;
  395. scaler->scaler_data =
  396. (struct scaler_data *)of_device_get_match_data(dev);
  397. scaler->dev = dev;
  398. regs_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  399. scaler->regs = devm_ioremap_resource(dev, regs_res);
  400. if (IS_ERR(scaler->regs))
  401. return PTR_ERR(scaler->regs);
  402. irq = platform_get_irq(pdev, 0);
  403. if (irq < 0) {
  404. dev_err(dev, "failed to get irq\n");
  405. return irq;
  406. }
  407. ret = devm_request_threaded_irq(dev, irq, NULL, scaler_irq_handler,
  408. IRQF_ONESHOT, "drm_scaler", scaler);
  409. if (ret < 0) {
  410. dev_err(dev, "failed to request irq\n");
  411. return ret;
  412. }
  413. for (i = 0; i < scaler->scaler_data->num_clk; ++i) {
  414. scaler->clock[i] = devm_clk_get(dev,
  415. scaler->scaler_data->clk_name[i]);
  416. if (IS_ERR(scaler->clock[i])) {
  417. dev_err(dev, "failed to get clock\n");
  418. return PTR_ERR(scaler->clock[i]);
  419. }
  420. }
  421. pm_runtime_use_autosuspend(dev);
  422. pm_runtime_set_autosuspend_delay(dev, SCALER_AUTOSUSPEND_DELAY);
  423. pm_runtime_enable(dev);
  424. platform_set_drvdata(pdev, scaler);
  425. ret = component_add(dev, &scaler_component_ops);
  426. if (ret)
  427. goto err_ippdrv_register;
  428. return 0;
  429. err_ippdrv_register:
  430. pm_runtime_dont_use_autosuspend(dev);
  431. pm_runtime_disable(dev);
  432. return ret;
  433. }
  434. static int scaler_remove(struct platform_device *pdev)
  435. {
  436. struct device *dev = &pdev->dev;
  437. component_del(dev, &scaler_component_ops);
  438. pm_runtime_dont_use_autosuspend(dev);
  439. pm_runtime_disable(dev);
  440. return 0;
  441. }
  442. #ifdef CONFIG_PM
  443. static int clk_disable_unprepare_wrapper(struct clk *clk)
  444. {
  445. clk_disable_unprepare(clk);
  446. return 0;
  447. }
  448. static int scaler_clk_ctrl(struct scaler_context *scaler, bool enable)
  449. {
  450. int (*clk_fun)(struct clk *clk), i;
  451. clk_fun = enable ? clk_prepare_enable : clk_disable_unprepare_wrapper;
  452. for (i = 0; i < scaler->scaler_data->num_clk; ++i)
  453. clk_fun(scaler->clock[i]);
  454. return 0;
  455. }
  456. static int scaler_runtime_suspend(struct device *dev)
  457. {
  458. struct scaler_context *scaler = dev_get_drvdata(dev);
  459. return scaler_clk_ctrl(scaler, false);
  460. }
  461. static int scaler_runtime_resume(struct device *dev)
  462. {
  463. struct scaler_context *scaler = dev_get_drvdata(dev);
  464. return scaler_clk_ctrl(scaler, true);
  465. }
  466. #endif
  467. static const struct dev_pm_ops scaler_pm_ops = {
  468. SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
  469. pm_runtime_force_resume)
  470. SET_RUNTIME_PM_OPS(scaler_runtime_suspend, scaler_runtime_resume, NULL)
  471. };
  472. static const struct drm_exynos_ipp_limit scaler_5420_two_pixel_hv_limits[] = {
  473. { IPP_SIZE_LIMIT(BUFFER, .h = { 16, SZ_8K }, .v = { 16, SZ_8K }) },
  474. { IPP_SIZE_LIMIT(AREA, .h.align = 2, .v.align = 2) },
  475. { IPP_SCALE_LIMIT(.h = { 65536 * 1 / 4, 65536 * 16 },
  476. .v = { 65536 * 1 / 4, 65536 * 16 }) },
  477. };
  478. static const struct drm_exynos_ipp_limit scaler_5420_two_pixel_h_limits[] = {
  479. { IPP_SIZE_LIMIT(BUFFER, .h = { 16, SZ_8K }, .v = { 16, SZ_8K }) },
  480. { IPP_SIZE_LIMIT(AREA, .h.align = 2, .v.align = 1) },
  481. { IPP_SCALE_LIMIT(.h = { 65536 * 1 / 4, 65536 * 16 },
  482. .v = { 65536 * 1 / 4, 65536 * 16 }) },
  483. };
  484. static const struct drm_exynos_ipp_limit scaler_5420_one_pixel_limits[] = {
  485. { IPP_SIZE_LIMIT(BUFFER, .h = { 16, SZ_8K }, .v = { 16, SZ_8K }) },
  486. { IPP_SCALE_LIMIT(.h = { 65536 * 1 / 4, 65536 * 16 },
  487. .v = { 65536 * 1 / 4, 65536 * 16 }) },
  488. };
  489. static const struct exynos_drm_ipp_formats exynos5420_formats[] = {
  490. /* SCALER_YUV420_2P_UV */
  491. { IPP_SRCDST_FORMAT(NV21, scaler_5420_two_pixel_hv_limits) },
  492. /* SCALER_YUV420_2P_VU */
  493. { IPP_SRCDST_FORMAT(NV12, scaler_5420_two_pixel_hv_limits) },
  494. /* SCALER_YUV420_3P */
  495. { IPP_SRCDST_FORMAT(YUV420, scaler_5420_two_pixel_hv_limits) },
  496. /* SCALER_YUV422_1P_YUYV */
  497. { IPP_SRCDST_FORMAT(YUYV, scaler_5420_two_pixel_h_limits) },
  498. /* SCALER_YUV422_1P_UYVY */
  499. { IPP_SRCDST_FORMAT(UYVY, scaler_5420_two_pixel_h_limits) },
  500. /* SCALER_YUV422_1P_YVYU */
  501. { IPP_SRCDST_FORMAT(YVYU, scaler_5420_two_pixel_h_limits) },
  502. /* SCALER_YUV422_2P_UV */
  503. { IPP_SRCDST_FORMAT(NV61, scaler_5420_two_pixel_h_limits) },
  504. /* SCALER_YUV422_2P_VU */
  505. { IPP_SRCDST_FORMAT(NV16, scaler_5420_two_pixel_h_limits) },
  506. /* SCALER_YUV422_3P */
  507. { IPP_SRCDST_FORMAT(YUV422, scaler_5420_two_pixel_h_limits) },
  508. /* SCALER_YUV444_2P_UV */
  509. { IPP_SRCDST_FORMAT(NV42, scaler_5420_one_pixel_limits) },
  510. /* SCALER_YUV444_2P_VU */
  511. { IPP_SRCDST_FORMAT(NV24, scaler_5420_one_pixel_limits) },
  512. /* SCALER_YUV444_3P */
  513. { IPP_SRCDST_FORMAT(YUV444, scaler_5420_one_pixel_limits) },
  514. /* SCALER_RGB_565 */
  515. { IPP_SRCDST_FORMAT(RGB565, scaler_5420_one_pixel_limits) },
  516. /* SCALER_ARGB1555 */
  517. { IPP_SRCDST_FORMAT(XRGB1555, scaler_5420_one_pixel_limits) },
  518. /* SCALER_ARGB1555 */
  519. { IPP_SRCDST_FORMAT(ARGB1555, scaler_5420_one_pixel_limits) },
  520. /* SCALER_ARGB4444 */
  521. { IPP_SRCDST_FORMAT(XRGB4444, scaler_5420_one_pixel_limits) },
  522. /* SCALER_ARGB4444 */
  523. { IPP_SRCDST_FORMAT(ARGB4444, scaler_5420_one_pixel_limits) },
  524. /* SCALER_ARGB8888 */
  525. { IPP_SRCDST_FORMAT(XRGB8888, scaler_5420_one_pixel_limits) },
  526. /* SCALER_ARGB8888 */
  527. { IPP_SRCDST_FORMAT(ARGB8888, scaler_5420_one_pixel_limits) },
  528. /* SCALER_RGBA8888 */
  529. { IPP_SRCDST_FORMAT(RGBX8888, scaler_5420_one_pixel_limits) },
  530. /* SCALER_RGBA8888 */
  531. { IPP_SRCDST_FORMAT(RGBA8888, scaler_5420_one_pixel_limits) },
  532. };
  533. static const struct scaler_data exynos5420_data = {
  534. .clk_name = {"mscl"},
  535. .num_clk = 1,
  536. .formats = exynos5420_formats,
  537. .num_formats = ARRAY_SIZE(exynos5420_formats),
  538. };
  539. static const struct scaler_data exynos5433_data = {
  540. .clk_name = {"pclk", "aclk", "aclk_xiu"},
  541. .num_clk = 3,
  542. .formats = exynos5420_formats, /* intentional */
  543. .num_formats = ARRAY_SIZE(exynos5420_formats),
  544. };
  545. static const struct of_device_id exynos_scaler_match[] = {
  546. {
  547. .compatible = "samsung,exynos5420-scaler",
  548. .data = &exynos5420_data,
  549. }, {
  550. .compatible = "samsung,exynos5433-scaler",
  551. .data = &exynos5433_data,
  552. }, {
  553. },
  554. };
  555. MODULE_DEVICE_TABLE(of, exynos_scaler_match);
  556. struct platform_driver scaler_driver = {
  557. .probe = scaler_probe,
  558. .remove = scaler_remove,
  559. .driver = {
  560. .name = "exynos-scaler",
  561. .owner = THIS_MODULE,
  562. .pm = &scaler_pm_ops,
  563. .of_match_table = exynos_scaler_match,
  564. },
  565. };