Skip to content

Commit

Permalink
Build fixing fl2000_drm
Browse files Browse the repository at this point in the history
  • Loading branch information
klogg committed Sep 11, 2024
1 parent 70a9f14 commit a759446
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
1 change: 1 addition & 0 deletions fl2000.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <drm/drm_probe_helper.h>
#include <drm/drm_damage_helper.h>
#include <drm/drm_fb_dma_helper.h>
#include <drm/drm_fbdev_dma.h>

#include "fl2000_registers.h"

Expand Down
41 changes: 25 additions & 16 deletions fl2000_drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,15 @@ static void fl2000_display_update(struct drm_simple_display_pipe *pipe,
}
}

static void fl2000_display_enable_vblank(struct drm_simple_display_pipe *pipe)
static int fl2000_display_enable_vblank(struct drm_simple_display_pipe *pipe)
{
struct drm_crtc *crtc = &pipe->crtc;
struct drm_device *drm = crtc->dev;
struct fl2000_drm_if *drm_if = container_of(drm, struct fl2000_drm_if, drm);

drm_if->vblank_enabled = true;

return 0;
}

static void fl2000_display_disable_vblank(struct drm_simple_display_pipe *pipe)
Expand Down Expand Up @@ -446,6 +448,7 @@ void fl2000_drm_vblank(struct usb_device *usb_dev)
{
int ret;
struct fl2000_drm_if *drm_if;
struct drm_crtc *crtc;

drm_if = dev_get_drvdata(&usb_dev->dev);
if (!drm_if) {
Expand All @@ -456,7 +459,8 @@ void fl2000_drm_vblank(struct usb_device *usb_dev)
if (!drm_if->vblank_enabled)
return;

ret = drm_crtc_handle_vblank(drm_if->crtc);
crtc = &drm_if->pipe->crtc;
ret = drm_crtc_handle_vblank(crtc);
if (ret)
dev_err(&usb_dev->dev, "Cannot handle vblank event (%d)", ret);
}
Expand Down Expand Up @@ -506,11 +510,18 @@ static void fl2000_drm_unbind(struct device *master)
{
/* It is assumed that master is FL2000 USB device */
struct usb_device *usb_dev = to_usb_device(master);
struct fl2000_drm_if *drm_if = res;
struct drm_device *drm = &drm_if->drm;
struct fl2000_drm_if *drm_if;
struct drm_device *drm;

dev_info(master, "Unbinding FL2000 master");

drm_if = dev_get_drvdata(&usb_dev->dev);
if (!drm_if) {
dev_err(&usb_dev->dev, "Cannot find DRM structure!");
return;
}
drm = &drm_if->drm;

drm_atomic_helper_shutdown(drm);

/* Detach bridge */
Expand All @@ -531,22 +542,22 @@ static struct component_master_ops fl2000_master_ops = {
* We do not configure DMA mask here because we link DRM device to the USB device provided.
* We also do not set up polling because connect/disconnect events are provided in interrupts.
*
* @param interface USB interface to attach DRM device to
* @param usb_dev USB device structure
*
* @return 0 on success, negative value on error
*/
int fl2000_drm_init(struct usb_interface *interface)
int fl2000_drm_init(sstruct usb_device *usb_dev)
{
int ret;
struct fl2000_drm_if *drm_if;
struct drm_device *drm;
struct drm_mode_config *mode_config;
struct component_match *match = NULL;
struct usb_device *usb_dev = interface_to_usbdev(interface);

/* DRM device is allocated together with private data structure and attached to the device */
drm_if = devm_drm_dev_alloc(&usb_dev->dev, &fl2000_drm_driver, struct fl2000_drm_if, drm);
if (IS_ERR(drm_if)) {
dev_err(&interface->dev, "Cannot allocate DRM structure (%ld)", PTR_ERR(drm_if));
dev_err(&usb_dev->dev, "Cannot allocate DRM structure (%ld)", PTR_ERR(drm_if));
return (int)PTR_ERR(drm_if);
}
drm = &drm_if->drm;
Expand All @@ -555,7 +566,7 @@ int fl2000_drm_init(struct usb_interface *interface)
/* Static mode configuration that won't change */
ret = drmm_mode_config_init(drm);
if (ret) {
dev_err(&interface->dev, "Cannot initialize DRM mode (%d)", ret);
dev_err(&usb_dev->dev, "Cannot initialize DRM mode (%d)", ret);
drm_dev_put(drm);
return ret;
}
Expand All @@ -571,7 +582,7 @@ int fl2000_drm_init(struct usb_interface *interface)
fl2000_pixel_formats, ARRAY_SIZE(fl2000_pixel_formats),
NULL, NULL);
if (ret) {
dev_err(&interface->dev, "Cannot configure simple display pipe (%d)", ret);
dev_err(&usb_dev->dev, "Cannot configure simple display pipe (%d)", ret);
drm_mode_config_cleanup(drm);
drm_dev_put(drm);
return ret;
Expand All @@ -580,7 +591,7 @@ int fl2000_drm_init(struct usb_interface *interface)
/* We support vblanks */
ret = drm_vblank_init(drm, drm->mode_config.num_crtc);
if (ret) {
dev_err(&interface->dev, "Failed to initialize %d vblank(s) (%d)", drm->mode_config.num_crtc, ret);
dev_err(&usb_dev->dev, "Failed to initialize %d vblank(s) (%d)", drm->mode_config.num_crtc, ret);
drm_mode_config_cleanup(drm);
drm_dev_put(drm);
return ret;
Expand All @@ -592,7 +603,7 @@ int fl2000_drm_init(struct usb_interface *interface)
/* Register supported HDMI bridge as a component with match by name */
ret = component_match_add(&usb_dev->dev, &match, component_compare_dev_name, fl2000_supported_bridge);
if (ret) {
dev_err(&interface->dev, "Cannot add component match! (%d)", ret);
dev_err(&usb_dev->dev, "Cannot add component match! (%d)", ret);
drm_mode_config_cleanup(drm);
drm_dev_put(drm);
return ret;
Expand All @@ -603,7 +614,7 @@ int fl2000_drm_init(struct usb_interface *interface)
*/
ret = component_master_add_with_match(&usb_dev->dev, &fl2000_master_ops, match);
if (ret) {
dev_err(&interface->dev, "Cannot register component master (%d)", ret);
dev_err(&usb_dev->dev, "Cannot register component master (%d)", ret);
drm_mode_config_cleanup(drm);
drm_dev_put(drm);
return ret;
Expand All @@ -614,10 +625,8 @@ int fl2000_drm_init(struct usb_interface *interface)
return 0;
}

void fl2000_drm_cleanup(struct usb_interface *interface)
void fl2000_drm_cleanup(struct usb_device *usb_dev)
{
struct usb_device *usb_dev = interface_to_usbdev(interface);

dev_set_drvdata(&usb_dev->dev, NULL);
component_master_del(&usb_dev->dev, &fl2000_master_ops);

Expand Down

0 comments on commit a759446

Please sign in to comment.