Lines Matching +full:p +full:- +full:states

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2011 Texas Instruments Incorporated - https://www.ti.com/
7 #include <linux/dma-mapping.h>
57 if (!new_crtc_state->active) in omap_atomic_wait_for_completion()
63 dev_warn(dev->dev, in omap_atomic_wait_for_completion()
70 struct drm_device *dev = old_state->dev; in omap_atomic_commit_tail()
71 struct omap_drm_private *priv = dev->dev_private; in omap_atomic_commit_tail()
73 dispc_runtime_get(priv->dispc); in omap_atomic_commit_tail()
78 if (priv->omaprev != 0x3430) { in omap_atomic_commit_tail()
98 * OMAP3 DSS seems to have issues with the work-around above, in omap_atomic_commit_tail()
117 dispc_runtime_put(priv->dispc); in omap_atomic_commit_tail()
125 if (sa->normalized_zpos != sb->normalized_zpos) in drm_atomic_state_normalized_zpos_cmp()
126 return sa->normalized_zpos - sb->normalized_zpos; in drm_atomic_state_normalized_zpos_cmp()
128 return sa->plane->base.id - sb->plane->base.id; in drm_atomic_state_normalized_zpos_cmp()
145 int total_planes = dev->mode_config.num_total_plane; in omap_atomic_update_normalize_zpos()
146 struct drm_plane_state **states; in omap_atomic_update_normalize_zpos() local
149 states = kmalloc_array(total_planes, sizeof(*states), GFP_KERNEL); in omap_atomic_update_normalize_zpos()
150 if (!states) in omap_atomic_update_normalize_zpos()
151 return -ENOMEM; in omap_atomic_update_normalize_zpos()
154 if (old_state->plane_mask == new_state->plane_mask && in omap_atomic_update_normalize_zpos()
155 !new_state->zpos_changed) in omap_atomic_update_normalize_zpos()
162 * Normalization process might create new states for planes in omap_atomic_update_normalize_zpos()
165 drm_for_each_plane_mask(plane, dev, new_state->plane_mask) { in omap_atomic_update_normalize_zpos()
167 drm_atomic_get_plane_state(new_state->state, in omap_atomic_update_normalize_zpos()
173 states[n++] = plane_state; in omap_atomic_update_normalize_zpos()
176 sort(states, n, sizeof(*states), in omap_atomic_update_normalize_zpos()
180 plane = states[i]->plane; in omap_atomic_update_normalize_zpos()
182 states[i]->normalized_zpos = i + inc; in omap_atomic_update_normalize_zpos()
184 plane->base.id, plane->name, in omap_atomic_update_normalize_zpos()
185 states[i]->normalized_zpos); in omap_atomic_update_normalize_zpos()
187 if (is_omap_plane_dual_overlay(states[i])) in omap_atomic_update_normalize_zpos()
190 new_state->zpos_changed = true; in omap_atomic_update_normalize_zpos()
194 kfree(states); in omap_atomic_update_normalize_zpos()
207 if (dev->mode_config.normalize_zpos) { in omap_atomic_check()
236 return to_omap_global_state(priv->glob_obj.state); in omap_get_existing_global_state()
246 struct omap_drm_private *priv = s->dev->dev_private; in omap_get_global_state()
249 priv_state = drm_atomic_get_private_obj_state(s, &priv->glob_obj); in omap_get_global_state()
261 state = kmemdup(obj->state, sizeof(*state), GFP_KERNEL); in omap_global_duplicate_state()
265 __drm_atomic_helper_private_obj_duplicate_state(obj, &state->base); in omap_global_duplicate_state()
267 return &state->base; in omap_global_duplicate_state()
285 struct omap_drm_private *priv = dev->dev_private; in omap_global_obj_init()
290 return -ENOMEM; in omap_global_obj_init()
292 drm_atomic_private_obj_init(dev, &priv->glob_obj, &state->base, in omap_global_obj_init()
299 drm_atomic_private_obj_fini(&priv->glob_obj); in omap_global_obj_fini()
304 struct omap_drm_private *priv = ddev->dev_private; in omap_disconnect_pipelines()
307 for (i = 0; i < priv->num_pipes; i++) { in omap_disconnect_pipelines()
308 struct omap_drm_pipeline *pipe = &priv->pipes[i]; in omap_disconnect_pipelines()
310 omapdss_device_disconnect(priv->dss, pipe->output); in omap_disconnect_pipelines()
312 omapdss_device_put(pipe->output); in omap_disconnect_pipelines()
313 pipe->output = NULL; in omap_disconnect_pipelines()
316 memset(&priv->channels, 0, sizeof(priv->channels)); in omap_disconnect_pipelines()
318 priv->num_pipes = 0; in omap_disconnect_pipelines()
323 struct omap_drm_private *priv = ddev->dev_private; in omap_connect_pipelines()
328 r = omapdss_device_connect(priv->dss, output); in omap_connect_pipelines()
329 if (r == -EPROBE_DEFER) { in omap_connect_pipelines()
333 dev_warn(output->dev, "could not connect output %s\n", in omap_connect_pipelines()
334 output->name); in omap_connect_pipelines()
338 pipe = &priv->pipes[priv->num_pipes++]; in omap_connect_pipelines()
339 pipe->output = omapdss_device_get(output); in omap_connect_pipelines()
341 if (priv->num_pipes == ARRAY_SIZE(priv->pipes)) { in omap_connect_pipelines()
357 if (pipe1->alias_id > pipe2->alias_id) in omap_compare_pipelines()
359 else if (pipe1->alias_id < pipe2->alias_id) in omap_compare_pipelines()
360 return -1; in omap_compare_pipelines()
366 struct omap_drm_private *priv = dev->dev_private; in omap_modeset_init_properties()
367 unsigned int num_planes = dispc_get_num_ovls(priv->dispc); in omap_modeset_init_properties()
369 priv->zorder_prop = drm_property_create_range(dev, 0, "zorder", 0, in omap_modeset_init_properties()
370 num_planes - 1); in omap_modeset_init_properties()
371 if (!priv->zorder_prop) in omap_modeset_init_properties()
372 return -ENOMEM; in omap_modeset_init_properties()
381 if (output->bridge) { in omap_display_id()
382 struct drm_bridge *bridge = output->bridge; in omap_display_id()
387 node = bridge->of_node; in omap_display_id()
390 return node ? of_alias_get_id(node, "display") : -ENODEV; in omap_display_id()
395 struct omap_drm_private *priv = dev->dev_private; in omap_modeset_init()
396 int num_ovls = dispc_get_num_ovls(priv->dispc); in omap_modeset_init()
397 int num_mgrs = dispc_get_num_mgrs(priv->dispc); in omap_modeset_init()
403 return -EPROBE_DEFER; in omap_modeset_init()
411 * and primary plane per each connected dss-device. Each in omap_modeset_init()
412 * connector->encoder->crtc chain is expected to be separate in omap_modeset_init()
413 * and each crtc is connect to a single dss-channel. If the in omap_modeset_init()
421 if (priv->num_pipes > num_mgrs || priv->num_pipes > num_ovls) { in omap_modeset_init()
422 dev_err(dev->dev, "%s(): Too many connected displays\n", in omap_modeset_init()
424 return -EINVAL; in omap_modeset_init()
428 plane_crtc_mask = (1 << priv->num_pipes) - 1; in omap_modeset_init()
431 enum drm_plane_type type = i < priv->num_pipes in omap_modeset_init()
436 if (WARN_ON(priv->num_planes >= ARRAY_SIZE(priv->planes))) in omap_modeset_init()
437 return -EINVAL; in omap_modeset_init()
443 priv->planes[priv->num_planes++] = plane; in omap_modeset_init()
450 for (i = 0; i < priv->num_pipes; i++) { in omap_modeset_init()
451 struct omap_drm_pipeline *pipe = &priv->pipes[i]; in omap_modeset_init()
454 pipe->encoder = omap_encoder_init(dev, pipe->output); in omap_modeset_init()
455 if (!pipe->encoder) in omap_modeset_init()
456 return -ENOMEM; in omap_modeset_init()
458 if (pipe->output->bridge) { in omap_modeset_init()
459 ret = drm_bridge_attach(pipe->encoder, in omap_modeset_init()
460 pipe->output->bridge, NULL, in omap_modeset_init()
466 id = omap_display_id(pipe->output); in omap_modeset_init()
467 pipe->alias_id = id >= 0 ? id : i; in omap_modeset_init()
471 sort(priv->pipes, priv->num_pipes, sizeof(priv->pipes[0]), in omap_modeset_init()
478 for (i = 0; i < priv->num_pipes; ++i) { in omap_modeset_init()
479 struct omap_drm_pipeline *pipe = &priv->pipes[i]; in omap_modeset_init()
480 enum omap_channel channel = pipe->output->dispc_channel; in omap_modeset_init()
482 if (WARN_ON(priv->channels[channel] != NULL)) in omap_modeset_init()
483 return -EINVAL; in omap_modeset_init()
485 priv->channels[channel] = pipe; in omap_modeset_init()
489 for (i = 0; i < priv->num_pipes; i++) { in omap_modeset_init()
490 struct omap_drm_pipeline *pipe = &priv->pipes[i]; in omap_modeset_init()
491 struct drm_encoder *encoder = pipe->encoder; in omap_modeset_init()
494 pipe->connector = drm_bridge_connector_init(dev, encoder); in omap_modeset_init()
495 if (IS_ERR(pipe->connector)) { in omap_modeset_init()
496 dev_err(priv->dev, in omap_modeset_init()
498 pipe->output->name); in omap_modeset_init()
499 return PTR_ERR(pipe->connector); in omap_modeset_init()
502 drm_connector_attach_encoder(pipe->connector, encoder); in omap_modeset_init()
504 crtc = omap_crtc_init(dev, pipe, priv->planes[i]); in omap_modeset_init()
508 encoder->possible_crtcs = 1 << i; in omap_modeset_init()
509 pipe->crtc = crtc; in omap_modeset_init()
513 priv->num_planes, priv->num_pipes); in omap_modeset_init()
515 dev->mode_config.min_width = 8; in omap_modeset_init()
516 dev->mode_config.min_height = 2; in omap_modeset_init()
524 dev->mode_config.max_width = 8192; in omap_modeset_init()
525 dev->mode_config.max_height = 8192; in omap_modeset_init()
528 dev->mode_config.normalize_zpos = true; in omap_modeset_init()
530 dev->mode_config.funcs = &omap_mode_config_funcs; in omap_modeset_init()
531 dev->mode_config.helper_private = &omap_mode_config_helper_funcs; in omap_modeset_init()
555 struct omap_drm_private *priv = dev->dev_private; in ioctl_get_param()
558 DBG("%p: param=%llu", dev, args->param); in ioctl_get_param()
560 switch (args->param) { in ioctl_get_param()
562 args->value = priv->omaprev; in ioctl_get_param()
565 DBG("unknown parameter %lld", args->param); in ioctl_get_param()
566 return -EINVAL; in ioctl_get_param()
578 u32 flags = args->flags & OMAP_BO_USER_MASK; in ioctl_gem_new()
580 VERB("%p:%p: size=0x%08x, flags=%08x", dev, file_priv, in ioctl_gem_new()
581 args->size.bytes, flags); in ioctl_gem_new()
583 return omap_gem_new_handle(dev, file_priv, args->size, flags, in ioctl_gem_new()
584 &args->handle); in ioctl_gem_new()
594 VERB("%p:%p: handle=%d", dev, file_priv, args->handle); in ioctl_gem_info()
596 obj = drm_gem_object_lookup(file_priv, args->handle); in ioctl_gem_info()
598 return -ENOENT; in ioctl_gem_info()
600 args->size = omap_gem_mmap_size(obj); in ioctl_gem_info()
601 args->offset = omap_gem_mmap_offset(obj); in ioctl_gem_info()
608 static const struct drm_ioctl_desc ioctls[DRM_COMMAND_END - DRM_COMMAND_BASE] = {
631 file->driver_priv = NULL; in dev_open()
633 DBG("open: dev=%p, file=%p", dev, file); in dev_open()
673 struct dss_pdata *pdata = dev->platform_data; in omapdrm_init()
680 return -ENODEV; in omapdrm_init()
687 priv->ddev = ddev; in omapdrm_init()
688 ddev->dev_private = priv; in omapdrm_init()
690 priv->dev = dev; in omapdrm_init()
691 priv->dss = pdata->dss; in omapdrm_init()
692 priv->dispc = dispc_get_dispc(priv->dss); in omapdrm_init()
694 priv->dss->mgr_ops_priv = priv; in omapdrm_init()
697 priv->omaprev = soc ? (uintptr_t)soc->data : 0; in omapdrm_init()
698 priv->wq = alloc_ordered_workqueue("omapdrm", 0); in omapdrm_init()
699 if (!priv->wq) { in omapdrm_init()
700 ret = -ENOMEM; in omapdrm_init()
704 mutex_init(&priv->list_lock); in omapdrm_init()
705 INIT_LIST_HEAD(&priv->obj_list); in omapdrm_init()
708 priv->max_bandwidth = dispc_get_memory_bandwidth_limit(priv->dispc); in omapdrm_init()
724 dev_err(priv->dev, "omap_modeset_init failed: ret=%d\n", ret); in omapdrm_init()
729 ret = drm_vblank_init(ddev, priv->num_pipes); in omapdrm_init()
731 dev_err(priv->dev, "could not init vblank\n"); in omapdrm_init()
760 destroy_workqueue(priv->wq); in omapdrm_init()
769 struct drm_device *ddev = priv->ddev; in omapdrm_cleanup()
785 destroy_workqueue(priv->wq); in omapdrm_cleanup()
797 ret = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in pdev_probe()
799 dev_err(&pdev->dev, "Failed to set the DMA mask\n"); in pdev_probe()
806 return -ENOMEM; in pdev_probe()
810 ret = omapdrm_init(priv, &pdev->dev); in pdev_probe()
829 drm_atomic_helper_shutdown(priv->ddev); in pdev_shutdown()
836 struct drm_device *drm_dev = priv->ddev; in omap_drm_suspend()
844 struct drm_device *drm_dev = priv->ddev; in omap_drm_resume()