[PATCH] Mirroing mode

Leslie Zhai xiang.zhai at i-soft.com.cn
Tue Apr 14 02:18:23 PDT 2015


Hi Pekka,

Thanks for your reply ;-)

It is JUST able to work, and thanks Xiong Zhang`s patch for output gl 
render in mirroring (clone) mode 
http://lists.freedesktop.org/archives/wayland-devel/2013-September/011138.html

I just add primary key to the output section of weston.ini, and set the 
SAME mode ;P

[output]
name=LVDS1
primary=1
mode=1024x768

[output]
name=VGA1
primary=0
mode=1024x768


diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index de046fc..ef1bd27 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -185,6 +185,8 @@ struct drm_output {

      struct vaapi_recorder *recorder;
      struct wl_listener recorder_frame_listener;
+
+    int primary;
  };

  /*
@@ -604,6 +606,11 @@ drm_output_repaint(struct weston_output *output_base,
      struct drm_sprite *s;
      struct drm_mode *mode;
      int ret = 0;
+    struct drm_output *clone_output;
+
+    /* TODO: primary output */
+    if (output->primary == 0)
+        return -1;

      if (output->destroy_pending)
          return -1;
@@ -625,7 +632,24 @@ drm_output_repaint(struct weston_output *output_base,
              goto err_pageflip;
          }
          output_base->set_dpms(output_base, WESTON_DPMS_ON);
-    }
+        if (mirror_mode) {
+            wl_list_for_each(clone_output, 
&compositor->base.output_list, base.link) {
+               if (&clone_output->base != output_base) {
+                   mode = container_of(clone_output->base.current_mode, 
struct drm_mode, base);
+                   ret = drmModeSetCrtc(compositor->drm.fd, 
clone_output->crtc_id,
+                                       output->next->fb_id, 0, 0,
+ &clone_output->connector_id, 1,
+                                       &mode->mode_info);
+                   if (ret) {
+                       weston_log("set mode failed: %m\n");
+                       return -1;
+                   }
+ clone_output->base.set_dpms(&clone_output->base, WESTON_DPMS_ON);
+               }
+           }
+        }
+    }

      if (drmModePageFlip(compositor->drm.fd, output->crtc_id,
                  output->next->fb_id,
@@ -636,6 +660,20 @@ drm_output_repaint(struct weston_output *output_base,

      output->page_flip_pending = 1;

+    /* TODO: the same as above */
+    if (mirror_mode) {
+        wl_list_for_each(clone_output, &compositor->base.output_list, 
base.link) {
+           if (&clone_output->base != output_base) {
+               if (drmModePageFlip(compositor->drm.fd, 
clone_output->crtc_id,
+                               output->next->fb_id,
+                               DRM_MODE_PAGE_FLIP_EVENT, clone_output) 
< 0) {
+                   weston_log("queueing pageflip failed: %m\n");
+                   return -1;
+               }
+           }
+       }
+    }
+
      drm_output_set_cursor(output);

      /*
@@ -2054,6 +2092,8 @@ create_output_for_connector(struct drm_compositor *ec,

      section = weston_config_get_section(ec->base.config, "output", "name",
                          output->base.name);
+    /* TODO: primary output */
+    weston_config_section_get_int(section, "primary", &output->primary, 0);
      weston_config_section_get_string(section, "mode", &s, "preferred");
      if (strcmp(s, "off") == 0)
          config = OUTPUT_CONFIG_OFF;


Yup it is a monkey patch! I have to deal with the pageflip as Xiong 
Zhang did.
Thank you very much, pg, you are so nice to teach me ;-)


On 2015年04月14日 15:04, Pekka Paalanen wrote:
> On Tue, 14 Apr 2015 12:23:03 +0800
> Leslie Zhai <xiang.zhai at i-soft.com.cn> wrote:
>
>> Hi Pekka,
>>
>> Thanks for your reply!
>>
>> It is not easy to use Google "thanks to" G.F.W. blocked it ;-(
>> Could you paste the URL links for me please? thanks a lot!
> About mirror/clone mode:
> http://lists.freedesktop.org/archives/wayland-devel/2013-September/011134.html
> http://lists.freedesktop.org/archives/wayland-devel/2013-September/011161.html
> http://lists.freedesktop.org/archives/wayland-devel/2013-October/011438.html
> http://lists.freedesktop.org/archives/wayland-devel/2014-February/013247.html
> http://lists.freedesktop.org/archives/wayland-devel/2014-March/013566.html
> http://lists.freedesktop.org/archives/wayland-devel/2014-October/017719.html
>
> About weston-randr:
> http://lists.freedesktop.org/archives/wayland-devel/2014-February/013480.html
> http://lists.freedesktop.org/archives/wayland-devel/2014-March/013511.html
> http://lists.freedesktop.org/archives/wayland-devel/2014-March/013691.html
> http://lists.freedesktop.org/archives/wayland-devel/2014-March/013843.html
> http://lists.freedesktop.org/archives/wayland-devel/2014-April/014091.html
> http://lists.freedesktop.org/archives/wayland-devel/2014-May/014586.html
>
> These are all beginnings of threads, as seen in the archives, so
> usually the important comments are in the replies, not in the linked
> email itself.
>
> That is likely not an exhaustive list, it's just what I gathered
> quickly.
>
>> It is not the issue - whether or not able to do partial (or full
>> repaint) updates, but owing to:
>> 1. different mode such as different width x height resolution
>> 2. different scale, maybe output VGA1 is often called "HiDPI" or
>> "retina" display
> Yes, those are just issues in addition to what I listed. Those are easy
> to implement once the more fundamental problems of what I listed are
> solved.
>
>> The screenshot
>> https://twitter.com/xiangzhai/status/587827576665587713/photo/1
>> The overlap of outputs (LVDS1 and VGA1) is not in the SAME coordinate
>> system: different X and Y axes, so even do a full repaint, it is not
>> able to fix the issue!
> What coordinate systems are you talking about? Weston has many.
>
> That is not the kind of glitch I was talking about. What you see there
> is simply wrong logic in the code. It's not a transient random glitch,
> so it's relatively easy to fix, because you can reliably test it.
>
> The glitch is about not repainting sub-regions that should have been
> painted, leading to corrupted output. E.g. a window missing a piece of
> it, or showing a piece of outdated content.
>
>> But what about Xinerama http://en.wikipedia.org/wiki/Xinerama like the
>> father of Xrandr.
>> I am learning how Xinerama do the coordinate matrix transform for the
>> X11, hope to inspire me for weston ;-)
> I don't think you can learn anything useful for Weston from there.
>
>> On 2015年04月10日 21:05, Pekka Paalanen wrote:
>>> On Fri, 10 Apr 2015 15:36:36 +0800
>>> Leslie Zhai <xiang.zhai at i-soft.com.cn> wrote:
>>>
>>>> Hi Pekka,
>>>>
>>>> I am reading src/compositor-drm.c in create_outputs(...) function, it
>>>> uses drmModeGetResources to get count_connectors,
>>>> then update the X position in a for loop shown as below:
>>>>
>>>> ```
>>>> x += container_of(ec->base.output_list.prev,
>>>>                          struct weston_output,
>>>>                          link)->width;
>>>> ```
>>>>
>>>> so it is absolutely extend mode by default, "draw" count_connectors`
>>>> create_output_for_connector(...) rectangles with DIFFERENT X position,
>>>> if take a screenshot, it should be
>>>> https://twitter.com/xiangzhai/status/586061869279883266/photo/1
>>>>
>>>> But if add mirror to drm_options (shown as below patch) it is able to
>>>> run weston --mirror with the SAME X position,
>>>> the screenshot
>>>> https://twitter.com/xiangzhai/status/586428721533288449/photo/1
>>>>
>>> I have a huge deja vu experience here. I warmly suggest you dig up the
>>> previous discussions from the mailing list archives when this kind of
>>> simple (too stupid to work for more than 2 outputs) mirroring was
>>> proposed.
>>>
>>>> diff --git a/src/compositor-drm.c b/src/compositor-drm.c
> ...
>
>>>> It is a monkey patch ;-) there are a lot of things I have to fix or
>>>> learn, such as:
>>>> 1. how to "draw" the SAME "rectangle" to different outputs, what do I
>>>> need to hack for recent weston`s architecture?
>>>> 2. xrandr utility will choose the SAME mode for different outputs, for
>>>> example, 1024x768, I have not implemented it for mirroring mode!
>>> Like I said, a simple test does not guarantee that weston's damage
>>> tracking can cope with it. You have to ensure the renderer/backend can
>>> do partial updates, and then watch for glitches when causing partial
>>> repaints.
>>>
>>> The answer to your question about rectangles involves understanding the
>>> damage tracking system and making sure it works also for overlapping
>>> outputs. After that, it should just work. I cannot explain it off-hand,
>>> it is so complex that it would take a good while for me to study and
>>> understand again how it works.
>>>
>>> Screenshooting forces a full repaint IIRC, so that would immediately
>>> hide any glitches you might see.
> Thanks,
> pq
>

-- 
Regards,
Leslie Zhai



More information about the wayland-devel mailing list