Lines Matching +full:native +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0-only
26 #define DRIVER_DESC "DRM driver for simple-framebuffer platform devices"
52 return -EINVAL; in simplefb_get_validated_int()
64 return -EINVAL; in simplefb_get_validated_int0()
79 return ERR_PTR(-EINVAL); in simplefb_get_validated_format()
83 if (!strcmp(format_name, fmt->name)) { in simplefb_get_validated_format()
84 info = drm_format_info(fmt->fourcc); in simplefb_get_validated_format()
86 return ERR_PTR(-EINVAL); in simplefb_get_validated_format()
95 return ERR_PTR(-EINVAL); in simplefb_get_validated_format()
102 return simplefb_get_validated_int0(dev, "width", pd->width); in simplefb_get_width_pd()
109 return simplefb_get_validated_int0(dev, "height", pd->height); in simplefb_get_height_pd()
116 return simplefb_get_validated_int(dev, "stride", pd->stride); in simplefb_get_stride_pd()
123 return simplefb_get_validated_format(dev, pd->format); in simplefb_get_format_pd()
214 struct drm_display_mode mode; member
242 * Here we handle the clocks property of our "simple-framebuffer" dt node.
263 for (i = 0; i < sdev->clk_count; ++i) { in simpledrm_device_release_clocks()
264 if (sdev->clks[i]) { in simpledrm_device_release_clocks()
265 clk_disable_unprepare(sdev->clks[i]); in simpledrm_device_release_clocks()
266 clk_put(sdev->clks[i]); in simpledrm_device_release_clocks()
273 struct drm_device *dev = &sdev->dev; in simpledrm_device_init_clocks()
274 struct platform_device *pdev = sdev->pdev; in simpledrm_device_init_clocks()
275 struct device_node *of_node = pdev->dev.of_node; in simpledrm_device_init_clocks()
280 if (dev_get_platdata(&pdev->dev) || !of_node) in simpledrm_device_init_clocks()
283 sdev->clk_count = of_clk_get_parent_count(of_node); in simpledrm_device_init_clocks()
284 if (!sdev->clk_count) in simpledrm_device_init_clocks()
287 sdev->clks = drmm_kzalloc(dev, sdev->clk_count * sizeof(sdev->clks[0]), in simpledrm_device_init_clocks()
289 if (!sdev->clks) in simpledrm_device_init_clocks()
290 return -ENOMEM; in simpledrm_device_init_clocks()
292 for (i = 0; i < sdev->clk_count; ++i) { in simpledrm_device_init_clocks()
296 if (ret == -EPROBE_DEFER) in simpledrm_device_init_clocks()
308 sdev->clks[i] = clock; in simpledrm_device_init_clocks()
311 return devm_add_action_or_reset(&pdev->dev, in simpledrm_device_init_clocks()
317 --i; in simpledrm_device_init_clocks()
318 if (sdev->clks[i]) { in simpledrm_device_init_clocks()
319 clk_disable_unprepare(sdev->clks[i]); in simpledrm_device_init_clocks()
320 clk_put(sdev->clks[i]); in simpledrm_device_init_clocks()
334 #define SUPPLY_SUFFIX "-supply"
339 * Here we handle the num-supplies and vin*-supply properties of our
340 * "simple-framebuffer" dt node. This is necessary so that we can make sure
361 for (i = 0; i < sdev->regulator_count; ++i) { in simpledrm_device_release_regulators()
362 if (sdev->regulators[i]) { in simpledrm_device_release_regulators()
363 regulator_disable(sdev->regulators[i]); in simpledrm_device_release_regulators()
364 regulator_put(sdev->regulators[i]); in simpledrm_device_release_regulators()
371 struct drm_device *dev = &sdev->dev; in simpledrm_device_init_regulators()
372 struct platform_device *pdev = sdev->pdev; in simpledrm_device_init_regulators()
373 struct device_node *of_node = pdev->dev.of_node; in simpledrm_device_init_regulators()
380 if (dev_get_platdata(&pdev->dev) || !of_node) in simpledrm_device_init_regulators()
385 p = strstr(prop->name, SUPPLY_SUFFIX); in simpledrm_device_init_regulators()
386 if (p && p != prop->name) in simpledrm_device_init_regulators()
393 sdev->regulators = drmm_kzalloc(dev, in simpledrm_device_init_regulators()
394 count * sizeof(sdev->regulators[0]), in simpledrm_device_init_regulators()
396 if (!sdev->regulators) in simpledrm_device_init_regulators()
397 return -ENOMEM; in simpledrm_device_init_regulators()
403 p = strstr(prop->name, SUPPLY_SUFFIX); in simpledrm_device_init_regulators()
404 if (!p || p == prop->name) in simpledrm_device_init_regulators()
406 len = strlen(prop->name) - strlen(SUPPLY_SUFFIX) + 1; in simpledrm_device_init_regulators()
407 strscpy(name, prop->name, min(sizeof(name), len)); in simpledrm_device_init_regulators()
409 regulator = regulator_get_optional(&pdev->dev, name); in simpledrm_device_init_regulators()
412 if (ret == -EPROBE_DEFER) in simpledrm_device_init_regulators()
427 sdev->regulators[i++] = regulator; in simpledrm_device_init_regulators()
429 sdev->regulator_count = i; in simpledrm_device_init_regulators()
431 return devm_add_action_or_reset(&pdev->dev, in simpledrm_device_init_regulators()
437 --i; in simpledrm_device_init_regulators()
438 if (sdev->regulators[i]) { in simpledrm_device_init_regulators()
439 regulator_disable(sdev->regulators[i]); in simpledrm_device_init_regulators()
440 regulator_put(sdev->regulators[i]); in simpledrm_device_init_regulators()
459 struct drm_display_mode mode = { SIMPLEDRM_MODE(width, height) }; in simpledrm_mode() local
461 mode.clock = 60 /* Hz */ * mode.hdisplay * mode.vdisplay; in simpledrm_mode()
462 drm_mode_set_name(&mode); in simpledrm_mode()
464 return mode; in simpledrm_mode()
471 struct drm_device *dev = &sdev->dev; in simpledrm_device_init_fb()
472 struct platform_device *pdev = sdev->pdev; in simpledrm_device_init_fb()
473 const struct simplefb_platform_data *pd = dev_get_platdata(&pdev->dev); in simpledrm_device_init_fb()
474 struct device_node *of_node = pdev->dev.of_node; in simpledrm_device_init_fb()
504 return -ENODEV; in simpledrm_device_init_fb()
507 sdev->mode = simpledrm_mode(width, height); in simpledrm_device_init_fb()
508 sdev->format = format; in simpledrm_device_init_fb()
509 sdev->pitch = stride; in simpledrm_device_init_fb()
511 drm_dbg_kms(dev, "display mode={" DRM_MODE_FMT "}\n", in simpledrm_device_init_fb()
512 DRM_MODE_ARG(&sdev->mode)); in simpledrm_device_init_fb()
515 &format->format, width, height, stride); in simpledrm_device_init_fb()
526 struct drm_device *dev = &sdev->dev; in simpledrm_device_init_mm()
527 struct platform_device *pdev = sdev->pdev; in simpledrm_device_init_mm()
534 return -EINVAL; in simpledrm_device_init_mm()
536 ret = devm_aperture_acquire_from_firmware(dev, mem->start, resource_size(mem)); in simpledrm_device_init_mm()
543 screen_base = devm_ioremap_wc(&pdev->dev, mem->start, in simpledrm_device_init_mm()
546 return -ENOMEM; in simpledrm_device_init_mm()
548 sdev->mem = mem; in simpledrm_device_init_mm()
549 sdev->screen_base = screen_base; in simpledrm_device_init_mm()
584 struct simpledrm_device *sdev = simpledrm_device_of_dev(connector->dev); in simpledrm_connector_helper_get_modes()
585 struct drm_display_mode *mode; in simpledrm_connector_helper_get_modes() local
587 mode = drm_mode_duplicate(connector->dev, &sdev->mode); in simpledrm_connector_helper_get_modes()
588 if (!mode) in simpledrm_connector_helper_get_modes()
591 if (mode->name[0] == '\0') in simpledrm_connector_helper_get_modes()
592 drm_mode_set_name(mode); in simpledrm_connector_helper_get_modes()
594 mode->type |= DRM_MODE_TYPE_PREFERRED; in simpledrm_connector_helper_get_modes()
595 drm_mode_probed_add(connector, mode); in simpledrm_connector_helper_get_modes()
597 if (mode->width_mm) in simpledrm_connector_helper_get_modes()
598 connector->display_info.width_mm = mode->width_mm; in simpledrm_connector_helper_get_modes()
599 if (mode->height_mm) in simpledrm_connector_helper_get_modes()
600 connector->display_info.height_mm = mode->height_mm; in simpledrm_connector_helper_get_modes()
619 const struct drm_display_mode *mode) in simpledrm_simple_display_pipe_mode_valid() argument
621 struct simpledrm_device *sdev = simpledrm_device_of_dev(pipe->crtc.dev); in simpledrm_simple_display_pipe_mode_valid()
623 if (mode->hdisplay != sdev->mode.hdisplay && in simpledrm_simple_display_pipe_mode_valid()
624 mode->vdisplay != sdev->mode.vdisplay) in simpledrm_simple_display_pipe_mode_valid()
626 else if (mode->hdisplay != sdev->mode.hdisplay) in simpledrm_simple_display_pipe_mode_valid()
628 else if (mode->vdisplay != sdev->mode.vdisplay) in simpledrm_simple_display_pipe_mode_valid()
639 struct simpledrm_device *sdev = simpledrm_device_of_dev(pipe->crtc.dev); in simpledrm_simple_display_pipe_enable()
641 struct drm_framebuffer *fb = plane_state->fb; in simpledrm_simple_display_pipe_enable()
642 void *vmap = shadow_plane_state->data[0].vaddr; /* TODO: Use mapping abstraction */ in simpledrm_simple_display_pipe_enable()
643 struct drm_device *dev = &sdev->dev; in simpledrm_simple_display_pipe_enable()
652 drm_fb_blit_dstclip(sdev->screen_base, sdev->pitch, in simpledrm_simple_display_pipe_enable()
653 sdev->format->format, vmap, fb); in simpledrm_simple_display_pipe_enable()
660 struct simpledrm_device *sdev = simpledrm_device_of_dev(pipe->crtc.dev); in simpledrm_simple_display_pipe_disable()
661 struct drm_device *dev = &sdev->dev; in simpledrm_simple_display_pipe_disable()
668 memset_io(sdev->screen_base, 0, sdev->pitch * sdev->mode.vdisplay); in simpledrm_simple_display_pipe_disable()
677 struct simpledrm_device *sdev = simpledrm_device_of_dev(pipe->crtc.dev); in simpledrm_simple_display_pipe_update()
678 struct drm_plane_state *plane_state = pipe->plane.state; in simpledrm_simple_display_pipe_update()
680 void *vmap = shadow_plane_state->data[0].vaddr; /* TODO: Use mapping abstraction */ in simpledrm_simple_display_pipe_update()
681 struct drm_framebuffer *fb = plane_state->fb; in simpledrm_simple_display_pipe_update()
682 struct drm_device *dev = &sdev->dev; in simpledrm_simple_display_pipe_update()
695 drm_fb_blit_rect_dstclip(sdev->screen_base, sdev->pitch, in simpledrm_simple_display_pipe_update()
696 sdev->format->format, vmap, fb, &clip); in simpledrm_simple_display_pipe_update()
719 struct drm_device *dev = &sdev->dev; in simpledrm_device_formats()
722 if (sdev->nformats) in simpledrm_device_formats()
725 /* native format goes first */ in simpledrm_device_formats()
726 sdev->formats[0] = sdev->format->format; in simpledrm_device_formats()
727 sdev->nformats = 1; in simpledrm_device_formats()
731 if (simpledrm_default_formats[i] == sdev->format->format) in simpledrm_device_formats()
732 continue; /* native format already went first */ in simpledrm_device_formats()
733 sdev->formats[sdev->nformats] = simpledrm_default_formats[i]; in simpledrm_device_formats()
734 sdev->nformats++; in simpledrm_device_formats()
738 * TODO: The simpledrm driver converts framebuffers to the native in simpledrm_device_formats()
740 * formats listed than supported by the driver, the native format in simpledrm_device_formats()
742 * support the native format and add a conversion helper ASAP. in simpledrm_device_formats()
744 if (drm_WARN_ONCE(dev, i != sdev->nformats, in simpledrm_device_formats()
746 &sdev->format->format)) { in simpledrm_device_formats()
747 sdev->nformats = 1; in simpledrm_device_formats()
751 *nformats_out = sdev->nformats; in simpledrm_device_formats()
752 return sdev->formats; in simpledrm_device_formats()
757 struct drm_device *dev = &sdev->dev; in simpledrm_device_init_modeset()
758 struct drm_display_mode *mode = &sdev->mode; in simpledrm_device_init_modeset() local
759 struct drm_connector *connector = &sdev->connector; in simpledrm_device_init_modeset()
760 struct drm_simple_display_pipe *pipe = &sdev->pipe; in simpledrm_device_init_modeset()
769 dev->mode_config.min_width = mode->hdisplay; in simpledrm_device_init_modeset()
770 dev->mode_config.max_width = mode->hdisplay; in simpledrm_device_init_modeset()
771 dev->mode_config.min_height = mode->vdisplay; in simpledrm_device_init_modeset()
772 dev->mode_config.max_height = mode->vdisplay; in simpledrm_device_init_modeset()
773 dev->mode_config.prefer_shadow_fbdev = true; in simpledrm_device_init_modeset()
774 dev->mode_config.preferred_depth = sdev->format->cpp[0] * 8; in simpledrm_device_init_modeset()
775 dev->mode_config.funcs = &simpledrm_mode_config_funcs; in simpledrm_device_init_modeset()
806 sdev = devm_drm_dev_alloc(&pdev->dev, drv, struct simpledrm_device, in simpledrm_device_create()
810 sdev->pdev = pdev; in simpledrm_device_create()
862 dev = &sdev->dev; in simpledrm_probe()
876 struct drm_device *dev = &sdev->dev; in simpledrm_remove()
884 { .compatible = "simple-framebuffer", },
891 .name = "simple-framebuffer", /* connect to sysfb */