virtual (client): Added implementation for setting available format.
[platform/core/uifw/libtdm.git] / client / tdm_client.c
index 4c05811..d3e8b47 100644 (file)
@@ -96,9 +96,18 @@ typedef struct _tdm_private_client_voutput {
        struct
        {
                int count;
+               tbm_format *formats;
+       } available_formats;
+
+       struct
+       {
+               int count;
                tdm_client_output_mode *modes;
        } available_modes;
 
+       unsigned int mmwidth;
+       unsigned int mmheight;
+
        uint32_t msg;
 } tdm_private_client_voutput;
 
@@ -1737,6 +1746,12 @@ tdm_client_voutput_destroy(tdm_client_voutput *voutput)
        if (!private_voutput)
                return;
 
+       if (private_voutput->available_modes.modes)
+               free(private_voutput->available_modes.modes);
+
+       if (private_voutput->available_formats.formats)
+               free(private_voutput->available_formats.formats);
+
        wl_tdm_voutput_destroy(private_voutput->wl_voutput);
 
        free(private_voutput);
@@ -1772,11 +1787,50 @@ tdm_client_voutput_set_available_modes(tdm_client_voutput *voutput, const tdm_cl
 }
 
 tdm_error
-tdm_client_voutput_set_physical_size(tdm_client_voutput *voutput, int mmWidth, int mmHeight)
+tdm_client_voutput_set_available_formats(tdm_client_voutput *voutput, const tbm_format *formats, const int count)
+{
+       tdm_private_client_voutput *private_voutput;
+
+       TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+       if ((count > 0) && (formats == NULL))
+               return TDM_ERROR_INVALID_PARAMETER;
+
+       private_voutput = (tdm_private_client_voutput *)voutput;
+
+       if (private_voutput->base.connection == TDM_OUTPUT_CONN_STATUS_CONNECTED)
+               return TDM_ERROR_BAD_REQUEST;
+
+       if (private_voutput->available_formats.formats)
+               free(private_voutput->available_formats.formats);
+
+       private_voutput->available_formats.count = count;
+
+       if (count != 0)
+       {
+               private_voutput->available_formats.formats = calloc(count, sizeof(tbm_format));
+               memcpy(private_voutput->available_formats.formats, formats, sizeof(tbm_format) * count);
+       }
+
+       return TDM_ERROR_NONE;
+}
+
+tdm_error
+tdm_client_voutput_set_physical_size(tdm_client_voutput *voutput, unsigned int mmWidth, unsigned int mmHeight)
 {
+       tdm_private_client_voutput *private_voutput;
+
        TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER);
-       TDM_RETURN_VAL_IF_FAIL(mmWidth > 0, TDM_ERROR_INVALID_PARAMETER);
-       TDM_RETURN_VAL_IF_FAIL(mmHeight > 0, TDM_ERROR_INVALID_PARAMETER);
+       TDM_RETURN_VAL_IF_FAIL(mmWidth != 0, TDM_ERROR_INVALID_PARAMETER);
+       TDM_RETURN_VAL_IF_FAIL(mmHeight != 0, TDM_ERROR_INVALID_PARAMETER);
+
+       private_voutput = (tdm_private_client_voutput *)voutput;
+
+       if (private_voutput->base.connection == TDM_OUTPUT_CONN_STATUS_CONNECTED)
+               return TDM_ERROR_BAD_REQUEST;
+
+       private_voutput->mmwidth = mmWidth;
+       private_voutput->mmheight = mmHeight;
 
        return TDM_ERROR_NONE;
 }
@@ -1803,16 +1857,6 @@ tdm_client_voutput_get_client_output(tdm_client_voutput *voutput, tdm_error *err
 }
 
 tdm_error
-tdm_client_output_set_buffer_queue(tdm_client_output *output, void *queue, void *func)
-{
-       TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER);
-       TDM_RETURN_VAL_IF_FAIL(queue != NULL, TDM_ERROR_INVALID_PARAMETER);
-       TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER);
-
-       return TDM_ERROR_NONE;
-}
-
-tdm_error
 tdm_client_output_get_available_modes(tdm_client_output *output, tdm_client_output_mode **modes, int *count)
 {
        TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER);
@@ -1831,6 +1875,23 @@ tdm_client_output_set_mode(tdm_client_output *output, const tdm_client_output_mo
        return TDM_ERROR_NONE;
 }
 
+void
+_tdm_client_voutput_send_available_formats(tdm_private_client_voutput *private_voutput)
+{
+       tbm_format *format;
+       struct wl_array array;
+       int i, size;
+
+       size = sizeof(tbm_format);
+       wl_array_init(&array);
+       for (i = 0; i < private_voutput->available_formats.count; i++) {
+               format = wl_array_add(&array, size);
+               *format = private_voutput->available_formats.formats[i];
+       }
+       wl_tdm_voutput_set_available_formats(private_voutput->wl_voutput, &array);
+       wl_array_release(&array);
+}
+
 tdm_error
 tdm_client_output_connect(tdm_client_output *output)
 {
@@ -1850,8 +1911,7 @@ tdm_client_output_connect(tdm_client_output *output)
        private_output->connection = TDM_OUTPUT_CONN_STATUS_CONNECTED;
 
        modes = private_voutput->available_modes.modes;
-       for (i = 0; i < private_voutput->available_modes.count; i++)
-       {
+       for (i = 0; i < private_voutput->available_modes.count; i++) {
                wl_tdm_voutput_set_available_modes(private_voutput->wl_voutput, i,
                                                                                   modes[i].clock, modes[i].hdisplay,
                                                                                   modes[i].hsync_start, modes[i].hsync_end,
@@ -1863,6 +1923,10 @@ tdm_client_output_connect(tdm_client_output *output)
                                                                                   modes[i].name);
        }
 
+       _tdm_client_voutput_send_available_formats(private_voutput);
+
+       wl_tdm_voutput_set_physical_size(private_voutput->wl_voutput, private_voutput->mmwidth, private_voutput->mmheight);
+
        wl_tdm_voutput_connect(private_voutput->wl_voutput);
 
        return TDM_ERROR_NONE;