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 {
struct list_head buffer_list;
tdm_server_voutput_buffer *attach_buffer;
int committing;
+ unsigned int request_commit;
} tdm_server_voutput_info;
typedef struct _tdm_server_vblank_info {
len = fread(pname, sizeof(char), TDM_NAME_LEN, h);
if (len == 0) {
- char *p = strncpy(pname, "NO NAME", sizeof(pname) - 1);
- len = p - pname;
+ strncpy(pname, "NO NAME", 7);
+ len = 8;
}
pname[len - 1] = '\0';
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;
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, ¤t_mode);
TDM_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
+ if (mode == current_mode) {
+ TDM_DBG("same mode");
+ return;
+ }
+
+ if (current_mode && ((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);
}
voutput_info = wl_resource_get_user_data(resource);
voutput_info->status = TDM_OUTPUT_CONN_STATUS_CONNECTED;
+ voutput_info->request_commit = 1;
+
tdm_voutput_set_physical_size(voutput_info->voutput, voutput_info->mmwidth, voutput_info->mmheight);
tdm_voutput_set_available_mode(voutput_info->voutput, voutput_info->available_modes.modes, voutput_info->available_modes.count);
tdm_voutput_connect(voutput_info->voutput);
+ tdm_output_set_voutput_commit(voutput_info->voutput);
}
static void
voutput_info->mmwidth = 0;
voutput_info->mmheight = 0;
+ if (voutput_info->request_commit == 1) {
+ tdm_output_unset_voutput_commit(voutput_info->voutput);
+ voutput_info->request_commit = 0;
+ }
+
if (voutput_info->attach_buffer) {
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);
}
tdm_voutput_disconnect(voutput_info->voutput);
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)
+ tdm_output_set_voutput_commit(voutput_info->voutput);
+
tdm_voutput_commit_done(voutput_info->voutput);
}
LIST_FOR_EACH_ENTRY(vb, &voutput_info->buffer_list, link) {
if (vb && vb->buffer == buffer) {
- tbm_surface_internal_ref(vb->buffer);
return vb;
}
}
voutput_info->attach_buffer = voutput_buffer;
+ tbm_surface_internal_ref(buffer);
wl_tdm_voutput_send_attach_buffer(voutput_info->resource, voutput_buffer->wl_buffer);
return TDM_ERROR_NONE;
TDM_RETURN_VAL_IF_FAIL(voutput_info->attach_buffer != NULL, TDM_ERROR_OPERATION_FAILED);
TDM_RETURN_VAL_IF_FAIL(voutput_info->committing == 0, TDM_ERROR_OPERATION_FAILED);
- tbm_surface_internal_ref(voutput_info->attach_buffer->buffer);
voutput_info->committing = 1;
wl_tdm_voutput_send_commit(voutput_info->resource);
voutput = voutput_info->voutput;
- if (voutput)
+ if (voutput_info->request_commit)
+ tdm_output_unset_voutput_commit(voutput_info->voutput);
+
+ if (voutput) {
+ if (voutput_info->request_commit == 1) {
+ tdm_output_unset_voutput_commit(voutput_info->voutput);
+ voutput_info->request_commit = 0;
+ tdm_voutput_disconnect(voutput_info->voutput);
+ }
+
ret = tdm_voutput_destroy(voutput);
- if (ret != TDM_ERROR_NONE)
- TDM_ERR("_tdm_voutput_cb_destroy fail");
+ if (ret != TDM_ERROR_NONE)
+ TDM_ERR("_tdm_voutput_cb_destroy fail");
+ }
if (voutput_info->attach_buffer) {
tbm_surface_h buffer = voutput_info->attach_buffer->buffer;