[RFC 0/1] drm: Add Grain Media GM12U320 kms driver

Noralf Trønnes noralf at tronnes.org
Fri Jun 9 22:31:39 UTC 2017


Den 09.06.2017 22.59, skrev Marco Diego Aurélio Mesquita:
> Hi Devs!
>
> On Thu, Jun 8, 2017 at 4:08 AM, Hans de Goede <hdegoede at redhat.com> wrote:
>> I don't think that using cma for the gm12u320 is a good idea, it will
>> typically be used as a secondary GPU output together with a real GPU
>> extending the desktop by being a prime display output. So for the memory
>> management stuff I would keep the code copied from the udl driver (which
>> we may later split out in a separate helper lib for devices where
>> the framebuffer is in normal system memory and we have some scather-gather
>> capable process copying it to the real device over e.g. USB)
>>
> I got the PL111 driver and stripped all device specific code. Also, I
> added the get_modes and driver usb probe functions from gm12u320. The
> resulting code is available in
> https://gitlab.com/marcodiego/dummy-display-driver .
>
> The driver compiles, loads, identifies the device when I plug it,
> /dev/fb1 is created adequately but it stops there. Gnome monitors tool
> does not see it as a new monitor. What I expected was that it would be
> seen as a new monitor and that I could even activate it. Instead,
> syslog complains: "Cannot find any crtc or sizes".
>
> Anyway, I think this is a first step. My first doubt: where should I
> go from now? What should I change in the driver so that gnome monitors
> tool sees it as a new monitor and I could activate it, even if it
> works as a mere dummy device?
>
> Second doubt is: is this really the simplest/best way? I mean, the
> repaper driver that Emil pointed seems a lot simpler, wouldn't it be
> better to mimic it? How complicated is it to modify the repaper driver
> to build a dummy driver?
>
> By dummy driver, I mean something that gnome monitors tools can
> identify as a new monitor and I can activate it. I hope to reach a
> point where the update or dirty callback is called. From that point on
> it is just a matter of sending the framebuffer through USB the way
> gm12u320 does currently.

I guess you have forgotten to replace connector detect, because I
didn't see you use drm_panel in your RFC.
(gm12u320_connector->panel is NULL afaict, so it's always disconnected)

static enum drm_connector_status gm12u320_connector_detect(struct 
drm_connector
                             *connector, bool force)
{
-    struct gm12u320_drm_connector *gm12u320_connector =
-        to_gm12u320_connector(connector);
-
-    return (gm12u320_connector->panel ?
-        connector_status_connected :
-        connector_status_disconnected);
+    if (drm_device_is_unplugged(connector->dev))
+        return connector_status_disconnected;
+
+    return connector_status_connected;
}


Something like this should give you the dirty callback:

static int gm12u320_fb_dirty(struct drm_framebuffer *fb,
                  struct drm_file *file_priv,
                  unsigned int flags, unsigned int color,
                  struct drm_clip_rect *clips,
                  unsigned int num_clips)
{
     struct drm_gem_cma_object *cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
     void *src = cma_obj->vaddr;

     printk("FBDIRTY\n");
}

static const struct drm_framebuffer_funcs gm12u320_fb_funcs = {
     .destroy    = drm_fb_cma_destroy,
     .create_handle    = drm_fb_cma_create_handle,
     .dirty        = gm12u320_fb_dirty,
};

static struct drm_framebuffer *
gm12u320_fb_create(struct drm_device *drm, struct drm_file *file_priv,
           const struct drm_mode_fb_cmd2 *mode_cmd)
{
     return drm_fb_cma_create_with_funcs(drm, file_priv, mode_cmd,
                         &gm12u320_fb_funcs);
}

static struct drm_mode_config_funcs mode_config_funcs = {
     .fb_create = gm12u320_fb_create,
     .atomic_check = drm_atomic_helper_check,
     .atomic_commit = drm_atomic_helper_commit,
};


The repaper driver is based on tinydrm which uses the CMA library.
Hans said that cma wasn't appropriate for your monitor.
It will be difficult to go from a working tinydrm driver to one based
on the udl GEM functions.

I don't know gnome monitors tools, so I can't comment on that.


Noralf.



More information about the dri-devel mailing list