Lines Matching +full:simple +full:- +full:framebuffer

1 // SPDX-License-Identifier: GPL-2.0-only
28 #define DRIVER_DESC "DRM driver for simple-framebuffer platform devices"
42 drm_err(dev, "simplefb: invalid framebuffer %s of %u\n", in simplefb_get_validated_int()
44 return -EINVAL; in simplefb_get_validated_int()
54 drm_err(dev, "simplefb: invalid framebuffer %s of %u\n", in simplefb_get_validated_int0()
56 return -EINVAL; in simplefb_get_validated_int0()
70 drm_err(dev, "simplefb: missing framebuffer format\n"); in simplefb_get_validated_format()
71 return ERR_PTR(-EINVAL); in simplefb_get_validated_format()
75 if (!strcmp(format_name, fmt->name)) { in simplefb_get_validated_format()
76 info = drm_format_info(fmt->fourcc); in simplefb_get_validated_format()
78 return ERR_PTR(-EINVAL); in simplefb_get_validated_format()
84 drm_err(dev, "simplefb: unknown framebuffer format %s\n", in simplefb_get_validated_format()
87 return ERR_PTR(-EINVAL); in simplefb_get_validated_format()
94 return simplefb_get_validated_int0(dev, "width", pd->width); in simplefb_get_width_pd()
101 return simplefb_get_validated_int0(dev, "height", pd->height); in simplefb_get_height_pd()
108 return simplefb_get_validated_int(dev, "stride", pd->stride); in simplefb_get_stride_pd()
115 return simplefb_get_validated_format(dev, pd->format); in simplefb_get_format_pd()
125 drm_err(dev, "simplefb: cannot parse framebuffer %s: error %d\n", in simplefb_read_u32_of()
137 drm_err(dev, "simplefb: cannot parse framebuffer %s: error %d\n", in simplefb_read_string_of()
187 * Simple Framebuffer device
234 * Here we handle the clocks property of our "simple-framebuffer" dt node.
255 for (i = 0; i < sdev->clk_count; ++i) { in simpledrm_device_release_clocks()
256 if (sdev->clks[i]) { in simpledrm_device_release_clocks()
257 clk_disable_unprepare(sdev->clks[i]); in simpledrm_device_release_clocks()
258 clk_put(sdev->clks[i]); in simpledrm_device_release_clocks()
265 struct drm_device *dev = &sdev->dev; in simpledrm_device_init_clocks()
266 struct platform_device *pdev = to_platform_device(dev->dev); in simpledrm_device_init_clocks()
267 struct device_node *of_node = pdev->dev.of_node; in simpledrm_device_init_clocks()
272 if (dev_get_platdata(&pdev->dev) || !of_node) in simpledrm_device_init_clocks()
275 sdev->clk_count = of_clk_get_parent_count(of_node); in simpledrm_device_init_clocks()
276 if (!sdev->clk_count) in simpledrm_device_init_clocks()
279 sdev->clks = drmm_kzalloc(dev, sdev->clk_count * sizeof(sdev->clks[0]), in simpledrm_device_init_clocks()
281 if (!sdev->clks) in simpledrm_device_init_clocks()
282 return -ENOMEM; in simpledrm_device_init_clocks()
284 for (i = 0; i < sdev->clk_count; ++i) { in simpledrm_device_init_clocks()
288 if (ret == -EPROBE_DEFER) in simpledrm_device_init_clocks()
300 sdev->clks[i] = clock; in simpledrm_device_init_clocks()
303 return devm_add_action_or_reset(&pdev->dev, in simpledrm_device_init_clocks()
309 --i; in simpledrm_device_init_clocks()
310 if (sdev->clks[i]) { in simpledrm_device_init_clocks()
311 clk_disable_unprepare(sdev->clks[i]); in simpledrm_device_init_clocks()
312 clk_put(sdev->clks[i]); in simpledrm_device_init_clocks()
326 #define SUPPLY_SUFFIX "-supply"
331 * Here we handle the num-supplies and vin*-supply properties of our
332 * "simple-framebuffer" dt node. This is necessary so that we can make sure
353 for (i = 0; i < sdev->regulator_count; ++i) { in simpledrm_device_release_regulators()
354 if (sdev->regulators[i]) { in simpledrm_device_release_regulators()
355 regulator_disable(sdev->regulators[i]); in simpledrm_device_release_regulators()
356 regulator_put(sdev->regulators[i]); in simpledrm_device_release_regulators()
363 struct drm_device *dev = &sdev->dev; in simpledrm_device_init_regulators()
364 struct platform_device *pdev = to_platform_device(dev->dev); in simpledrm_device_init_regulators()
365 struct device_node *of_node = pdev->dev.of_node; in simpledrm_device_init_regulators()
372 if (dev_get_platdata(&pdev->dev) || !of_node) in simpledrm_device_init_regulators()
377 p = strstr(prop->name, SUPPLY_SUFFIX); in simpledrm_device_init_regulators()
378 if (p && p != prop->name) in simpledrm_device_init_regulators()
385 sdev->regulators = drmm_kzalloc(dev, in simpledrm_device_init_regulators()
386 count * sizeof(sdev->regulators[0]), in simpledrm_device_init_regulators()
388 if (!sdev->regulators) in simpledrm_device_init_regulators()
389 return -ENOMEM; in simpledrm_device_init_regulators()
395 p = strstr(prop->name, SUPPLY_SUFFIX); in simpledrm_device_init_regulators()
396 if (!p || p == prop->name) in simpledrm_device_init_regulators()
398 len = strlen(prop->name) - strlen(SUPPLY_SUFFIX) + 1; in simpledrm_device_init_regulators()
399 strscpy(name, prop->name, min(sizeof(name), len)); in simpledrm_device_init_regulators()
401 regulator = regulator_get_optional(&pdev->dev, name); in simpledrm_device_init_regulators()
404 if (ret == -EPROBE_DEFER) in simpledrm_device_init_regulators()
419 sdev->regulators[i++] = regulator; in simpledrm_device_init_regulators()
421 sdev->regulator_count = i; in simpledrm_device_init_regulators()
423 return devm_add_action_or_reset(&pdev->dev, in simpledrm_device_init_regulators()
429 --i; in simpledrm_device_init_regulators()
430 if (sdev->regulators[i]) { in simpledrm_device_init_regulators()
431 regulator_disable(sdev->regulators[i]); in simpledrm_device_init_regulators()
432 regulator_put(sdev->regulators[i]); in simpledrm_device_init_regulators()
478 struct drm_framebuffer *fb = plane_state->fb; in simpledrm_primary_plane_helper_atomic_update()
479 struct drm_device *dev = plane->dev; in simpledrm_primary_plane_helper_atomic_update()
494 struct iosys_map dst = IOSYS_MAP_INIT_VADDR(sdev->screen_base); in simpledrm_primary_plane_helper_atomic_update()
495 struct drm_rect dst_clip = plane_state->dst; in simpledrm_primary_plane_helper_atomic_update()
500 iosys_map_incr(&dst, drm_fb_clip_offset(sdev->pitch, sdev->format, &dst_clip)); in simpledrm_primary_plane_helper_atomic_update()
501 drm_fb_blit(&dst, &sdev->pitch, sdev->format->format, shadow_plane_state->data, fb, in simpledrm_primary_plane_helper_atomic_update()
513 struct drm_device *dev = plane->dev; in simpledrm_primary_plane_helper_atomic_disable()
521 memset_io(sdev->screen_base, 0, sdev->pitch * sdev->mode.vdisplay); in simpledrm_primary_plane_helper_atomic_disable()
543 struct simpledrm_device *sdev = simpledrm_device_of_dev(crtc->dev); in simpledrm_crtc_helper_mode_valid()
545 return drm_crtc_helper_mode_valid_fixed(crtc, mode, &sdev->mode); in simpledrm_crtc_helper_mode_valid()
586 struct simpledrm_device *sdev = simpledrm_device_of_dev(connector->dev); in simpledrm_connector_helper_get_modes()
588 return drm_connector_helper_get_modes_fixed(connector, &sdev->mode); in simpledrm_connector_helper_get_modes()
632 const struct simplefb_platform_data *pd = dev_get_platdata(&pdev->dev); in simpledrm_device_create()
633 struct device_node *of_node = pdev->dev.of_node; in simpledrm_device_create()
648 sdev = devm_drm_dev_alloc(&pdev->dev, drv, struct simpledrm_device, dev); in simpledrm_device_create()
651 dev = &sdev->dev; in simpledrm_device_create()
693 return ERR_PTR(-ENODEV); in simpledrm_device_create()
698 return ERR_PTR(-EINVAL); in simpledrm_device_create()
701 sdev->mode = simpledrm_mode(width, height); in simpledrm_device_create()
702 sdev->format = format; in simpledrm_device_create()
703 sdev->pitch = stride; in simpledrm_device_create()
705 drm_dbg(dev, "display mode={" DRM_MODE_FMT "}\n", DRM_MODE_ARG(&sdev->mode)); in simpledrm_device_create()
706 drm_dbg(dev, "framebuffer format=%p4cc, size=%dx%d, stride=%d byte\n", in simpledrm_device_create()
707 &format->format, width, height, stride); in simpledrm_device_create()
715 return ERR_PTR(-EINVAL); in simpledrm_device_create()
717 ret = devm_aperture_acquire_from_firmware(dev, res->start, resource_size(res)); in simpledrm_device_create()
723 mem = devm_request_mem_region(&pdev->dev, res->start, resource_size(res), drv->name); in simpledrm_device_create()
728 * the I/O-memory resource as-is and try to map that instead. in simpledrm_device_create()
734 screen_base = devm_ioremap_wc(&pdev->dev, mem->start, resource_size(mem)); in simpledrm_device_create()
736 return ERR_PTR(-ENOMEM); in simpledrm_device_create()
737 sdev->screen_base = screen_base; in simpledrm_device_create()
750 dev->mode_config.min_width = width; in simpledrm_device_create()
751 dev->mode_config.max_width = max_width; in simpledrm_device_create()
752 dev->mode_config.min_height = height; in simpledrm_device_create()
753 dev->mode_config.max_height = max_height; in simpledrm_device_create()
754 dev->mode_config.preferred_depth = format->cpp[0] * 8; in simpledrm_device_create()
755 dev->mode_config.funcs = &simpledrm_mode_config_funcs; in simpledrm_device_create()
759 nformats = drm_fb_build_fourcc_list(dev, &format->format, 1, in simpledrm_device_create()
762 sdev->formats, ARRAY_SIZE(sdev->formats)); in simpledrm_device_create()
764 primary_plane = &sdev->primary_plane; in simpledrm_device_create()
766 sdev->formats, nformats, in simpledrm_device_create()
776 crtc = &sdev->crtc; in simpledrm_device_create()
785 encoder = &sdev->encoder; in simpledrm_device_create()
790 encoder->possible_crtcs = drm_crtc_mask(crtc); in simpledrm_device_create()
794 connector = &sdev->connector; in simpledrm_device_create()
843 dev = &sdev->dev; in simpledrm_probe()
857 struct drm_device *dev = &sdev->dev; in simpledrm_remove()
865 { .compatible = "simple-framebuffer", },
872 .name = "simple-framebuffer", /* connect to sysfb */