server: fix voutput mode change error 45/198145/1
authorJunkyeong Kim <jk0430.kim@samsung.com>
Mon, 21 Jan 2019 11:00:45 +0000 (20:00 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Mon, 21 Jan 2019 11:05:45 +0000 (20:05 +0900)
1. if mode changed, exported wl_buffer is not available. (buffer size changed)
so have to destroy old shared wl_buffers.
2. do not executed tdm_output_set_mode directly in voutput_set_mode cb.

Change-Id: Iec7bb13ee47949562020464ea1656ec078315816
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
src/tdm_server.c

index c66948d..adddc5b 100644 (file)
@@ -72,6 +72,7 @@ typedef struct _tdm_server_voutput_buffer {
        struct list_head link;
        struct wl_resource *wl_buffer;
        tbm_surface_h buffer;
+       int need_reset;
 } tdm_server_voutput_buffer;
 
 typedef struct _tdm_server_voutput_info {
@@ -870,8 +871,8 @@ _tdm_voutput_cb_set_mode(struct wl_client *client, struct wl_resource *resource,
        tdm_server_voutput_info *voutput_info = NULL;
        tdm_output *output = NULL;
        tdm_output_conn_status status = TDM_OUTPUT_CONN_STATUS_DISCONNECTED;
-       const tdm_output_mode *modes, *mode;
-
+       const tdm_output_mode *modes, *mode, *current_mode;
+       tdm_server_voutput_buffer *vb = NULL, *vbb = NULL;
        int count = 0;
        tdm_error ret;
 
@@ -889,8 +890,21 @@ _tdm_voutput_cb_set_mode(struct wl_client *client, struct wl_resource *resource,
        mode = &modes[index];
        TDM_DBG("mode set request to index:%d (%dx%d, %d)", index, mode->hdisplay, mode->vdisplay, mode->vrefresh);
 
-       ret = tdm_output_set_mode(output, mode);
+       ret = tdm_output_get_mode(output, &current_mode);
        TDM_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
+       if (mode == current_mode) {
+               TDM_DBG("same mode");
+               return;
+       }
+
+       if ((mode->hdisplay != current_mode->hdisplay) || (mode->vdisplay != current_mode->vdisplay)) {
+               LIST_FOR_EACH_ENTRY_SAFE(vb, vbb, &voutput_info->buffer_list, link) {
+                       if (vb->wl_buffer == voutput_info->attach_buffer->wl_buffer)
+                               voutput_info->attach_buffer->need_reset = 1;
+                       else
+                               wl_tdm_voutput_send_destroy_buffer(voutput_info->resource, vb->wl_buffer);
+               }
+       }
 
        tdm_output_request_mode_set(voutput_info->output, index);
 }
@@ -935,6 +949,8 @@ _tdm_voutput_cb_disconnect(struct wl_client *client, struct wl_resource *resourc
                tbm_surface_h buffer = voutput_info->attach_buffer->buffer;
                tbm_surface_internal_unref(buffer);
                voutput_info->committing = 0;
+               if (voutput_info->attach_buffer->need_reset)
+                       wl_tdm_voutput_send_destroy_buffer(voutput_info->resource, voutput_info->attach_buffer->wl_buffer);
                voutput_info->attach_buffer = NULL;
                tdm_voutput_commit_done(voutput_info->voutput);
        }
@@ -957,6 +973,8 @@ _tdm_voutput_cb_commit_done(struct wl_client *client, struct wl_resource *resour
        buffer = voutput_info->attach_buffer->buffer;
        tbm_surface_internal_unref(buffer);
        voutput_info->committing = 0;
+       if (voutput_info->attach_buffer->need_reset)
+               wl_tdm_voutput_send_destroy_buffer(voutput_info->resource, voutput_info->attach_buffer->wl_buffer);
        voutput_info->attach_buffer = NULL;
 
        if (voutput_info->request_commit == 1)