Lines Matching +full:s +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0
9 #include <linux/dma-mapping.h>
61 * @pixmap: pixmap dma buffer (clut8-format cursor)
80 #define DBGFS_DUMP(reg) seq_printf(s, "\n %-25s 0x%08X", #reg, \
81 readl(cursor->regs + reg))
83 static void cursor_dbg_vpo(struct seq_file *s, u32 val) in cursor_dbg_vpo() argument
85 seq_printf(s, "\txdo:%4d\tydo:%4d", val & 0x0FFF, (val >> 16) & 0x0FFF); in cursor_dbg_vpo()
88 static void cursor_dbg_size(struct seq_file *s, u32 val) in cursor_dbg_size() argument
90 seq_printf(s, "\t%d x %d", val & 0x07FF, (val >> 16) & 0x07FF); in cursor_dbg_size()
93 static void cursor_dbg_pml(struct seq_file *s, in cursor_dbg_pml() argument
96 if (cursor->pixmap.paddr == val) in cursor_dbg_pml()
97 seq_printf(s, "\tVirt @: %p", cursor->pixmap.base); in cursor_dbg_pml()
100 static void cursor_dbg_cml(struct seq_file *s, in cursor_dbg_cml() argument
103 if (cursor->clut_paddr == val) in cursor_dbg_cml()
104 seq_printf(s, "\tVirt @: %p", cursor->clut); in cursor_dbg_cml()
107 static int cursor_dbg_show(struct seq_file *s, void *data) in cursor_dbg_show() argument
109 struct drm_info_node *node = s->private; in cursor_dbg_show()
110 struct sti_cursor *cursor = (struct sti_cursor *)node->info_ent->data; in cursor_dbg_show()
112 seq_printf(s, "%s: (vaddr = 0x%p)", in cursor_dbg_show()
113 sti_plane_to_str(&cursor->plane), cursor->regs); in cursor_dbg_show()
117 cursor_dbg_vpo(s, readl(cursor->regs + CUR_VPO)); in cursor_dbg_show()
119 cursor_dbg_pml(s, cursor, readl(cursor->regs + CUR_PML)); in cursor_dbg_show()
122 cursor_dbg_size(s, readl(cursor->regs + CUR_SIZE)); in cursor_dbg_show()
124 cursor_dbg_cml(s, cursor, readl(cursor->regs + CUR_CML)); in cursor_dbg_show()
127 seq_putc(s, '\n'); in cursor_dbg_show()
145 minor->debugfs_root, minor); in cursor_debugfs_init()
150 u8 *dst = cursor->pixmap.base; in sti_cursor_argb8888_to_clut8()
154 for (i = 0; i < cursor->height; i++) { in sti_cursor_argb8888_to_clut8()
155 for (j = 0; j < cursor->width; j++) { in sti_cursor_argb8888_to_clut8()
170 unsigned short *base = cursor->clut; in sti_cursor_init()
191 struct drm_crtc *crtc = new_plane_state->crtc; in sti_cursor_atomic_check()
192 struct drm_framebuffer *fb = new_plane_state->fb; in sti_cursor_atomic_check()
194 struct drm_display_mode *mode; in sti_cursor_atomic_check() local
203 mode = &crtc_state->mode; in sti_cursor_atomic_check()
204 dst_x = new_plane_state->crtc_x; in sti_cursor_atomic_check()
205 dst_y = new_plane_state->crtc_y; in sti_cursor_atomic_check()
206 dst_w = clamp_val(new_plane_state->crtc_w, 0, in sti_cursor_atomic_check()
207 mode->crtc_hdisplay - dst_x); in sti_cursor_atomic_check()
208 dst_h = clamp_val(new_plane_state->crtc_h, 0, in sti_cursor_atomic_check()
209 mode->crtc_vdisplay - dst_y); in sti_cursor_atomic_check()
211 src_w = new_plane_state->src_w >> 16; in sti_cursor_atomic_check()
212 src_h = new_plane_state->src_h >> 16; in sti_cursor_atomic_check()
220 return -EINVAL; in sti_cursor_atomic_check()
223 /* If the cursor size has changed, re-allocated the pixmap */ in sti_cursor_atomic_check()
224 if (!cursor->pixmap.base || in sti_cursor_atomic_check()
225 (cursor->width != src_w) || in sti_cursor_atomic_check()
226 (cursor->height != src_h)) { in sti_cursor_atomic_check()
227 cursor->width = src_w; in sti_cursor_atomic_check()
228 cursor->height = src_h; in sti_cursor_atomic_check()
230 if (cursor->pixmap.base) in sti_cursor_atomic_check()
231 dma_free_wc(cursor->dev, cursor->pixmap.size, in sti_cursor_atomic_check()
232 cursor->pixmap.base, cursor->pixmap.paddr); in sti_cursor_atomic_check()
234 cursor->pixmap.size = cursor->width * cursor->height; in sti_cursor_atomic_check()
236 cursor->pixmap.base = dma_alloc_wc(cursor->dev, in sti_cursor_atomic_check()
237 cursor->pixmap.size, in sti_cursor_atomic_check()
238 &cursor->pixmap.paddr, in sti_cursor_atomic_check()
240 if (!cursor->pixmap.base) { in sti_cursor_atomic_check()
242 return -EINVAL; in sti_cursor_atomic_check()
248 return -EINVAL; in sti_cursor_atomic_check()
251 DRM_DEBUG_KMS("CRTC:%d (%s) drm plane:%d (%s)\n", in sti_cursor_atomic_check()
252 crtc->base.id, sti_mixer_to_str(to_sti_mixer(crtc)), in sti_cursor_atomic_check()
253 drm_plane->base.id, sti_plane_to_str(plane)); in sti_cursor_atomic_check()
266 struct drm_crtc *crtc = newstate->crtc; in sti_cursor_atomic_update()
267 struct drm_framebuffer *fb = newstate->fb; in sti_cursor_atomic_update()
268 struct drm_display_mode *mode; in sti_cursor_atomic_update() local
277 mode = &crtc->mode; in sti_cursor_atomic_update()
278 dst_x = newstate->crtc_x; in sti_cursor_atomic_update()
279 dst_y = newstate->crtc_y; in sti_cursor_atomic_update()
284 sti_cursor_argb8888_to_clut8(cursor, (u32 *)dma_obj->vaddr); in sti_cursor_atomic_update()
286 /* AWS and AWE depend on the mode */ in sti_cursor_atomic_update()
287 y = sti_vtg_get_line_number(*mode, 0); in sti_cursor_atomic_update()
288 x = sti_vtg_get_pixel_number(*mode, 0); in sti_cursor_atomic_update()
290 writel(val, cursor->regs + CUR_AWS); in sti_cursor_atomic_update()
291 y = sti_vtg_get_line_number(*mode, mode->vdisplay - 1); in sti_cursor_atomic_update()
292 x = sti_vtg_get_pixel_number(*mode, mode->hdisplay - 1); in sti_cursor_atomic_update()
294 writel(val, cursor->regs + CUR_AWE); in sti_cursor_atomic_update()
297 writel(cursor->pixmap.paddr, cursor->regs + CUR_PML); in sti_cursor_atomic_update()
298 writel(cursor->width, cursor->regs + CUR_PMP); in sti_cursor_atomic_update()
299 writel(cursor->height << 16 | cursor->width, cursor->regs + CUR_SIZE); in sti_cursor_atomic_update()
301 y = sti_vtg_get_line_number(*mode, dst_y); in sti_cursor_atomic_update()
302 x = sti_vtg_get_pixel_number(*mode, dst_x); in sti_cursor_atomic_update()
303 writel((y << 16) | x, cursor->regs + CUR_VPO); in sti_cursor_atomic_update()
306 writel(cursor->clut_paddr, cursor->regs + CUR_CML); in sti_cursor_atomic_update()
307 writel(CUR_CTL_CLUT_UPDATE, cursor->regs + CUR_CTL); in sti_cursor_atomic_update()
311 plane->status = STI_PLANE_UPDATED; in sti_cursor_atomic_update()
321 if (!oldstate->crtc) { in sti_cursor_atomic_disable()
323 drm_plane->base.id); in sti_cursor_atomic_disable()
327 DRM_DEBUG_DRIVER("CRTC:%d (%s) drm plane:%d (%s)\n", in sti_cursor_atomic_disable()
328 oldstate->crtc->base.id, in sti_cursor_atomic_disable()
329 sti_mixer_to_str(to_sti_mixer(oldstate->crtc)), in sti_cursor_atomic_disable()
330 drm_plane->base.id, sti_plane_to_str(plane)); in sti_cursor_atomic_disable()
332 plane->status = STI_PLANE_DISABLING; in sti_cursor_atomic_disable()
346 cursor_debugfs_init(cursor, drm_plane->dev->primary); in sti_cursor_late_register()
378 cursor->clut = dma_alloc_wc(dev, size, &cursor->clut_paddr, in sti_cursor_create()
381 if (!cursor->clut) { in sti_cursor_create()
386 cursor->dev = dev; in sti_cursor_create()
387 cursor->regs = baseaddr; in sti_cursor_create()
388 cursor->plane.desc = desc; in sti_cursor_create()
389 cursor->plane.status = STI_PLANE_DISABLED; in sti_cursor_create()
393 res = drm_universal_plane_init(drm_dev, &cursor->plane.drm_plane, in sti_cursor_create()
404 drm_plane_helper_add(&cursor->plane.drm_plane, in sti_cursor_create()
407 sti_plane_init_property(&cursor->plane, DRM_PLANE_TYPE_CURSOR); in sti_cursor_create()
409 return &cursor->plane.drm_plane; in sti_cursor_create()
412 dma_free_wc(dev, size, cursor->clut, cursor->clut_paddr); in sti_cursor_create()