apply wayland coding style 37/60537/1
authorBoram Park <boram1288.park@samsung.com>
Mon, 29 Feb 2016 02:01:16 +0000 (11:01 +0900)
committerBoram Park <boram1288.park@samsung.com>
Mon, 29 Feb 2016 02:01:16 +0000 (11:01 +0900)
Change-Id: I07f1b264728a8deb6a845394d6fd790319c742b7

src/tdm_drm.c
src/tdm_drm_display.c
src/tdm_drm_format.c
src/tdm_drm_pp.c

index 5dffd15..6e38470 100644 (file)
 
 #define TDM_DRM_NAME "vigs"
 
-static tdm_func_display drm_func_display =
-{
-    drm_display_get_capabilitiy,
-    NULL,  //display_get_pp_capability,
-    NULL,  //display_get_capture_capability
-    drm_display_get_outputs,
-    drm_display_get_fd,
-    drm_display_get_fd,
-    drm_display_handle_events,
-    NULL,  //display_create_pp,
+static tdm_func_display drm_func_display = {
+       drm_display_get_capabilitiy,
+       NULL,  //display_get_pp_capability,
+       NULL,  //display_get_capture_capability
+       drm_display_get_outputs,
+       drm_display_get_fd,
+       drm_display_get_fd,
+       drm_display_handle_events,
+       NULL,  //display_create_pp,
 };
 
-static tdm_func_output drm_func_output =
-{
-    drm_output_get_capability,
-    drm_output_get_layers,
-    drm_output_set_property,
-    drm_output_get_property,
-    drm_output_wait_vblank,
-    drm_output_set_vblank_handler,
-    drm_output_commit,
-    drm_output_set_commit_handler,
-    drm_output_set_dpms,
-    drm_output_get_dpms,
-    drm_output_set_mode,
-    drm_output_get_mode,
-    NULL,   //output_create_capture
+static tdm_func_output drm_func_output = {
+       drm_output_get_capability,
+       drm_output_get_layers,
+       drm_output_set_property,
+       drm_output_get_property,
+       drm_output_wait_vblank,
+       drm_output_set_vblank_handler,
+       drm_output_commit,
+       drm_output_set_commit_handler,
+       drm_output_set_dpms,
+       drm_output_get_dpms,
+       drm_output_set_mode,
+       drm_output_get_mode,
+       NULL,   //output_create_capture
 };
 
-static tdm_func_layer drm_func_layer =
-{
-    drm_layer_get_capability,
-    drm_layer_set_property,
-    drm_layer_get_property,
-    drm_layer_set_info,
-    drm_layer_get_info,
-    drm_layer_set_buffer,
-    drm_layer_unset_buffer,
-    NULL,    //layer_set_video_pos
-    NULL,    //layer_create_capture
+static tdm_func_layer drm_func_layer = {
+       drm_layer_get_capability,
+       drm_layer_set_property,
+       drm_layer_get_property,
+       drm_layer_set_info,
+       drm_layer_get_info,
+       drm_layer_set_buffer,
+       drm_layer_unset_buffer,
+       NULL,    //layer_set_video_pos
+       NULL,    //layer_create_capture
 };
 
-static tdm_func_pp drm_func_pp =
-{
-    drm_pp_destroy,
-    drm_pp_set_info,
-    drm_pp_attach,
-    drm_pp_commit,
-    drm_pp_set_done_handler,
+static tdm_func_pp drm_func_pp = {
+       drm_pp_destroy,
+       drm_pp_set_info,
+       drm_pp_attach,
+       drm_pp_commit,
+       drm_pp_set_done_handler,
 };
 
 static tdm_drm_data *drm_data;
 
 #ifdef HAVE_UDEV
-static struct udev_device*
+static struct udev_device *
 _tdm_find_primary_gpu(void)
 {
-    struct udev *udev;
+       struct udev *udev;
        struct udev_enumerate *e;
        struct udev_list_entry *entry;
        const char *path, *id;
        struct udev_device *device, *drm_device, *pci;
 
-    udev = udev_new();
-    if (!udev)
-    {
-        TDM_ERR("fail to initialize udev context\n");
-        return NULL;
-    }
+       udev = udev_new();
+       if (!udev) {
+               TDM_ERR("fail to initialize udev context\n");
+               return NULL;
+       }
 
        e = udev_enumerate_new(udev);
        udev_enumerate_add_match_subsystem(e, "drm");
@@ -94,7 +89,7 @@ _tdm_find_primary_gpu(void)
                        continue;
 
                pci = udev_device_get_parent_with_subsystem_devtype(device,
-                                                               "pci", NULL);
+                               "pci", NULL);
                if (pci) {
                        id = udev_device_get_sysattr_value(pci, "boot_vga");
                        if (id && !strcmp(id, "1")) {
@@ -119,179 +114,168 @@ _tdm_find_primary_gpu(void)
 static int
 _tdm_drm_open_drm(void)
 {
-    int fd = -1;
+       int fd = -1;
 
-    fd = drmOpen(TDM_DRM_NAME, NULL);
-    if (fd < 0)
-    {
-        TDM_ERR("Cannot open '%s' drm", TDM_DRM_NAME);
-    }
+       fd = drmOpen(TDM_DRM_NAME, NULL);
+       if (fd < 0) {
+               TDM_ERR("Cannot open '%s' drm", TDM_DRM_NAME);
+       }
 
 #ifdef HAVE_UDEV
-    if (fd < 0)
-    {
-        struct udev_device *drm_device = NULL;
-        const char *filename;
-        TDM_WRN("Cannot open drm device.. search by udev");
-
-        drm_device = _tdm_find_primary_gpu();
-        if (drm_device == NULL)
-        {
-            TDM_ERR("fail to find drm device\n");
-            goto close_l;
-        }
+       if (fd < 0) {
+               struct udev_device *drm_device = NULL;
+               const char *filename;
+               TDM_WRN("Cannot open drm device.. search by udev");
+
+               drm_device = _tdm_find_primary_gpu();
+               if (drm_device == NULL) {
+                       TDM_ERR("fail to find drm device\n");
+                       goto close_l;
+               }
 
-        filename = udev_device_get_devnode(drm_device);
+               filename = udev_device_get_devnode(drm_device);
 
-        fd = open(filename, O_RDWR | O_CLOEXEC);
-        if (fd < 0)
-            TDM_ERR("Cannot open drm device(%s)\n", filename);
+               fd = open(filename, O_RDWR | O_CLOEXEC);
+               if (fd < 0)
+                       TDM_ERR("Cannot open drm device(%s)\n", filename);
 
-        TDM_DBG("open drm device (name:%s, fd:%d)", filename, fd);
+               TDM_DBG("open drm device (name:%s, fd:%d)", filename, fd);
 
-        udev_device_unref(drm_device);
-    }
+               udev_device_unref(drm_device);
+       }
 close_l:
 #endif
-    return fd;
+       return fd;
 }
 
 void
 tdm_drm_deinit(tdm_backend_data *bdata)
 {
-    if (drm_data != bdata)
-        return;
+       if (drm_data != bdata)
+               return;
 
-    TDM_INFO("deinit");
+       TDM_INFO("deinit");
 
-    tdm_drm_display_destroy_output_list(drm_data);
+       tdm_drm_display_destroy_output_list(drm_data);
 
-    if (drm_data->plane_res)
-        drmModeFreePlaneResources(drm_data->plane_res);
-    if (drm_data->mode_res)
-        drmModeFreeResources(drm_data->mode_res);
-    if (drm_data->drm_fd >= 0)
-        close(drm_data->drm_fd);
+       if (drm_data->plane_res)
+               drmModeFreePlaneResources(drm_data->plane_res);
+       if (drm_data->mode_res)
+               drmModeFreeResources(drm_data->mode_res);
+       if (drm_data->drm_fd >= 0)
+               close(drm_data->drm_fd);
 
-    free(drm_data);
-    drm_data = NULL;
+       free(drm_data);
+       drm_data = NULL;
 }
 
-tdm_backend_data*
+tdm_backend_data *
 tdm_drm_init(tdm_display *dpy, tdm_error *error)
 {
-    tdm_error ret;
-
-    if (!dpy)
-    {
-        TDM_ERR("display is null");
-        if (error)
-            *error = TDM_ERROR_INVALID_PARAMETER;
-        return NULL;
-    }
-
-    if (drm_data)
-    {
-        TDM_ERR("failed: init twice");
-        if (error)
-            *error = TDM_ERROR_BAD_REQUEST;
-        return NULL;
-    }
-
-    drm_data = calloc(1, sizeof(tdm_drm_data));
-    if (!drm_data)
-    {
-        TDM_ERR("alloc failed");
-        if (error)
-            *error = TDM_ERROR_OUT_OF_MEMORY;
-        return NULL;
-    }
-
-    LIST_INITHEAD(&drm_data->output_list);
-    LIST_INITHEAD(&drm_data->buffer_list);
-
-    ret = tdm_backend_register_func_display(dpy, &drm_func_display);
-    if (ret != TDM_ERROR_NONE)
-        goto failed;
-
-    ret = tdm_backend_register_func_output(dpy, &drm_func_output);
-    if (ret != TDM_ERROR_NONE)
-        goto failed;
-
-    ret = tdm_backend_register_func_layer(dpy, &drm_func_layer);
-    if (ret != TDM_ERROR_NONE)
-        goto failed;
-
-    ret = tdm_backend_register_func_pp(dpy, &drm_func_pp);
-    if (ret != TDM_ERROR_NONE)
-        goto failed;
-
-    drm_data->dpy = dpy;
-
-    drm_data->drm_fd = _tdm_drm_open_drm();
-    if (drm_data->drm_fd < 0)
-    {
-        ret = TDM_ERROR_OPERATION_FAILED;
-        goto failed;
-    }
+       tdm_error ret;
+
+       if (!dpy) {
+               TDM_ERR("display is null");
+               if (error)
+                       *error = TDM_ERROR_INVALID_PARAMETER;
+               return NULL;
+       }
+
+       if (drm_data) {
+               TDM_ERR("failed: init twice");
+               if (error)
+                       *error = TDM_ERROR_BAD_REQUEST;
+               return NULL;
+       }
+
+       drm_data = calloc(1, sizeof(tdm_drm_data));
+       if (!drm_data) {
+               TDM_ERR("alloc failed");
+               if (error)
+                       *error = TDM_ERROR_OUT_OF_MEMORY;
+               return NULL;
+       }
+
+       LIST_INITHEAD(&drm_data->output_list);
+       LIST_INITHEAD(&drm_data->buffer_list);
+
+       ret = tdm_backend_register_func_display(dpy, &drm_func_display);
+       if (ret != TDM_ERROR_NONE)
+               goto failed;
+
+       ret = tdm_backend_register_func_output(dpy, &drm_func_output);
+       if (ret != TDM_ERROR_NONE)
+               goto failed;
+
+       ret = tdm_backend_register_func_layer(dpy, &drm_func_layer);
+       if (ret != TDM_ERROR_NONE)
+               goto failed;
+
+       ret = tdm_backend_register_func_pp(dpy, &drm_func_pp);
+       if (ret != TDM_ERROR_NONE)
+               goto failed;
+
+       drm_data->dpy = dpy;
+
+       drm_data->drm_fd = _tdm_drm_open_drm();
+       if (drm_data->drm_fd < 0) {
+               ret = TDM_ERROR_OPERATION_FAILED;
+               goto failed;
+       }
 
 #if LIBDRM_MAJOR_VERSION >= 2 && LIBDRM_MINOR_VERSION >= 4  && LIBDRM_MICRO_VERSION >= 47
-    if (drmSetClientCap(drm_data->drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1) < 0)
-        TDM_WRN("Set DRM_CLIENT_CAP_UNIVERSAL_PLANES failed");
+       if (drmSetClientCap(drm_data->drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1) < 0)
+               TDM_WRN("Set DRM_CLIENT_CAP_UNIVERSAL_PLANES failed");
 #endif
 
-    drm_data->mode_res = drmModeGetResources(drm_data->drm_fd);
-    if (!drm_data->mode_res)
-    {
-        TDM_ERR("no drm resource: %m");
-        ret = TDM_ERROR_OPERATION_FAILED;
-        goto failed;
-    }
-
-    drm_data->plane_res = drmModeGetPlaneResources(drm_data->drm_fd);
-    if (!drm_data->plane_res)
-    {
-        TDM_ERR("no drm plane resource: %m");
-        ret = TDM_ERROR_OPERATION_FAILED;
-        goto failed;
-    }
-
-    if (drm_data->plane_res->count_planes <= 0)
-    {
-        TDM_ERR("no drm plane resource");
-        ret = TDM_ERROR_OPERATION_FAILED;
-        goto failed;
-    }
-
-    ret = tdm_drm_display_create_output_list(drm_data);
-    if (ret != TDM_ERROR_NONE)
-        goto failed;
-
-    ret = tdm_drm_display_create_layer_list(drm_data);
-    if (ret != TDM_ERROR_NONE)
-        goto failed;
-
-    if (error)
-        *error = TDM_ERROR_NONE;
-
-    TDM_INFO("init success!");
-
-    return (tdm_backend_data*)drm_data;
+       drm_data->mode_res = drmModeGetResources(drm_data->drm_fd);
+       if (!drm_data->mode_res) {
+               TDM_ERR("no drm resource: %m");
+               ret = TDM_ERROR_OPERATION_FAILED;
+               goto failed;
+       }
+
+       drm_data->plane_res = drmModeGetPlaneResources(drm_data->drm_fd);
+       if (!drm_data->plane_res) {
+               TDM_ERR("no drm plane resource: %m");
+               ret = TDM_ERROR_OPERATION_FAILED;
+               goto failed;
+       }
+
+       if (drm_data->plane_res->count_planes <= 0) {
+               TDM_ERR("no drm plane resource");
+               ret = TDM_ERROR_OPERATION_FAILED;
+               goto failed;
+       }
+
+       ret = tdm_drm_display_create_output_list(drm_data);
+       if (ret != TDM_ERROR_NONE)
+               goto failed;
+
+       ret = tdm_drm_display_create_layer_list(drm_data);
+       if (ret != TDM_ERROR_NONE)
+               goto failed;
+
+       if (error)
+               *error = TDM_ERROR_NONE;
+
+       TDM_INFO("init success!");
+
+       return (tdm_backend_data *)drm_data;
 failed:
-    if (error)
-        *error = ret;
+       if (error)
+               *error = ret;
 
-    tdm_drm_deinit(drm_data);
+       tdm_drm_deinit(drm_data);
 
-    TDM_ERR("init failed!");
-    return NULL;
+       TDM_ERR("init failed!");
+       return NULL;
 }
 
-tdm_backend_module tdm_backend_module_data =
-{
-    "vigs",
-    "Samsung",
-    TDM_BACKEND_ABI_VERSION,
-    tdm_drm_init,
-    tdm_drm_deinit
+tdm_backend_module tdm_backend_module_data = {
+       "vigs",
+       "Samsung",
+       TDM_BACKEND_ABI_VERSION,
+       tdm_drm_init,
+       tdm_drm_deinit
 };
index 315ec5a..3839481 100644 (file)
@@ -14,318 +14,293 @@ typedef struct _tdm_drm_output_data tdm_drm_output_data;
 typedef struct _tdm_drm_layer_data tdm_drm_layer_data;
 typedef struct _tdm_drm_event_data tdm_drm_event_data;
 
-typedef enum
-{
-    TDM_DRM_EVENT_TYPE_WAIT,
-    TDM_DRM_EVENT_TYPE_COMMIT,
-    TDM_DRM_EVENT_TYPE_PAGEFLIP,
+typedef enum {
+        TDM_DRM_EVENT_TYPE_WAIT,
+        TDM_DRM_EVENT_TYPE_COMMIT,
+        TDM_DRM_EVENT_TYPE_PAGEFLIP,
 } tdm_drm_event_type;
 
-typedef struct _tdm_drm_display_buffer
-{
-    struct list_head link;
+typedef struct _tdm_drm_display_buffer {
+       struct list_head link;
 
-    unsigned int fb_id;
-    tbm_surface_h buffer;
-    int width;
+       unsigned int fb_id;
+       tbm_surface_h buffer;
+       int width;
 } tdm_drm_display_buffer;
 
-struct _tdm_drm_event_data
-{
-    tdm_drm_event_type type;
-    tdm_drm_output_data *output_data;
-    void *user_data;
+struct _tdm_drm_event_data {
+       tdm_drm_event_type type;
+       tdm_drm_output_data *output_data;
+       void *user_data;
 };
 
-struct _tdm_drm_output_data
-{
-    struct list_head link;
-
-    /* data which are fixed at initializing */
-    tdm_drm_data *drm_data;
-    uint32_t connector_id;
-    uint32_t encoder_id;
-    uint32_t crtc_id;
-    uint32_t pipe;
-    uint32_t dpms_prop_id;
-    int count_modes;
-    drmModeModeInfoPtr drm_modes;
-    tdm_output_mode *output_modes;
-    tdm_output_type connector_type;
-    unsigned int connector_type_id;
-    struct list_head layer_list;
-    tdm_drm_layer_data *primary_layer;
-
-    /* not fixed data below */
-    tdm_output_vblank_handler vblank_func;
-    tdm_output_commit_handler commit_func;
-
-    tdm_output_conn_status status;
-
-    int mode_changed;
-    const tdm_output_mode *current_mode;
+struct _tdm_drm_output_data {
+       struct list_head link;
+
+       /* data which are fixed at initializing */
+       tdm_drm_data *drm_data;
+       uint32_t connector_id;
+       uint32_t encoder_id;
+       uint32_t crtc_id;
+       uint32_t pipe;
+       uint32_t dpms_prop_id;
+       int count_modes;
+       drmModeModeInfoPtr drm_modes;
+       tdm_output_mode *output_modes;
+       tdm_output_type connector_type;
+       unsigned int connector_type_id;
+       struct list_head layer_list;
+       tdm_drm_layer_data *primary_layer;
+
+       /* not fixed data below */
+       tdm_output_vblank_handler vblank_func;
+       tdm_output_commit_handler commit_func;
+
+       tdm_output_conn_status status;
+
+       int mode_changed;
+       const tdm_output_mode *current_mode;
 };
 
-struct _tdm_drm_layer_data
-{
-    struct list_head link;
+struct _tdm_drm_layer_data {
+       struct list_head link;
 
-    /* data which are fixed at initializing */
-    tdm_drm_data *drm_data;
-    tdm_drm_output_data *output_data;
-    uint32_t plane_id;
-    tdm_layer_capability capabilities;
-    int zpos;
+       /* data which are fixed at initializing */
+       tdm_drm_data *drm_data;
+       tdm_drm_output_data *output_data;
+       uint32_t plane_id;
+       tdm_layer_capability capabilities;
+       int zpos;
 
-    /* not fixed data below */
-    tdm_info_layer info;
-    int info_changed;
+       /* not fixed data below */
+       tdm_info_layer info;
+       int info_changed;
 
-    tdm_drm_display_buffer *display_buffer;
-    int display_buffer_changed;
+       tdm_drm_display_buffer *display_buffer;
+       int display_buffer_changed;
 };
 
 static drmModeModeInfoPtr
 _tdm_drm_display_get_mode(tdm_drm_output_data *output_data)
 {
-    int i;
-
-    if (!output_data->current_mode)
-    {
-        TDM_ERR("no output_data->current_mode");
-        return NULL;
-    }
-
-    for (i = 0; i < output_data->count_modes; i++)
-    {
-        drmModeModeInfoPtr drm_mode = &output_data->drm_modes[i];
-        if ((drm_mode->hdisplay == output_data->current_mode->hdisplay) &&
-            (drm_mode->vdisplay == output_data->current_mode->vdisplay) &&
-            (drm_mode->vrefresh == output_data->current_mode->vrefresh) &&
-            (drm_mode->flags == output_data->current_mode->flags) &&
-            (drm_mode->type == output_data->current_mode->type) &&
-            !(strncmp(drm_mode->name, output_data->current_mode->name, TDM_NAME_LEN)))
-            return drm_mode;
-    }
-
-    return NULL;
+       int i;
+
+       if (!output_data->current_mode) {
+               TDM_ERR("no output_data->current_mode");
+               return NULL;
+       }
+
+       for (i = 0; i < output_data->count_modes; i++) {
+               drmModeModeInfoPtr drm_mode = &output_data->drm_modes[i];
+               if ((drm_mode->hdisplay == output_data->current_mode->hdisplay) &&
+                   (drm_mode->vdisplay == output_data->current_mode->vdisplay) &&
+                   (drm_mode->vrefresh == output_data->current_mode->vrefresh) &&
+                   (drm_mode->flags == output_data->current_mode->flags) &&
+                   (drm_mode->type == output_data->current_mode->type) &&
+                   !(strncmp(drm_mode->name, output_data->current_mode->name, TDM_NAME_LEN)))
+                       return drm_mode;
+       }
+
+       return NULL;
 }
 
-static tdm_drm_display_buffer*
+static tdm_drm_display_buffer *
 _tdm_drm_display_find_buffer(tdm_drm_data *drm_data, tbm_surface_h buffer)
 {
-    tdm_drm_display_buffer *display_buffer = NULL;
+       tdm_drm_display_buffer *display_buffer = NULL;
 
-    LIST_FOR_EACH_ENTRY(display_buffer, &drm_data->buffer_list, link)
-    {
-        if (display_buffer->buffer == buffer)
-            return display_buffer;
-    }
+       LIST_FOR_EACH_ENTRY(display_buffer, &drm_data->buffer_list, link) {
+               if (display_buffer->buffer == buffer)
+                       return display_buffer;
+       }
 
-    return NULL;
+       return NULL;
 }
 
 static void
-_tdm_drm_display_to_tdm_mode(drmModeModeInfoPtr drm_mode, tdm_output_mode *tdm_mode)
+_tdm_drm_display_to_tdm_mode(drmModeModeInfoPtr drm_mode,
+                             tdm_output_mode *tdm_mode)
 {
-    tdm_mode->clock = drm_mode->clock;
-    tdm_mode->hdisplay = drm_mode->hdisplay;
-    tdm_mode->hsync_start = drm_mode->hsync_start;
-    tdm_mode->hsync_end = drm_mode->hsync_end;
-    tdm_mode->htotal = drm_mode->htotal;
-    tdm_mode->hskew = drm_mode->hskew;
-    tdm_mode->vdisplay = drm_mode->vdisplay;
-    tdm_mode->vsync_start = drm_mode->vsync_start;
-    tdm_mode->vsync_end = drm_mode->vsync_end;
-    tdm_mode->vtotal = drm_mode->vtotal;
-    tdm_mode->vscan = drm_mode->vscan;
-    tdm_mode->vrefresh = drm_mode->vrefresh;
-    tdm_mode->flags = drm_mode->flags;
-    tdm_mode->type = drm_mode->type;
-    snprintf(tdm_mode->name, TDM_NAME_LEN, "%s", drm_mode->name);
+       tdm_mode->clock = drm_mode->clock;
+       tdm_mode->hdisplay = drm_mode->hdisplay;
+       tdm_mode->hsync_start = drm_mode->hsync_start;
+       tdm_mode->hsync_end = drm_mode->hsync_end;
+       tdm_mode->htotal = drm_mode->htotal;
+       tdm_mode->hskew = drm_mode->hskew;
+       tdm_mode->vdisplay = drm_mode->vdisplay;
+       tdm_mode->vsync_start = drm_mode->vsync_start;
+       tdm_mode->vsync_end = drm_mode->vsync_end;
+       tdm_mode->vtotal = drm_mode->vtotal;
+       tdm_mode->vscan = drm_mode->vscan;
+       tdm_mode->vrefresh = drm_mode->vrefresh;
+       tdm_mode->flags = drm_mode->flags;
+       tdm_mode->type = drm_mode->type;
+       snprintf(tdm_mode->name, TDM_NAME_LEN, "%s", drm_mode->name);
 }
 
 static tdm_error
 _tdm_drm_display_get_cur_msc (int fd, int pipe, uint *msc)
 {
-    drmVBlank vbl;
+       drmVBlank vbl;
 
-    vbl.request.type = DRM_VBLANK_RELATIVE;
-    if (pipe > 0)
-        vbl.request.type |= DRM_VBLANK_SECONDARY;
+       vbl.request.type = DRM_VBLANK_RELATIVE;
+       if (pipe > 0)
+               vbl.request.type |= DRM_VBLANK_SECONDARY;
 
-    vbl.request.sequence = 0;
-    if (drmWaitVBlank(fd, &vbl))
-    {
-        TDM_ERR("get vblank counter failed: %m");
-        *msc = 0;
-        return TDM_ERROR_OPERATION_FAILED;
-    }
+       vbl.request.sequence = 0;
+       if (drmWaitVBlank(fd, &vbl)) {
+               TDM_ERR("get vblank counter failed: %m");
+               *msc = 0;
+               return TDM_ERROR_OPERATION_FAILED;
+       }
 
-    *msc = vbl.reply.sequence;
+       *msc = vbl.reply.sequence;
 
-    return TDM_ERROR_NONE;
+       return TDM_ERROR_NONE;
 }
 
 static tdm_error
 _tdm_drm_display_wait_vblank(int fd, int pipe, uint *target_msc, void *data)
 {
-    drmVBlank vbl;
+       drmVBlank vbl;
 
-    vbl.request.type =  DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT;
-    if (pipe > 0)
-        vbl.request.type |= DRM_VBLANK_SECONDARY;
+       vbl.request.type =  DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT;
+       if (pipe > 0)
+               vbl.request.type |= DRM_VBLANK_SECONDARY;
 
-    vbl.request.sequence = *target_msc;
-    vbl.request.signal = (unsigned long)(uintptr_t)data;
+       vbl.request.sequence = *target_msc;
+       vbl.request.signal = (unsigned long)(uintptr_t)data;
 
-    if (drmWaitVBlank(fd, &vbl))
-    {
-        *target_msc = 0;
-        TDM_ERR("wait vblank failed: %m");
-        return TDM_ERROR_OPERATION_FAILED;
-    }
+       if (drmWaitVBlank(fd, &vbl)) {
+               *target_msc = 0;
+               TDM_ERR("wait vblank failed: %m");
+               return TDM_ERROR_OPERATION_FAILED;
+       }
 
-    *target_msc = vbl.reply.sequence;
+       *target_msc = vbl.reply.sequence;
 
-    return TDM_ERROR_NONE;
+       return TDM_ERROR_NONE;
 }
 
 static tdm_error
-_tdm_drm_display_commit_primary_layer(tdm_drm_layer_data *layer_data, void *user_data, int *do_waitvblank)
+_tdm_drm_display_commit_primary_layer(tdm_drm_layer_data *layer_data,
+                                      void *user_data, int *do_waitvblank)
 {
-    tdm_drm_data *drm_data = layer_data->drm_data;
-    tdm_drm_output_data *output_data = layer_data->output_data;
-
-    if (output_data->mode_changed && layer_data->display_buffer_changed)
-    {
-        drmModeModeInfoPtr mode;
-
-        if (!layer_data->display_buffer)
-        {
-            TDM_ERR("primary layer should have a buffer for modestting");
-            return TDM_ERROR_BAD_REQUEST;
-        }
-
-        output_data->mode_changed = 0;
-        layer_data->display_buffer_changed = 0;
-        layer_data->info_changed = 0;
-
-        mode = _tdm_drm_display_get_mode(output_data);
-        if (!mode)
-        {
-            TDM_ERR("couldn't find proper mode");
-            return TDM_ERROR_BAD_REQUEST;
-        }
-
-        if (drmModeSetCrtc(drm_data->drm_fd, output_data->crtc_id,
-                           layer_data->display_buffer->fb_id, 0, 0,
-                           &output_data->connector_id, 1, mode))
-        {
-            TDM_ERR("set crtc failed: %m");
-            return TDM_ERROR_OPERATION_FAILED;
-        }
-        *do_waitvblank = 1;
-        return TDM_ERROR_NONE;
-    }
-    else if (layer_data->display_buffer_changed)
-    {
-        layer_data->display_buffer_changed = 0;
-
-        if (!layer_data->display_buffer)
-        {
-            if (drmModeSetCrtc(drm_data->drm_fd, output_data->crtc_id,
-                               0, 0, 0, NULL, 0, NULL))
-            {
-                TDM_ERR("unset crtc failed: %m");
-                return TDM_ERROR_OPERATION_FAILED;
-            }
-            *do_waitvblank = 1;
-        }
-        else
-        {
-            tdm_drm_event_data *event_data = calloc(1, sizeof(tdm_drm_event_data));
-
-            if (!event_data)
-            {
-                TDM_ERR("alloc failed");
-                return TDM_ERROR_OUT_OF_MEMORY;
-            }
-
-            event_data->type = TDM_DRM_EVENT_TYPE_PAGEFLIP;
-            event_data->output_data = output_data;
-            event_data->user_data = user_data;
-            if (drmModePageFlip(drm_data->drm_fd, output_data->crtc_id,
-                                layer_data->display_buffer->fb_id, DRM_MODE_PAGE_FLIP_EVENT, event_data))
-            {
-                TDM_ERR("pageflip failed: %m");
-                return TDM_ERROR_OPERATION_FAILED;
-            }
-            *do_waitvblank = 0;
-        }
-    }
-
-    return TDM_ERROR_NONE;
+       tdm_drm_data *drm_data = layer_data->drm_data;
+       tdm_drm_output_data *output_data = layer_data->output_data;
+
+       if (output_data->mode_changed && layer_data->display_buffer_changed) {
+               drmModeModeInfoPtr mode;
+
+               if (!layer_data->display_buffer) {
+                       TDM_ERR("primary layer should have a buffer for modestting");
+                       return TDM_ERROR_BAD_REQUEST;
+               }
+
+               output_data->mode_changed = 0;
+               layer_data->display_buffer_changed = 0;
+               layer_data->info_changed = 0;
+
+               mode = _tdm_drm_display_get_mode(output_data);
+               if (!mode) {
+                       TDM_ERR("couldn't find proper mode");
+                       return TDM_ERROR_BAD_REQUEST;
+               }
+
+               if (drmModeSetCrtc(drm_data->drm_fd, output_data->crtc_id,
+                                  layer_data->display_buffer->fb_id, 0, 0,
+                                  &output_data->connector_id, 1, mode)) {
+                       TDM_ERR("set crtc failed: %m");
+                       return TDM_ERROR_OPERATION_FAILED;
+               }
+               *do_waitvblank = 1;
+               return TDM_ERROR_NONE;
+       } else if (layer_data->display_buffer_changed) {
+               layer_data->display_buffer_changed = 0;
+
+               if (!layer_data->display_buffer) {
+                       if (drmModeSetCrtc(drm_data->drm_fd, output_data->crtc_id,
+                                          0, 0, 0, NULL, 0, NULL)) {
+                               TDM_ERR("unset crtc failed: %m");
+                               return TDM_ERROR_OPERATION_FAILED;
+                       }
+                       *do_waitvblank = 1;
+               } else {
+                       tdm_drm_event_data *event_data = calloc(1, sizeof(tdm_drm_event_data));
+
+                       if (!event_data) {
+                               TDM_ERR("alloc failed");
+                               return TDM_ERROR_OUT_OF_MEMORY;
+                       }
+
+                       event_data->type = TDM_DRM_EVENT_TYPE_PAGEFLIP;
+                       event_data->output_data = output_data;
+                       event_data->user_data = user_data;
+                       if (drmModePageFlip(drm_data->drm_fd, output_data->crtc_id,
+                                           layer_data->display_buffer->fb_id, DRM_MODE_PAGE_FLIP_EVENT, event_data)) {
+                               TDM_ERR("pageflip failed: %m");
+                               return TDM_ERROR_OPERATION_FAILED;
+                       }
+                       *do_waitvblank = 0;
+               }
+       }
+
+       return TDM_ERROR_NONE;
 }
 
 static tdm_error
 _tdm_drm_display_commit_layer(tdm_drm_layer_data *layer_data)
 {
-    tdm_drm_data *drm_data = layer_data->drm_data;
-    tdm_drm_output_data *output_data = layer_data->output_data;
-    uint32_t fx, fy, fw, fh;
-    int crtc_w;
-
-    if (!layer_data->display_buffer_changed && !layer_data->info_changed)
-        return TDM_ERROR_NONE;
-
-    if (output_data->current_mode)
-        crtc_w = output_data->current_mode->hdisplay;
-    else
-    {
-        drmModeCrtcPtr crtc = drmModeGetCrtc(drm_data->drm_fd, output_data->crtc_id);
-        if (!crtc)
-        {
-            TDM_ERR("getting crtc failed");
-            return TDM_ERROR_OPERATION_FAILED;
-        }
-        crtc_w = crtc->width;
-        if (crtc_w == 0)
-        {
-            TDM_ERR("getting crtc width failed");
-            return TDM_ERROR_OPERATION_FAILED;
-        }
-    }
-
-    layer_data->display_buffer_changed = 0;
-    layer_data->info_changed = 0;
-
-    if (!layer_data->display_buffer)
-    {
-        if (drmModeSetPlane(drm_data->drm_fd, layer_data->plane_id,
-                            output_data->crtc_id, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
-            TDM_ERR("unset plane(%d) filed: %m", layer_data->plane_id);
-
-        return TDM_ERROR_NONE;
-    }
-
-    /* Source values are 16.16 fixed point */
-    fx = ((unsigned int)layer_data->info.src_config.pos.x) << 16;
-    fy = ((unsigned int)layer_data->info.src_config.pos.y) << 16;
-    fw = ((unsigned int)layer_data->info.src_config.pos.w) << 16;
-    fh = ((unsigned int)layer_data->info.src_config.pos.h) << 16;
-
-    if (drmModeSetPlane(drm_data->drm_fd, layer_data->plane_id,
-                        output_data->crtc_id, layer_data->display_buffer->fb_id, 0,
-                        layer_data->info.dst_pos.x, layer_data->info.dst_pos.y,
-                        layer_data->info.dst_pos.w, layer_data->info.dst_pos.h,
-                        fx, fy, fw, fh) < 0)
-    {
-        TDM_ERR("set plane(%d) failed: %m", layer_data->plane_id);
-        return TDM_ERROR_OPERATION_FAILED;
-    }
-
-    return TDM_ERROR_NONE;
+       tdm_drm_data *drm_data = layer_data->drm_data;
+       tdm_drm_output_data *output_data = layer_data->output_data;
+       uint32_t fx, fy, fw, fh;
+       int crtc_w;
+
+       if (!layer_data->display_buffer_changed && !layer_data->info_changed)
+               return TDM_ERROR_NONE;
+
+       if (output_data->current_mode)
+               crtc_w = output_data->current_mode->hdisplay;
+       else {
+               drmModeCrtcPtr crtc = drmModeGetCrtc(drm_data->drm_fd, output_data->crtc_id);
+               if (!crtc) {
+                       TDM_ERR("getting crtc failed");
+                       return TDM_ERROR_OPERATION_FAILED;
+               }
+               crtc_w = crtc->width;
+               if (crtc_w == 0) {
+                       TDM_ERR("getting crtc width failed");
+                       return TDM_ERROR_OPERATION_FAILED;
+               }
+       }
+
+       layer_data->display_buffer_changed = 0;
+       layer_data->info_changed = 0;
+
+       if (!layer_data->display_buffer) {
+               if (drmModeSetPlane(drm_data->drm_fd, layer_data->plane_id,
+                                   output_data->crtc_id, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
+                       TDM_ERR("unset plane(%d) filed: %m", layer_data->plane_id);
+
+               return TDM_ERROR_NONE;
+       }
+
+       /* Source values are 16.16 fixed point */
+       fx = ((unsigned int)layer_data->info.src_config.pos.x) << 16;
+       fy = ((unsigned int)layer_data->info.src_config.pos.y) << 16;
+       fw = ((unsigned int)layer_data->info.src_config.pos.w) << 16;
+       fh = ((unsigned int)layer_data->info.src_config.pos.h) << 16;
+
+       if (drmModeSetPlane(drm_data->drm_fd, layer_data->plane_id,
+                           output_data->crtc_id, layer_data->display_buffer->fb_id, 0,
+                           layer_data->info.dst_pos.x, layer_data->info.dst_pos.y,
+                           layer_data->info.dst_pos.w, layer_data->info.dst_pos.h,
+                           fx, fy, fw, fh) < 0) {
+               TDM_ERR("set plane(%d) failed: %m", layer_data->plane_id);
+               return TDM_ERROR_OPERATION_FAILED;
+       }
+
+       return TDM_ERROR_NONE;
 }
 
 static void
@@ -333,1148 +308,1096 @@ _tdm_drm_display_cb_event(int fd, unsigned int sequence,
                           unsigned int tv_sec, unsigned int tv_usec,
                           void *user_data)
 {
-    tdm_drm_event_data *event_data = user_data;
-    tdm_drm_output_data *output_data;
-
-    if (!event_data)
-    {
-        TDM_ERR("no event data");
-        return;
-    }
-
-    output_data = event_data->output_data;
-
-    switch(event_data->type)
-    {
-    case TDM_DRM_EVENT_TYPE_PAGEFLIP:
-        if (output_data->commit_func)
-            output_data->commit_func(output_data, sequence, tv_sec, tv_usec, event_data->user_data);
-        break;
-    case TDM_DRM_EVENT_TYPE_WAIT:
-        if (output_data->vblank_func)
-            output_data->vblank_func(output_data, sequence, tv_sec, tv_usec, event_data->user_data);
-        break;
-    case TDM_DRM_EVENT_TYPE_COMMIT:
-        if (output_data->commit_func)
-            output_data->commit_func(output_data, sequence, tv_sec, tv_usec, event_data->user_data);
-        break;
-    default:
-        break;
-    }
-
-    free(event_data);
+       tdm_drm_event_data *event_data = user_data;
+       tdm_drm_output_data *output_data;
+
+       if (!event_data) {
+               TDM_ERR("no event data");
+               return;
+       }
+
+       output_data = event_data->output_data;
+
+       switch (event_data->type) {
+       case TDM_DRM_EVENT_TYPE_PAGEFLIP:
+               if (output_data->commit_func)
+                       output_data->commit_func(output_data, sequence, tv_sec, tv_usec,
+                                                event_data->user_data);
+               break;
+       case TDM_DRM_EVENT_TYPE_WAIT:
+               if (output_data->vblank_func)
+                       output_data->vblank_func(output_data, sequence, tv_sec, tv_usec,
+                                                event_data->user_data);
+               break;
+       case TDM_DRM_EVENT_TYPE_COMMIT:
+               if (output_data->commit_func)
+                       output_data->commit_func(output_data, sequence, tv_sec, tv_usec,
+                                                event_data->user_data);
+               break;
+       default:
+               break;
+       }
+
+       free(event_data);
 }
 
 static tdm_error
 _tdm_drm_display_create_layer_list(tdm_drm_data *drm_data)
 {
-    int i;
-
-    if (drm_data->plane_res->count_planes == 0)
-    {
-        TDM_ERR("no layer error");
-        return TDM_ERROR_OPERATION_FAILED;
-    }
-
-    for (i = 0; i < drm_data->plane_res->count_planes; i++)
-    {
-        tdm_drm_output_data *output_data = NULL;
-        tdm_drm_layer_data *layer_data;
-        drmModePlanePtr plane;
-
-        if (i == 3)
-        {
-            TDM_DBG("doesn't need more layer set");
-            break;
-        }
-
-        LIST_FOR_EACH_ENTRY(output_data, &drm_data->output_list, link)
-        {
-            if (output_data->pipe == 0)
-                break;
-        }
-
-        plane = drmModeGetPlane(drm_data->drm_fd, drm_data->plane_res->planes[i]);
-        if (!plane)
-        {
-            TDM_ERR("no plane");
-            continue;
-        }
-
-        layer_data = calloc(1, sizeof(tdm_drm_layer_data));
-        if (!layer_data)
-        {
-            TDM_ERR("alloc failed");
-            drmModeFreePlane(plane);
-            continue;
-        }
-
-        layer_data->drm_data = drm_data;
-        layer_data->output_data = output_data;
-        layer_data->plane_id = drm_data->plane_res->planes[i];
-
-        if (drm_data->plane_res->count_planes == 1)
-        {
-            layer_data->capabilities = TDM_LAYER_CAPABILITY_PRIMARY | TDM_LAYER_CAPABILITY_GRAPHIC;
-            output_data->primary_layer = layer_data;
-        }
-        else if (drm_data->plane_res->count_planes == 2)
-        {
-            if (i == 0)
-            {
-                layer_data->capabilities = TDM_LAYER_CAPABILITY_PRIMARY | TDM_LAYER_CAPABILITY_GRAPHIC;
-                output_data->primary_layer = layer_data;
-            }
-            else
-            {
-                layer_data->capabilities = TDM_LAYER_CAPABILITY_OVERLAY | TDM_LAYER_CAPABILITY_GRAPHIC;
-            }
-        }
-        else
-        {
-            if (i == 0)
-            {
-                layer_data->capabilities = TDM_LAYER_CAPABILITY_CURSOR | TDM_LAYER_CAPABILITY_GRAPHIC;
-            }
-            else if (i == 1)
-            {
-                layer_data->capabilities = TDM_LAYER_CAPABILITY_PRIMARY | TDM_LAYER_CAPABILITY_GRAPHIC;
-                output_data->primary_layer = layer_data;
-            }
-            else
-            {
-                layer_data->capabilities = TDM_LAYER_CAPABILITY_OVERLAY | TDM_LAYER_CAPABILITY_GRAPHIC;
-            }
-        }
-
-        TDM_DBG("layer_data(%p) plane_id(%d) crtc_id(%d) capabilities(%x)",
-                layer_data, layer_data->plane_id, layer_data->output_data->crtc_id,
-                layer_data->capabilities);
-
-        LIST_ADDTAIL(&layer_data->link, &output_data->layer_list);
-
-        drmModeFreePlane(plane);
-    }
-
-    return TDM_ERROR_NONE;
+       int i;
+
+       if (drm_data->plane_res->count_planes == 0) {
+               TDM_ERR("no layer error");
+               return TDM_ERROR_OPERATION_FAILED;
+       }
+
+       for (i = 0; i < drm_data->plane_res->count_planes; i++) {
+               tdm_drm_output_data *output_data = NULL;
+               tdm_drm_layer_data *layer_data;
+               drmModePlanePtr plane;
+
+               if (i == 3) {
+                       TDM_DBG("doesn't need more layer set");
+                       break;
+               }
+
+               LIST_FOR_EACH_ENTRY(output_data, &drm_data->output_list, link) {
+                       if (output_data->pipe == 0)
+                               break;
+               }
+
+               plane = drmModeGetPlane(drm_data->drm_fd, drm_data->plane_res->planes[i]);
+               if (!plane) {
+                       TDM_ERR("no plane");
+                       continue;
+               }
+
+               layer_data = calloc(1, sizeof(tdm_drm_layer_data));
+               if (!layer_data) {
+                       TDM_ERR("alloc failed");
+                       drmModeFreePlane(plane);
+                       continue;
+               }
+
+               layer_data->drm_data = drm_data;
+               layer_data->output_data = output_data;
+               layer_data->plane_id = drm_data->plane_res->planes[i];
+
+               if (drm_data->plane_res->count_planes == 1) {
+                       layer_data->capabilities = TDM_LAYER_CAPABILITY_PRIMARY |
+                                                  TDM_LAYER_CAPABILITY_GRAPHIC;
+                       output_data->primary_layer = layer_data;
+               } else if (drm_data->plane_res->count_planes == 2) {
+                       if (i == 0) {
+                               layer_data->capabilities = TDM_LAYER_CAPABILITY_PRIMARY |
+                                                          TDM_LAYER_CAPABILITY_GRAPHIC;
+                               output_data->primary_layer = layer_data;
+                       } else {
+                               layer_data->capabilities = TDM_LAYER_CAPABILITY_OVERLAY |
+                                                          TDM_LAYER_CAPABILITY_GRAPHIC;
+                       }
+               } else {
+                       if (i == 0) {
+                               layer_data->capabilities = TDM_LAYER_CAPABILITY_CURSOR |
+                                                          TDM_LAYER_CAPABILITY_GRAPHIC;
+                       } else if (i == 1) {
+                               layer_data->capabilities = TDM_LAYER_CAPABILITY_PRIMARY |
+                                                          TDM_LAYER_CAPABILITY_GRAPHIC;
+                               output_data->primary_layer = layer_data;
+                       } else {
+                               layer_data->capabilities = TDM_LAYER_CAPABILITY_OVERLAY |
+                                                          TDM_LAYER_CAPABILITY_GRAPHIC;
+                       }
+               }
+
+               TDM_DBG("layer_data(%p) plane_id(%d) crtc_id(%d) capabilities(%x)",
+                       layer_data, layer_data->plane_id, layer_data->output_data->crtc_id,
+                       layer_data->capabilities);
+
+               LIST_ADDTAIL(&layer_data->link, &output_data->layer_list);
+
+               drmModeFreePlane(plane);
+       }
+
+       return TDM_ERROR_NONE;
 }
 
 static void
 _tdm_drm_display_cb_destroy_buffer(tbm_surface_h buffer, void *user_data)
 {
-    tdm_drm_data *drm_data;
-    tdm_drm_display_buffer *display_buffer;
-    int ret;
-
-    if (!user_data)
-    {
-        TDM_ERR("no user_data");
-        return;
-    }
-    if (!buffer)
-    {
-        TDM_ERR("no buffer");
-        return;
-    }
-
-    drm_data = (tdm_drm_data *)user_data;
-
-    display_buffer = _tdm_drm_display_find_buffer(drm_data, buffer);
-    if (!display_buffer)
-    {
-        TDM_ERR("no display_buffer");
-        return;
-    }
-    LIST_DEL(&display_buffer->link);
-
-    if (display_buffer->fb_id > 0)
-    {
-        ret = drmModeRmFB(drm_data->drm_fd, display_buffer->fb_id);
-        if (ret < 0)
-        {
-            TDM_ERR("rm fb failed");
-            return;
-        }
-        TDM_DBG("drmModeRmFB success!!! fb_id:%d", display_buffer->fb_id);
-    }
-    else
-        TDM_DBG("drmModeRmFB not called fb_id:%d", display_buffer->fb_id);
-
-    free(display_buffer);
+       tdm_drm_data *drm_data;
+       tdm_drm_display_buffer *display_buffer;
+       int ret;
+
+       if (!user_data) {
+               TDM_ERR("no user_data");
+               return;
+       }
+       if (!buffer) {
+               TDM_ERR("no buffer");
+               return;
+       }
+
+       drm_data = (tdm_drm_data *)user_data;
+
+       display_buffer = _tdm_drm_display_find_buffer(drm_data, buffer);
+       if (!display_buffer) {
+               TDM_ERR("no display_buffer");
+               return;
+       }
+       LIST_DEL(&display_buffer->link);
+
+       if (display_buffer->fb_id > 0) {
+               ret = drmModeRmFB(drm_data->drm_fd, display_buffer->fb_id);
+               if (ret < 0) {
+                       TDM_ERR("rm fb failed");
+                       return;
+               }
+               TDM_DBG("drmModeRmFB success!!! fb_id:%d", display_buffer->fb_id);
+       } else
+               TDM_DBG("drmModeRmFB not called fb_id:%d", display_buffer->fb_id);
+
+       free(display_buffer);
 }
 
 tdm_error
 tdm_drm_display_create_layer_list(tdm_drm_data *drm_data)
 {
-    tdm_drm_output_data *output_data = NULL;
-    tdm_error ret;
-
-    ret = _tdm_drm_display_create_layer_list(drm_data);
-    if (ret != TDM_ERROR_NONE)
-        return ret;
-
-    LIST_FOR_EACH_ENTRY(output_data, &drm_data->output_list, link)
-    {
-        if (!output_data->primary_layer)
-        {
-            TDM_ERR("output(%d) no primary layer", output_data->pipe);
-            return TDM_ERROR_OPERATION_FAILED;
-        }
-    }
-
-    return TDM_ERROR_NONE;
+       tdm_drm_output_data *output_data = NULL;
+       tdm_error ret;
+
+       ret = _tdm_drm_display_create_layer_list(drm_data);
+       if (ret != TDM_ERROR_NONE)
+               return ret;
+
+       LIST_FOR_EACH_ENTRY(output_data, &drm_data->output_list, link) {
+               if (!output_data->primary_layer) {
+                       TDM_ERR("output(%d) no primary layer", output_data->pipe);
+                       return TDM_ERROR_OPERATION_FAILED;
+               }
+       }
+
+       return TDM_ERROR_NONE;
 }
 
 void
 tdm_drm_display_destroy_output_list(tdm_drm_data *drm_data)
 {
-    tdm_drm_output_data *o = NULL, *oo = NULL;
-
-    if (LIST_IS_EMPTY(&drm_data->output_list))
-        return;
-
-    LIST_FOR_EACH_ENTRY_SAFE(o, oo, &drm_data->output_list, link)
-    {
-        LIST_DEL(&o->link);
-        if (!LIST_IS_EMPTY(&o->layer_list))
-        {
-            tdm_drm_layer_data *l = NULL, *ll = NULL;
-            LIST_FOR_EACH_ENTRY_SAFE(l, ll, &o->layer_list, link)
-            {
-                LIST_DEL(&l->link);
-                free(l);
-            }
-        }
-        free(o->drm_modes);
-        free(o->output_modes);
-        free(o);
-    }
+       tdm_drm_output_data *o = NULL, *oo = NULL;
+
+       if (LIST_IS_EMPTY(&drm_data->output_list))
+               return;
+
+       LIST_FOR_EACH_ENTRY_SAFE(o, oo, &drm_data->output_list, link) {
+               LIST_DEL(&o->link);
+               if (!LIST_IS_EMPTY(&o->layer_list)) {
+                       tdm_drm_layer_data *l = NULL, *ll = NULL;
+                       LIST_FOR_EACH_ENTRY_SAFE(l, ll, &o->layer_list, link) {
+                               LIST_DEL(&l->link);
+                               free(l);
+                       }
+               }
+               free(o->drm_modes);
+               free(o->output_modes);
+               free(o);
+       }
 }
 
 tdm_error
 tdm_drm_display_create_output_list(tdm_drm_data *drm_data)
 {
-    tdm_drm_output_data *output_data;
-    int i;
-    tdm_error ret;
-    int allocated = 0;
-
-    RETURN_VAL_IF_FAIL(LIST_IS_EMPTY(&drm_data->output_list), TDM_ERROR_OPERATION_FAILED);
-
-    for (i = 0; i < drm_data->mode_res->count_connectors; i++)
-    {
-        drmModeConnectorPtr connector;
-        drmModeEncoderPtr encoder;
-        int crtc_id = 0, c, j;
-
-        connector = drmModeGetConnector(drm_data->drm_fd, drm_data->mode_res->connectors[i]);
-        if (!connector)
-        {
-            TDM_ERR("no connector");
-            ret = TDM_ERROR_OPERATION_FAILED;
-            goto failed_create;
-        }
-
-        if (connector->count_encoders != 1)
-        {
-            TDM_ERR("too many encoders: %d", connector->count_encoders);
-            drmModeFreeConnector(connector);
-            ret = TDM_ERROR_OPERATION_FAILED;
-            goto failed_create;
-        }
-
-        encoder = drmModeGetEncoder(drm_data->drm_fd, connector->encoders[0]);
-        if (!encoder)
-        {
-            TDM_ERR("no encoder");
-            drmModeFreeConnector(connector);
-            ret = TDM_ERROR_OPERATION_FAILED;
-            goto failed_create;
-        }
-
-        for (c = 0; c < drm_data->mode_res->count_crtcs; c++)
-        {
-            if (allocated & (1 << c))
-                continue;
-
-            if ((encoder->possible_crtcs & (1 << c)) == 0)
-                continue;
-
-            crtc_id = drm_data->mode_res->crtcs[c];
-            allocated |= (1 << c);
-            break;
-        }
-
-        if (crtc_id == 0)
-        {
-            TDM_ERR("no possible crtc");
-            drmModeFreeConnector(connector);
-            ret = TDM_ERROR_OPERATION_FAILED;
-            goto failed_create;
-        }
-
-        output_data = calloc(1, sizeof(tdm_drm_output_data));
-        if (!output_data)
-        {
-            TDM_ERR("alloc failed");
-            drmModeFreeConnector(connector);
-            drmModeFreeEncoder(encoder);
-            ret = TDM_ERROR_OUT_OF_MEMORY;
-            goto failed_create;
-        }
-
-        LIST_INITHEAD(&output_data->layer_list);
-
-        output_data->drm_data = drm_data;
-        output_data->connector_id = drm_data->mode_res->connectors[i];
-        output_data->encoder_id = encoder->encoder_id;
-        output_data->crtc_id = crtc_id;
-        output_data->pipe = c;
-        output_data->connector_type = connector->connector_type;
-        output_data->connector_type_id = connector->connector_type_id;
-
-        if (connector->connection == DRM_MODE_CONNECTED)
-            output_data->status = TDM_OUTPUT_CONN_STATUS_CONNECTED;
-        else
-            output_data->status = TDM_OUTPUT_CONN_STATUS_DISCONNECTED;
-
-        for (j = 0; j < connector->count_props; j++)
-        {
-            drmModePropertyPtr prop = drmModeGetProperty(drm_data->drm_fd, connector->props[i]);
-            if (!prop)
-                continue;
-            if (!strcmp(prop->name, "DPMS"))
-            {
-                output_data->dpms_prop_id = connector->props[i];
-                drmModeFreeProperty(prop);
-                break;
-            }
-            drmModeFreeProperty(prop);
-        }
-
-        output_data->count_modes = connector->count_modes;
-        output_data->drm_modes = calloc(connector->count_modes, sizeof(drmModeModeInfo));
-        if (!output_data->drm_modes)
-        {
-            TDM_ERR("alloc failed");
-            free(output_data);
-            drmModeFreeConnector(connector);
-            drmModeFreeEncoder(encoder);
-            ret = TDM_ERROR_OUT_OF_MEMORY;
-            goto failed_create;
-        }
-        output_data->output_modes = calloc(connector->count_modes, sizeof(tdm_output_mode));
-        if (!output_data->output_modes)
-        {
-            TDM_ERR("alloc failed");
-            free(output_data->drm_modes);
-            free(output_data);
-            drmModeFreeConnector(connector);
-            drmModeFreeEncoder(encoder);
-            ret = TDM_ERROR_OUT_OF_MEMORY;
-            goto failed_create;
-        }
-        for (j = 0; j < connector->count_modes; j++)
-        {
-            output_data->drm_modes[j] = connector->modes[j];
-            _tdm_drm_display_to_tdm_mode(&output_data->drm_modes[j], &output_data->output_modes[j]);
-        }
-
-        LIST_ADDTAIL(&output_data->link, &drm_data->output_list);
-
-        TDM_DBG("output_data(%p) connector_id(%d:%d:%d-%d) encoder_id(%d) crtc_id(%d) pipe(%d) dpms_id(%d)",
-                output_data, output_data->connector_id, output_data->status, output_data->connector_type,
-                output_data->connector_type_id, output_data->encoder_id, output_data->crtc_id,
-                output_data->pipe, output_data->dpms_prop_id);
-
-        drmModeFreeEncoder(encoder);
-        drmModeFreeConnector(connector);
-    }
-
-    TDM_DBG("output count: %d", drm_data->mode_res->count_connectors);
-
-    return TDM_ERROR_NONE;
+       tdm_drm_output_data *output_data;
+       int i;
+       tdm_error ret;
+       int allocated = 0;
+
+       RETURN_VAL_IF_FAIL(LIST_IS_EMPTY(&drm_data->output_list),
+                          TDM_ERROR_OPERATION_FAILED);
+
+       for (i = 0; i < drm_data->mode_res->count_connectors; i++) {
+               drmModeConnectorPtr connector;
+               drmModeEncoderPtr encoder;
+               int crtc_id = 0, c, j;
+
+               connector = drmModeGetConnector(drm_data->drm_fd,
+                                               drm_data->mode_res->connectors[i]);
+               if (!connector) {
+                       TDM_ERR("no connector");
+                       ret = TDM_ERROR_OPERATION_FAILED;
+                       goto failed_create;
+               }
+
+               if (connector->count_encoders != 1) {
+                       TDM_ERR("too many encoders: %d", connector->count_encoders);
+                       drmModeFreeConnector(connector);
+                       ret = TDM_ERROR_OPERATION_FAILED;
+                       goto failed_create;
+               }
+
+               encoder = drmModeGetEncoder(drm_data->drm_fd, connector->encoders[0]);
+               if (!encoder) {
+                       TDM_ERR("no encoder");
+                       drmModeFreeConnector(connector);
+                       ret = TDM_ERROR_OPERATION_FAILED;
+                       goto failed_create;
+               }
+
+               for (c = 0; c < drm_data->mode_res->count_crtcs; c++) {
+                       if (allocated & (1 << c))
+                               continue;
+
+                       if ((encoder->possible_crtcs & (1 << c)) == 0)
+                               continue;
+
+                       crtc_id = drm_data->mode_res->crtcs[c];
+                       allocated |= (1 << c);
+                       break;
+               }
+
+               if (crtc_id == 0) {
+                       TDM_ERR("no possible crtc");
+                       drmModeFreeConnector(connector);
+                       ret = TDM_ERROR_OPERATION_FAILED;
+                       goto failed_create;
+               }
+
+               output_data = calloc(1, sizeof(tdm_drm_output_data));
+               if (!output_data) {
+                       TDM_ERR("alloc failed");
+                       drmModeFreeConnector(connector);
+                       drmModeFreeEncoder(encoder);
+                       ret = TDM_ERROR_OUT_OF_MEMORY;
+                       goto failed_create;
+               }
+
+               LIST_INITHEAD(&output_data->layer_list);
+
+               output_data->drm_data = drm_data;
+               output_data->connector_id = drm_data->mode_res->connectors[i];
+               output_data->encoder_id = encoder->encoder_id;
+               output_data->crtc_id = crtc_id;
+               output_data->pipe = c;
+               output_data->connector_type = connector->connector_type;
+               output_data->connector_type_id = connector->connector_type_id;
+
+               if (connector->connection == DRM_MODE_CONNECTED)
+                       output_data->status = TDM_OUTPUT_CONN_STATUS_CONNECTED;
+               else
+                       output_data->status = TDM_OUTPUT_CONN_STATUS_DISCONNECTED;
+
+               for (j = 0; j < connector->count_props; j++) {
+                       drmModePropertyPtr prop = drmModeGetProperty(drm_data->drm_fd,
+                                                 connector->props[i]);
+                       if (!prop)
+                               continue;
+                       if (!strcmp(prop->name, "DPMS")) {
+                               output_data->dpms_prop_id = connector->props[i];
+                               drmModeFreeProperty(prop);
+                               break;
+                       }
+                       drmModeFreeProperty(prop);
+               }
+
+               output_data->count_modes = connector->count_modes;
+               output_data->drm_modes = calloc(connector->count_modes,
+                                               sizeof(drmModeModeInfo));
+               if (!output_data->drm_modes) {
+                       TDM_ERR("alloc failed");
+                       free(output_data);
+                       drmModeFreeConnector(connector);
+                       drmModeFreeEncoder(encoder);
+                       ret = TDM_ERROR_OUT_OF_MEMORY;
+                       goto failed_create;
+               }
+               output_data->output_modes = calloc(connector->count_modes,
+                                                  sizeof(tdm_output_mode));
+               if (!output_data->output_modes) {
+                       TDM_ERR("alloc failed");
+                       free(output_data->drm_modes);
+                       free(output_data);
+                       drmModeFreeConnector(connector);
+                       drmModeFreeEncoder(encoder);
+                       ret = TDM_ERROR_OUT_OF_MEMORY;
+                       goto failed_create;
+               }
+               for (j = 0; j < connector->count_modes; j++) {
+                       output_data->drm_modes[j] = connector->modes[j];
+                       _tdm_drm_display_to_tdm_mode(&output_data->drm_modes[j],
+                                                    &output_data->output_modes[j]);
+               }
+
+               LIST_ADDTAIL(&output_data->link, &drm_data->output_list);
+
+               TDM_DBG("output_data(%p) connector_id(%d:%d:%d-%d) encoder_id(%d) crtc_id(%d) pipe(%d) dpms_id(%d)",
+                       output_data, output_data->connector_id, output_data->status,
+                       output_data->connector_type,
+                       output_data->connector_type_id, output_data->encoder_id, output_data->crtc_id,
+                       output_data->pipe, output_data->dpms_prop_id);
+
+               drmModeFreeEncoder(encoder);
+               drmModeFreeConnector(connector);
+       }
+
+       TDM_DBG("output count: %d", drm_data->mode_res->count_connectors);
+
+       return TDM_ERROR_NONE;
 failed_create:
-    tdm_drm_display_destroy_output_list(drm_data);
-    return ret;
+       tdm_drm_display_destroy_output_list(drm_data);
+       return ret;
 }
 
 tdm_error
 drm_display_get_capabilitiy(tdm_backend_data *bdata, tdm_caps_display *caps)
 {
-    RETURN_VAL_IF_FAIL(caps, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(caps, TDM_ERROR_INVALID_PARAMETER);
 
-    caps->max_layer_count = -1; /* not defined */
+       caps->max_layer_count = -1; /* not defined */
 
-    return TDM_ERROR_NONE;
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
 drm_display_get_pp_capability(tdm_backend_data *bdata, tdm_caps_pp *caps)
 {
-    return tdm_drm_pp_get_capability(bdata, caps);
+       return tdm_drm_pp_get_capability(bdata, caps);
 }
 
-tdm_output**
+tdm_output **
 drm_display_get_outputs(tdm_backend_data *bdata, int *count, tdm_error *error)
 {
-    tdm_drm_data *drm_data = bdata;
-    tdm_drm_output_data *output_data = NULL;
-    tdm_output **outputs;
-    tdm_error ret;
-    int i;
-
-    RETURN_VAL_IF_FAIL(drm_data, NULL);
-    RETURN_VAL_IF_FAIL(count, NULL);
-
-    *count = 0;
-    LIST_FOR_EACH_ENTRY(output_data, &drm_data->output_list, link)
-        (*count)++;
-
-    if (*count == 0)
-    {
-        ret = TDM_ERROR_NONE;
-        goto failed_get;
-    }
-
-    /* will be freed in frontend */
-    outputs = calloc(*count, sizeof(tdm_drm_output_data*));
-    if (!outputs)
-    {
-        TDM_ERR("failed: alloc memory");
-        *count = 0;
-        ret = TDM_ERROR_OUT_OF_MEMORY;
-        goto failed_get;
-    }
-
-    i = 0;
-    LIST_FOR_EACH_ENTRY(output_data, &drm_data->output_list, link)
-        outputs[i++] = output_data;
-
-    if (error)
-        *error = TDM_ERROR_NONE;
-
-    return outputs;
+       tdm_drm_data *drm_data = bdata;
+       tdm_drm_output_data *output_data = NULL;
+       tdm_output **outputs;
+       tdm_error ret;
+       int i;
+
+       RETURN_VAL_IF_FAIL(drm_data, NULL);
+       RETURN_VAL_IF_FAIL(count, NULL);
+
+       *count = 0;
+       LIST_FOR_EACH_ENTRY(output_data, &drm_data->output_list, link)
+       (*count)++;
+
+       if (*count == 0) {
+               ret = TDM_ERROR_NONE;
+               goto failed_get;
+       }
+
+       /* will be freed in frontend */
+       outputs = calloc(*count, sizeof(tdm_drm_output_data *));
+       if (!outputs) {
+               TDM_ERR("failed: alloc memory");
+               *count = 0;
+               ret = TDM_ERROR_OUT_OF_MEMORY;
+               goto failed_get;
+       }
+
+       i = 0;
+       LIST_FOR_EACH_ENTRY(output_data, &drm_data->output_list, link)
+       outputs[i++] = output_data;
+
+       if (error)
+               *error = TDM_ERROR_NONE;
+
+       return outputs;
 failed_get:
-    if (error)
-        *error = ret;
-    return NULL;
+       if (error)
+               *error = ret;
+       return NULL;
 }
 
 tdm_error
 drm_display_get_fd(tdm_backend_data *bdata, int *fd)
 {
-    tdm_drm_data *drm_data = bdata;
+       tdm_drm_data *drm_data = bdata;
 
-    RETURN_VAL_IF_FAIL(drm_data, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(fd, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(drm_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(fd, TDM_ERROR_INVALID_PARAMETER);
 
-    *fd = drm_data->drm_fd;
+       *fd = drm_data->drm_fd;
 
-    return TDM_ERROR_NONE;
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
 drm_display_handle_events(tdm_backend_data *bdata)
 {
-    tdm_drm_data *drm_data = bdata;
-    drmEventContext ctx;
+       tdm_drm_data *drm_data = bdata;
+       drmEventContext ctx;
 
-    RETURN_VAL_IF_FAIL(drm_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(drm_data, TDM_ERROR_INVALID_PARAMETER);
 
-    memset(&ctx, 0, sizeof(drmEventContext));
+       memset(&ctx, 0, sizeof(drmEventContext));
 
-    ctx.version = DRM_EVENT_CONTEXT_VERSION;
-    ctx.page_flip_handler = _tdm_drm_display_cb_event;
-    ctx.vblank_handler = _tdm_drm_display_cb_event;
+       ctx.version = DRM_EVENT_CONTEXT_VERSION;
+       ctx.page_flip_handler = _tdm_drm_display_cb_event;
+       ctx.vblank_handler = _tdm_drm_display_cb_event;
 
-    drmHandleEvent(drm_data->drm_fd, &ctx);
+       drmHandleEvent(drm_data->drm_fd, &ctx);
 
-    return TDM_ERROR_NONE;
+       return TDM_ERROR_NONE;
 }
 
-tdm_pp*
+tdm_pp *
 drm_display_create_pp(tdm_backend_data *bdata, tdm_error *error)
 {
-    tdm_drm_data *drm_data = bdata;
+       tdm_drm_data *drm_data = bdata;
 
-    RETURN_VAL_IF_FAIL(drm_data, NULL);
+       RETURN_VAL_IF_FAIL(drm_data, NULL);
 
-    return tdm_drm_pp_create(drm_data, error);
+       return tdm_drm_pp_create(drm_data, error);
 }
 
 tdm_error
 drm_output_get_capability(tdm_output *output, tdm_caps_output *caps)
 {
-    tdm_drm_output_data *output_data = output;
-    tdm_drm_data *drm_data;
-    drmModeConnectorPtr connector = NULL;
-    drmModeCrtcPtr crtc = NULL;
-    drmModeObjectPropertiesPtr props = NULL;
-    int i;
-    tdm_error ret;
-
-    RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(caps, TDM_ERROR_INVALID_PARAMETER);
-
-    memset(caps, 0, sizeof(tdm_caps_output));
-
-    drm_data = output_data->drm_data;
-
-    snprintf(caps->maker, TDM_NAME_LEN, "unknown");
-    snprintf(caps->model, TDM_NAME_LEN, "unknown");
-    snprintf(caps->name, TDM_NAME_LEN, "unknown");
-
-    caps->status = output_data->status;
-    caps->type = output_data->connector_type;
-    caps->type_id = output_data->connector_type_id;
-
-    connector = drmModeGetConnector(drm_data->drm_fd, output_data->connector_id);
-    RETURN_VAL_IF_FAIL(connector, TDM_ERROR_OPERATION_FAILED);
-
-    caps->mode_count = connector->count_modes;
-    caps->modes = calloc(1, sizeof(tdm_output_mode) * caps->mode_count);
-    if (!caps->modes)
-    {
-        ret = TDM_ERROR_OUT_OF_MEMORY;
-        TDM_ERR("alloc failed\n");
-        goto failed_get;
-    }
-    for (i = 0; i < caps->mode_count; i++)
-        caps->modes[i] = output_data->output_modes[i];
-
-    caps->mmWidth = connector->mmWidth;
-    caps->mmHeight = connector->mmHeight;
-    caps->subpixel = connector->subpixel;
-
-    caps->min_w = drm_data->mode_res->min_width;
-    caps->min_h = drm_data->mode_res->min_height;
-    caps->max_w = drm_data->mode_res->max_width;
-    caps->max_h = drm_data->mode_res->max_height;
-    caps->preferred_align = -1;
-
-    crtc = drmModeGetCrtc(drm_data->drm_fd, output_data->crtc_id);
-    if (!crtc)
-    {
-        ret = TDM_ERROR_OPERATION_FAILED;
-        TDM_ERR("get crtc failed: %m\n");
-        goto failed_get;
-    }
-
-    props = drmModeObjectGetProperties(drm_data->drm_fd, output_data->crtc_id, DRM_MODE_OBJECT_CRTC);
-    if (!props)
-    {
-        ret = TDM_ERROR_OPERATION_FAILED;
-        TDM_ERR("get crtc properties failed: %m\n");
-        goto failed_get;
-    }
-
-    caps->prop_count = props->count_props;
-    caps->props = calloc(1, sizeof(tdm_prop) * caps->prop_count);
-    if (!caps->props)
-    {
-        ret = TDM_ERROR_OUT_OF_MEMORY;
-        TDM_ERR("alloc failed\n");
-        goto failed_get;
-    }
-
-    for (i = 0; i < caps->prop_count; i++)
-    {
-        drmModePropertyPtr prop = drmModeGetProperty(drm_data->drm_fd, props->props[i]);
-        if (!prop)
-            continue;
-        snprintf(caps->props[i].name, TDM_NAME_LEN, "%s", prop->name);
-        caps->props[i].id = props->props[i];
-        drmModeFreeProperty(prop);
-    }
-
-    drmModeFreeObjectProperties(props);
-    drmModeFreeCrtc(crtc);
-    drmModeFreeConnector(connector);
-
-    return TDM_ERROR_NONE;
+       tdm_drm_output_data *output_data = output;
+       tdm_drm_data *drm_data;
+       drmModeConnectorPtr connector = NULL;
+       drmModeCrtcPtr crtc = NULL;
+       drmModeObjectPropertiesPtr props = NULL;
+       int i;
+       tdm_error ret;
+
+       RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(caps, TDM_ERROR_INVALID_PARAMETER);
+
+       memset(caps, 0, sizeof(tdm_caps_output));
+
+       drm_data = output_data->drm_data;
+
+       snprintf(caps->maker, TDM_NAME_LEN, "unknown");
+       snprintf(caps->model, TDM_NAME_LEN, "unknown");
+       snprintf(caps->name, TDM_NAME_LEN, "unknown");
+
+       caps->status = output_data->status;
+       caps->type = output_data->connector_type;
+       caps->type_id = output_data->connector_type_id;
+
+       connector = drmModeGetConnector(drm_data->drm_fd, output_data->connector_id);
+       RETURN_VAL_IF_FAIL(connector, TDM_ERROR_OPERATION_FAILED);
+
+       caps->mode_count = connector->count_modes;
+       caps->modes = calloc(1, sizeof(tdm_output_mode) * caps->mode_count);
+       if (!caps->modes) {
+               ret = TDM_ERROR_OUT_OF_MEMORY;
+               TDM_ERR("alloc failed\n");
+               goto failed_get;
+       }
+       for (i = 0; i < caps->mode_count; i++)
+               caps->modes[i] = output_data->output_modes[i];
+
+       caps->mmWidth = connector->mmWidth;
+       caps->mmHeight = connector->mmHeight;
+       caps->subpixel = connector->subpixel;
+
+       caps->min_w = drm_data->mode_res->min_width;
+       caps->min_h = drm_data->mode_res->min_height;
+       caps->max_w = drm_data->mode_res->max_width;
+       caps->max_h = drm_data->mode_res->max_height;
+       caps->preferred_align = -1;
+
+       crtc = drmModeGetCrtc(drm_data->drm_fd, output_data->crtc_id);
+       if (!crtc) {
+               ret = TDM_ERROR_OPERATION_FAILED;
+               TDM_ERR("get crtc failed: %m\n");
+               goto failed_get;
+       }
+
+       props = drmModeObjectGetProperties(drm_data->drm_fd, output_data->crtc_id,
+                                          DRM_MODE_OBJECT_CRTC);
+       if (!props) {
+               ret = TDM_ERROR_OPERATION_FAILED;
+               TDM_ERR("get crtc properties failed: %m\n");
+               goto failed_get;
+       }
+
+       caps->prop_count = props->count_props;
+       caps->props = calloc(1, sizeof(tdm_prop) * caps->prop_count);
+       if (!caps->props) {
+               ret = TDM_ERROR_OUT_OF_MEMORY;
+               TDM_ERR("alloc failed\n");
+               goto failed_get;
+       }
+
+       for (i = 0; i < caps->prop_count; i++) {
+               drmModePropertyPtr prop = drmModeGetProperty(drm_data->drm_fd, props->props[i]);
+               if (!prop)
+                       continue;
+               snprintf(caps->props[i].name, TDM_NAME_LEN, "%s", prop->name);
+               caps->props[i].id = props->props[i];
+               drmModeFreeProperty(prop);
+       }
+
+       drmModeFreeObjectProperties(props);
+       drmModeFreeCrtc(crtc);
+       drmModeFreeConnector(connector);
+
+       return TDM_ERROR_NONE;
 failed_get:
-    drmModeFreeCrtc(crtc);
-    drmModeFreeObjectProperties(props);
-    drmModeFreeConnector(connector);
-    free(caps->modes);
-    free(caps->props);
-    memset(caps, 0, sizeof(tdm_caps_output));
-    return ret;
+       drmModeFreeCrtc(crtc);
+       drmModeFreeObjectProperties(props);
+       drmModeFreeConnector(connector);
+       free(caps->modes);
+       free(caps->props);
+       memset(caps, 0, sizeof(tdm_caps_output));
+       return ret;
 }
 
-tdm_layer**
+tdm_layer **
 drm_output_get_layers(tdm_output *output,  int *count, tdm_error *error)
 {
-    tdm_drm_output_data *output_data = output;
-    tdm_drm_layer_data *layer_data = NULL;
-    tdm_layer **layers;
-    tdm_error ret;
-    int i;
-
-    RETURN_VAL_IF_FAIL(output_data, NULL);
-    RETURN_VAL_IF_FAIL(count, NULL);
-
-    *count = 0;
-    LIST_FOR_EACH_ENTRY(layer_data, &output_data->layer_list, link)
-        (*count)++;
-
-    if (*count == 0)
-    {
-        ret = TDM_ERROR_NONE;
-        goto failed_get;
-    }
-
-    /* will be freed in frontend */
-    layers = calloc(*count, sizeof(tdm_drm_layer_data*));
-    if (!layers)
-    {
-        TDM_ERR("failed: alloc memory");
-        *count = 0;
-        ret = TDM_ERROR_OUT_OF_MEMORY;
-        goto failed_get;
-    }
-
-    i = 0;
-    LIST_FOR_EACH_ENTRY(layer_data, &output_data->layer_list, link)
-        layers[i++] = layer_data;
-
-    if (error)
-        *error = TDM_ERROR_NONE;
-
-    return layers;
+       tdm_drm_output_data *output_data = output;
+       tdm_drm_layer_data *layer_data = NULL;
+       tdm_layer **layers;
+       tdm_error ret;
+       int i;
+
+       RETURN_VAL_IF_FAIL(output_data, NULL);
+       RETURN_VAL_IF_FAIL(count, NULL);
+
+       *count = 0;
+       LIST_FOR_EACH_ENTRY(layer_data, &output_data->layer_list, link)
+       (*count)++;
+
+       if (*count == 0) {
+               ret = TDM_ERROR_NONE;
+               goto failed_get;
+       }
+
+       /* will be freed in frontend */
+       layers = calloc(*count, sizeof(tdm_drm_layer_data *));
+       if (!layers) {
+               TDM_ERR("failed: alloc memory");
+               *count = 0;
+               ret = TDM_ERROR_OUT_OF_MEMORY;
+               goto failed_get;
+       }
+
+       i = 0;
+       LIST_FOR_EACH_ENTRY(layer_data, &output_data->layer_list, link)
+       layers[i++] = layer_data;
+
+       if (error)
+               *error = TDM_ERROR_NONE;
+
+       return layers;
 failed_get:
-    if (error)
-        *error = ret;
-    return NULL;
+       if (error)
+               *error = ret;
+       return NULL;
 }
 
 tdm_error
 drm_output_set_property(tdm_output *output, unsigned int id, tdm_value value)
 {
-    tdm_drm_output_data *output_data = output;
-    tdm_drm_data *drm_data;
-    int ret;
-
-    RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(output_data->crtc_id > 0, TDM_ERROR_INVALID_PARAMETER);
-
-    drm_data = output_data->drm_data;
-    ret = drmModeObjectSetProperty(drm_data->drm_fd,
-                                   output_data->crtc_id, DRM_MODE_OBJECT_CRTC,
-                                   id, value.u32);
-    if (ret < 0)
-    {
-        TDM_ERR("set property failed: %m");
-        return TDM_ERROR_OPERATION_FAILED;
-    }
-
-    return TDM_ERROR_NONE;
+       tdm_drm_output_data *output_data = output;
+       tdm_drm_data *drm_data;
+       int ret;
+
+       RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(output_data->crtc_id > 0, TDM_ERROR_INVALID_PARAMETER);
+
+       drm_data = output_data->drm_data;
+       ret = drmModeObjectSetProperty(drm_data->drm_fd,
+                                      output_data->crtc_id, DRM_MODE_OBJECT_CRTC,
+                                      id, value.u32);
+       if (ret < 0) {
+               TDM_ERR("set property failed: %m");
+               return TDM_ERROR_OPERATION_FAILED;
+       }
+
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
 drm_output_get_property(tdm_output *output, unsigned int id, tdm_value *value)
 {
-    tdm_drm_output_data *output_data = output;
-    tdm_drm_data *drm_data;
-    drmModeObjectPropertiesPtr props;
-    int i;
-
-    RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(output_data->crtc_id > 0, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(value, TDM_ERROR_INVALID_PARAMETER);
-
-    drm_data = output_data->drm_data;
-    props = drmModeObjectGetProperties(drm_data->drm_fd, output_data->crtc_id, DRM_MODE_OBJECT_CRTC);
-    if (props == NULL)
-    {
-        TDM_ERR("get property failed: %m");
-        return TDM_ERROR_OPERATION_FAILED;
-    }
-
-    for (i = 0; i < props->count_props; i++)
-        if (props->props[i] == id)
-        {
-            (*value).u32 = (uint)props->prop_values[i];
-            break;
-        }
-
-    drmModeFreeObjectProperties(props);
-
-    return TDM_ERROR_NONE;
+       tdm_drm_output_data *output_data = output;
+       tdm_drm_data *drm_data;
+       drmModeObjectPropertiesPtr props;
+       int i;
+
+       RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(output_data->crtc_id > 0, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(value, TDM_ERROR_INVALID_PARAMETER);
+
+       drm_data = output_data->drm_data;
+       props = drmModeObjectGetProperties(drm_data->drm_fd, output_data->crtc_id,
+                                          DRM_MODE_OBJECT_CRTC);
+       if (props == NULL) {
+               TDM_ERR("get property failed: %m");
+               return TDM_ERROR_OPERATION_FAILED;
+       }
+
+       for (i = 0; i < props->count_props; i++)
+               if (props->props[i] == id) {
+                       (*value).u32 = (uint)props->prop_values[i];
+                       break;
+               }
+
+       drmModeFreeObjectProperties(props);
+
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
-drm_output_wait_vblank(tdm_output *output, int interval, int sync, void *user_data)
+drm_output_wait_vblank(tdm_output *output, int interval, int sync,
+                       void *user_data)
 {
-    tdm_drm_output_data *output_data = output;
-    tdm_drm_data *drm_data;
-    tdm_drm_event_data *event_data;
-    uint target_msc;
-    tdm_error ret;
+       tdm_drm_output_data *output_data = output;
+       tdm_drm_data *drm_data;
+       tdm_drm_event_data *event_data;
+       uint target_msc;
+       tdm_error ret;
 
-    RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
 
-    event_data = calloc(1, sizeof(tdm_drm_event_data));
-    if (!event_data)
-    {
-        TDM_ERR("alloc failed");
-        return TDM_ERROR_OUT_OF_MEMORY;
-    }
+       event_data = calloc(1, sizeof(tdm_drm_event_data));
+       if (!event_data) {
+               TDM_ERR("alloc failed");
+               return TDM_ERROR_OUT_OF_MEMORY;
+       }
 
-    drm_data = output_data->drm_data;
+       drm_data = output_data->drm_data;
 
-    ret = _tdm_drm_display_get_cur_msc(drm_data->drm_fd, output_data->pipe, &target_msc);
-    if (ret != TDM_ERROR_NONE)
-        goto failed_vblank;
+       ret = _tdm_drm_display_get_cur_msc(drm_data->drm_fd, output_data->pipe,
+                                          &target_msc);
+       if (ret != TDM_ERROR_NONE)
+               goto failed_vblank;
 
-    target_msc++;
+       target_msc++;
 
-    event_data->type = TDM_DRM_EVENT_TYPE_WAIT;
-    event_data->output_data = output_data;
-    event_data->user_data = user_data;
+       event_data->type = TDM_DRM_EVENT_TYPE_WAIT;
+       event_data->output_data = output_data;
+       event_data->user_data = user_data;
 
-    ret = _tdm_drm_display_wait_vblank(drm_data->drm_fd, output_data->pipe, &target_msc, event_data);
-    if (ret != TDM_ERROR_NONE)
-        goto failed_vblank;
+       ret = _tdm_drm_display_wait_vblank(drm_data->drm_fd, output_data->pipe,
+                                          &target_msc, event_data);
+       if (ret != TDM_ERROR_NONE)
+               goto failed_vblank;
 
-    return TDM_ERROR_NONE;
+       return TDM_ERROR_NONE;
 failed_vblank:
-    free(event_data);
-    return ret;
+       free(event_data);
+       return ret;
 }
 
 tdm_error
-drm_output_set_vblank_handler(tdm_output *output, tdm_output_vblank_handler func)
+drm_output_set_vblank_handler(tdm_output *output,
+                              tdm_output_vblank_handler func)
 {
-    tdm_drm_output_data *output_data = output;
+       tdm_drm_output_data *output_data = output;
 
-    RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(func, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(func, TDM_ERROR_INVALID_PARAMETER);
 
-    output_data->vblank_func = func;
+       output_data->vblank_func = func;
 
-    return TDM_ERROR_NONE;
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
 drm_output_commit(tdm_output *output, int sync, void *user_data)
 {
-    tdm_drm_output_data *output_data = output;
-    tdm_drm_data *drm_data;
-    tdm_drm_layer_data *layer_data = NULL;
-    tdm_error ret;
-    int do_waitvblank = 1;
-
-    RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
-
-    drm_data = output_data->drm_data;
-
-    LIST_FOR_EACH_ENTRY(layer_data, &output_data->layer_list, link)
-    {
-        if (layer_data == output_data->primary_layer)
-        {
-            ret = _tdm_drm_display_commit_primary_layer(layer_data, user_data, &do_waitvblank);
-            if (ret != TDM_ERROR_NONE)
-                return ret;
-        }
-        else
-        {
-            ret = _tdm_drm_display_commit_layer(layer_data);
-            if (ret != TDM_ERROR_NONE)
-                return ret;
-        }
-    }
-
-    if (do_waitvblank == 1)
-    {
-        tdm_drm_event_data *event_data = calloc(1, sizeof(tdm_drm_event_data));
-        uint target_msc;
-
-        if (!event_data)
-        {
-            TDM_ERR("alloc failed");
-            return TDM_ERROR_OUT_OF_MEMORY;
-        }
-
-        ret = _tdm_drm_display_get_cur_msc(drm_data->drm_fd, output_data->pipe, &target_msc);
-        if (ret != TDM_ERROR_NONE)
-        {
-            free(event_data);
-            return ret;
-        }
-
-        target_msc++;
-
-        event_data->type = TDM_DRM_EVENT_TYPE_COMMIT;
-        event_data->output_data = output_data;
-        event_data->user_data = user_data;
-
-        ret = _tdm_drm_display_wait_vblank(drm_data->drm_fd, output_data->pipe, &target_msc, event_data);
-        if (ret != TDM_ERROR_NONE)
-        {
-            free(event_data);
-            return ret;
-        }
-    }
-
-    return TDM_ERROR_NONE;
+       tdm_drm_output_data *output_data = output;
+       tdm_drm_data *drm_data;
+       tdm_drm_layer_data *layer_data = NULL;
+       tdm_error ret;
+       int do_waitvblank = 1;
+
+       RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
+
+       drm_data = output_data->drm_data;
+
+       LIST_FOR_EACH_ENTRY(layer_data, &output_data->layer_list, link) {
+               if (layer_data == output_data->primary_layer) {
+                       ret = _tdm_drm_display_commit_primary_layer(layer_data, user_data,
+                                       &do_waitvblank);
+                       if (ret != TDM_ERROR_NONE)
+                               return ret;
+               } else {
+                       ret = _tdm_drm_display_commit_layer(layer_data);
+                       if (ret != TDM_ERROR_NONE)
+                               return ret;
+               }
+       }
+
+       if (do_waitvblank == 1) {
+               tdm_drm_event_data *event_data = calloc(1, sizeof(tdm_drm_event_data));
+               uint target_msc;
+
+               if (!event_data) {
+                       TDM_ERR("alloc failed");
+                       return TDM_ERROR_OUT_OF_MEMORY;
+               }
+
+               ret = _tdm_drm_display_get_cur_msc(drm_data->drm_fd, output_data->pipe,
+                                                  &target_msc);
+               if (ret != TDM_ERROR_NONE) {
+                       free(event_data);
+                       return ret;
+               }
+
+               target_msc++;
+
+               event_data->type = TDM_DRM_EVENT_TYPE_COMMIT;
+               event_data->output_data = output_data;
+               event_data->user_data = user_data;
+
+               ret = _tdm_drm_display_wait_vblank(drm_data->drm_fd, output_data->pipe,
+                                                  &target_msc, event_data);
+               if (ret != TDM_ERROR_NONE) {
+                       free(event_data);
+                       return ret;
+               }
+       }
+
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
-drm_output_set_commit_handler(tdm_output *output, tdm_output_commit_handler func)
+drm_output_set_commit_handler(tdm_output *output,
+                              tdm_output_commit_handler func)
 {
-    tdm_drm_output_data *output_data = output;
+       tdm_drm_output_data *output_data = output;
 
-    RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(func, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(func, TDM_ERROR_INVALID_PARAMETER);
 
-    output_data->commit_func = func;
+       output_data->commit_func = func;
 
-    return TDM_ERROR_NONE;
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
 drm_output_set_dpms(tdm_output *output, tdm_output_dpms dpms_value)
 {
-    tdm_drm_output_data *output_data = output;
-    tdm_drm_data *drm_data;
-    int ret;
-
-    RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
-
-    drm_data = output_data->drm_data;
-    ret = drmModeObjectSetProperty(drm_data->drm_fd,
-                                   output_data->connector_id, DRM_MODE_OBJECT_CONNECTOR,
-                                   output_data->dpms_prop_id, dpms_value);
-    if (ret < 0)
-    {
-        TDM_ERR("set dpms failed: %m");
-        return TDM_ERROR_OPERATION_FAILED;
-    }
-
-    return TDM_ERROR_NONE;
+       tdm_drm_output_data *output_data = output;
+       tdm_drm_data *drm_data;
+       int ret;
+
+       RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
+
+       drm_data = output_data->drm_data;
+       ret = drmModeObjectSetProperty(drm_data->drm_fd,
+                                      output_data->connector_id, DRM_MODE_OBJECT_CONNECTOR,
+                                      output_data->dpms_prop_id, dpms_value);
+       if (ret < 0) {
+               TDM_ERR("set dpms failed: %m");
+               return TDM_ERROR_OPERATION_FAILED;
+       }
+
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
 drm_output_get_dpms(tdm_output *output, tdm_output_dpms *dpms_value)
 {
-    tdm_drm_output_data *output_data = output;
-    tdm_drm_data *drm_data;
-    drmModeObjectPropertiesPtr props;
-    int i;
-
-    RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(dpms_value, TDM_ERROR_INVALID_PARAMETER);
-
-    drm_data = output_data->drm_data;
-    props = drmModeObjectGetProperties(drm_data->drm_fd, output_data->connector_id, DRM_MODE_OBJECT_CONNECTOR);
-    if (props == NULL)
-    {
-        TDM_ERR("get property failed: %m");
-        return TDM_ERROR_OPERATION_FAILED;
-    }
-
-    for (i = 0; i < props->count_props; i++)
-        if (props->props[i] == output_data->dpms_prop_id)
-        {
-            *dpms_value = (uint)props->prop_values[i];
-            break;
-        }
-
-    drmModeFreeObjectProperties(props);
-
-    return TDM_ERROR_NONE;
+       tdm_drm_output_data *output_data = output;
+       tdm_drm_data *drm_data;
+       drmModeObjectPropertiesPtr props;
+       int i;
+
+       RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(dpms_value, TDM_ERROR_INVALID_PARAMETER);
+
+       drm_data = output_data->drm_data;
+       props = drmModeObjectGetProperties(drm_data->drm_fd, output_data->connector_id,
+                                          DRM_MODE_OBJECT_CONNECTOR);
+       if (props == NULL) {
+               TDM_ERR("get property failed: %m");
+               return TDM_ERROR_OPERATION_FAILED;
+       }
+
+       for (i = 0; i < props->count_props; i++)
+               if (props->props[i] == output_data->dpms_prop_id) {
+                       *dpms_value = (uint)props->prop_values[i];
+                       break;
+               }
+
+       drmModeFreeObjectProperties(props);
+
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
 drm_output_set_mode(tdm_output *output, const tdm_output_mode *mode)
 {
-    tdm_drm_output_data *output_data = output;
+       tdm_drm_output_data *output_data = output;
 
-    RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(mode, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(mode, TDM_ERROR_INVALID_PARAMETER);
 
-    output_data->current_mode = mode;
-    output_data->mode_changed = 1;
+       output_data->current_mode = mode;
+       output_data->mode_changed = 1;
 
-    return TDM_ERROR_NONE;
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
 drm_output_get_mode(tdm_output *output, const tdm_output_mode **mode)
 {
-    tdm_drm_output_data *output_data = output;
+       tdm_drm_output_data *output_data = output;
 
-    RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(mode, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(mode, TDM_ERROR_INVALID_PARAMETER);
 
-    *mode = output_data->current_mode;
+       *mode = output_data->current_mode;
 
-    return TDM_ERROR_NONE;
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
 drm_layer_get_capability(tdm_layer *layer, tdm_caps_layer *caps)
 {
-    tdm_drm_layer_data *layer_data = layer;
-    tdm_drm_data *drm_data;
-    drmModePlanePtr plane = NULL;
-    drmModeObjectPropertiesPtr props = NULL;
-    int i;
-    tdm_error ret;
-
-    RETURN_VAL_IF_FAIL(layer_data, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(caps, TDM_ERROR_INVALID_PARAMETER);
-
-    memset(caps, 0, sizeof(tdm_caps_layer));
-
-    drm_data = layer_data->drm_data;
-    plane = drmModeGetPlane(drm_data->drm_fd, layer_data->plane_id);
-    if (!plane)
-    {
-        TDM_ERR("get plane failed: %m");
-        ret = TDM_ERROR_OPERATION_FAILED;
-        goto failed_get;
-    }
-
-    caps->capabilities = layer_data->capabilities;
-    caps->zpos = layer_data->zpos;  /* if VIDEO layer, zpos is -1 */
-
-    caps->format_count = plane->count_formats;
-    caps->formats = calloc(1, sizeof(tbm_format) * caps->format_count);
-    if (!caps->formats)
-    {
-        ret = TDM_ERROR_OUT_OF_MEMORY;
-        TDM_ERR("alloc failed\n");
-        goto failed_get;
-    }
-
-    for (i = 0; i < caps->format_count; i++)
-    {
-        /* TODO: kernel reports wrong formats */
-        if (plane->formats[i] != DRM_FORMAT_XRGB8888 && plane->formats[i] != DRM_FORMAT_ARGB8888)
-           continue;
-        caps->formats[i] = tdm_drm_format_to_tbm_format(plane->formats[i]);
-    }
-
-    props = drmModeObjectGetProperties(drm_data->drm_fd, layer_data->plane_id, DRM_MODE_OBJECT_PLANE);
-    if (!props)
-    {
-        ret = TDM_ERROR_OPERATION_FAILED;
-        TDM_ERR("get plane properties failed: %m\n");
-        goto failed_get;
-    }
-
-    caps->props = calloc(1, sizeof(tdm_prop) * props->count_props);
-    if (!caps->props)
-    {
-        ret = TDM_ERROR_OUT_OF_MEMORY;
-        TDM_ERR("alloc failed\n");
-        goto failed_get;
-    }
-
-    caps->prop_count = 0;
-    for (i = 0; i < props->count_props; i++)
-    {
-        drmModePropertyPtr prop = drmModeGetProperty(drm_data->drm_fd, props->props[i]);
-        if (!prop)
-            continue;
-        if (!strncmp(prop->name, "type", TDM_NAME_LEN))
-            continue;
-        if (!strncmp(prop->name, "zpos", TDM_NAME_LEN))
-            continue;
-        snprintf(caps->props[i].name, TDM_NAME_LEN, "%s", prop->name);
-        caps->props[i].id = props->props[i];
-        caps->prop_count++;
-        drmModeFreeProperty(prop);
-    }
-
-    drmModeFreeObjectProperties(props);
-    drmModeFreePlane(plane);
-
-    return TDM_ERROR_NONE;
+       tdm_drm_layer_data *layer_data = layer;
+       tdm_drm_data *drm_data;
+       drmModePlanePtr plane = NULL;
+       drmModeObjectPropertiesPtr props = NULL;
+       int i;
+       tdm_error ret;
+
+       RETURN_VAL_IF_FAIL(layer_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(caps, TDM_ERROR_INVALID_PARAMETER);
+
+       memset(caps, 0, sizeof(tdm_caps_layer));
+
+       drm_data = layer_data->drm_data;
+       plane = drmModeGetPlane(drm_data->drm_fd, layer_data->plane_id);
+       if (!plane) {
+               TDM_ERR("get plane failed: %m");
+               ret = TDM_ERROR_OPERATION_FAILED;
+               goto failed_get;
+       }
+
+       caps->capabilities = layer_data->capabilities;
+       caps->zpos = layer_data->zpos;  /* if VIDEO layer, zpos is -1 */
+
+       caps->format_count = plane->count_formats;
+       caps->formats = calloc(1, sizeof(tbm_format) * caps->format_count);
+       if (!caps->formats) {
+               ret = TDM_ERROR_OUT_OF_MEMORY;
+               TDM_ERR("alloc failed\n");
+               goto failed_get;
+       }
+
+       for (i = 0; i < caps->format_count; i++) {
+               /* TODO: kernel reports wrong formats */
+               if (plane->formats[i] != DRM_FORMAT_XRGB8888 &&
+                   plane->formats[i] != DRM_FORMAT_ARGB8888)
+                       continue;
+               caps->formats[i] = tdm_drm_format_to_tbm_format(plane->formats[i]);
+       }
+
+       props = drmModeObjectGetProperties(drm_data->drm_fd, layer_data->plane_id,
+                                          DRM_MODE_OBJECT_PLANE);
+       if (!props) {
+               ret = TDM_ERROR_OPERATION_FAILED;
+               TDM_ERR("get plane properties failed: %m\n");
+               goto failed_get;
+       }
+
+       caps->props = calloc(1, sizeof(tdm_prop) * props->count_props);
+       if (!caps->props) {
+               ret = TDM_ERROR_OUT_OF_MEMORY;
+               TDM_ERR("alloc failed\n");
+               goto failed_get;
+       }
+
+       caps->prop_count = 0;
+       for (i = 0; i < props->count_props; i++) {
+               drmModePropertyPtr prop = drmModeGetProperty(drm_data->drm_fd, props->props[i]);
+               if (!prop)
+                       continue;
+               if (!strncmp(prop->name, "type", TDM_NAME_LEN))
+                       continue;
+               if (!strncmp(prop->name, "zpos", TDM_NAME_LEN))
+                       continue;
+               snprintf(caps->props[i].name, TDM_NAME_LEN, "%s", prop->name);
+               caps->props[i].id = props->props[i];
+               caps->prop_count++;
+               drmModeFreeProperty(prop);
+       }
+
+       drmModeFreeObjectProperties(props);
+       drmModeFreePlane(plane);
+
+       return TDM_ERROR_NONE;
 failed_get:
-    drmModeFreeObjectProperties(props);
-    drmModeFreePlane(plane);
-    free(caps->formats);
-    free(caps->props);
-    memset(caps, 0, sizeof(tdm_caps_layer));
-    return ret;
+       drmModeFreeObjectProperties(props);
+       drmModeFreePlane(plane);
+       free(caps->formats);
+       free(caps->props);
+       memset(caps, 0, sizeof(tdm_caps_layer));
+       return ret;
 }
 
 tdm_error
 drm_layer_set_property(tdm_layer *layer, unsigned int id, tdm_value value)
 {
-    tdm_drm_layer_data *layer_data = layer;
-    tdm_drm_data *drm_data;
-    int ret;
-
-    RETURN_VAL_IF_FAIL(layer_data, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(layer_data->plane_id > 0, TDM_ERROR_INVALID_PARAMETER);
-
-    drm_data = layer_data->drm_data;
-    ret = drmModeObjectSetProperty(drm_data->drm_fd,
-                                   layer_data->plane_id, DRM_MODE_OBJECT_PLANE,
-                                   id, value.u32);
-    if (ret < 0)
-    {
-        TDM_ERR("set property failed: %m");
-        return TDM_ERROR_OPERATION_FAILED;
-    }
-
-    return TDM_ERROR_NONE;
+       tdm_drm_layer_data *layer_data = layer;
+       tdm_drm_data *drm_data;
+       int ret;
+
+       RETURN_VAL_IF_FAIL(layer_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(layer_data->plane_id > 0, TDM_ERROR_INVALID_PARAMETER);
+
+       drm_data = layer_data->drm_data;
+       ret = drmModeObjectSetProperty(drm_data->drm_fd,
+                                      layer_data->plane_id, DRM_MODE_OBJECT_PLANE,
+                                      id, value.u32);
+       if (ret < 0) {
+               TDM_ERR("set property failed: %m");
+               return TDM_ERROR_OPERATION_FAILED;
+       }
+
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
 drm_layer_get_property(tdm_layer *layer, unsigned int id, tdm_value *value)
 {
-    tdm_drm_layer_data *layer_data = layer;
-    tdm_drm_data *drm_data;
-    drmModeObjectPropertiesPtr props;
-    int i;
-
-    RETURN_VAL_IF_FAIL(layer_data, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(layer_data->plane_id > 0, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(value, TDM_ERROR_INVALID_PARAMETER);
-
-    drm_data = layer_data->drm_data;
-    props = drmModeObjectGetProperties(drm_data->drm_fd, layer_data->plane_id,
-                                       DRM_MODE_OBJECT_PLANE);
-    if (props == NULL)
-    {
-        TDM_ERR("get property failed: %m");
-        return TDM_ERROR_OPERATION_FAILED;
-    }
-
-    for (i = 0; i < props->count_props; i++)
-        if (props->props[i] == id)
-        {
-            (*value).u32 = (uint)props->prop_values[i];
-            break;
-        }
-
-    drmModeFreeObjectProperties(props);
-
-    return TDM_ERROR_NONE;
+       tdm_drm_layer_data *layer_data = layer;
+       tdm_drm_data *drm_data;
+       drmModeObjectPropertiesPtr props;
+       int i;
+
+       RETURN_VAL_IF_FAIL(layer_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(layer_data->plane_id > 0, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(value, TDM_ERROR_INVALID_PARAMETER);
+
+       drm_data = layer_data->drm_data;
+       props = drmModeObjectGetProperties(drm_data->drm_fd, layer_data->plane_id,
+                                          DRM_MODE_OBJECT_PLANE);
+       if (props == NULL) {
+               TDM_ERR("get property failed: %m");
+               return TDM_ERROR_OPERATION_FAILED;
+       }
+
+       for (i = 0; i < props->count_props; i++)
+               if (props->props[i] == id) {
+                       (*value).u32 = (uint)props->prop_values[i];
+                       break;
+               }
+
+       drmModeFreeObjectProperties(props);
+
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
 drm_layer_set_info(tdm_layer *layer, tdm_info_layer *info)
 {
-    tdm_drm_layer_data *layer_data = layer;
+       tdm_drm_layer_data *layer_data = layer;
 
-    RETURN_VAL_IF_FAIL(layer_data, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(info, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(layer_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(info, TDM_ERROR_INVALID_PARAMETER);
 
-    layer_data->info = *info;
-    layer_data->info_changed = 1;
+       layer_data->info = *info;
+       layer_data->info_changed = 1;
 
-    return TDM_ERROR_NONE;
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
 drm_layer_get_info(tdm_layer *layer, tdm_info_layer *info)
 {
-    tdm_drm_layer_data *layer_data = layer;
+       tdm_drm_layer_data *layer_data = layer;
 
-    RETURN_VAL_IF_FAIL(layer_data, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(info, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(layer_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(info, TDM_ERROR_INVALID_PARAMETER);
 
-    *info = layer_data->info;
+       *info = layer_data->info;
 
-    return TDM_ERROR_NONE;
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
 drm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer)
 {
-    tdm_drm_layer_data *layer_data = layer;
-    tdm_drm_data *drm_data;
-    tdm_drm_display_buffer *display_buffer;
-    tdm_error err = TDM_ERROR_NONE;
-    int ret, i, count;
-
-    RETURN_VAL_IF_FAIL(layer_data, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(buffer, TDM_ERROR_INVALID_PARAMETER);
-
-    drm_data = layer_data->drm_data;
-
-    display_buffer = _tdm_drm_display_find_buffer(drm_data, buffer);
-    if (!display_buffer)
-    {
-        display_buffer = calloc(1, sizeof(tdm_drm_display_buffer));
-        if (!display_buffer)
-        {
-            TDM_ERR("alloc failed");
-            return TDM_ERROR_OUT_OF_MEMORY;
-        }
-        display_buffer->buffer = buffer;
-
-        err = tdm_buffer_add_destroy_handler(buffer, _tdm_drm_display_cb_destroy_buffer, drm_data);
-        if (err != TDM_ERROR_NONE)
-        {
-            TDM_ERR("add destroy handler fail");
-            free(display_buffer);
-            return TDM_ERROR_OPERATION_FAILED;
-        }
-
-        LIST_ADDTAIL(&display_buffer->link, &drm_data->buffer_list);
-    }
-
-    if (display_buffer->fb_id == 0)
-    {
-        unsigned int width;
-        unsigned int height;
-        unsigned int format;
-        unsigned int handles[4] = {0,};
-        unsigned int pitches[4] = {0,};
-        unsigned int offsets[4] = {0,};
-        unsigned int size;
-
-        width = tbm_surface_get_width(buffer);
-        height = tbm_surface_get_height(buffer);
-        format = tbm_surface_get_format(buffer);
-        count = tbm_surface_internal_get_num_bos(buffer);
-        for (i = 0; i < count; i++)
-        {
-            tbm_bo bo = tbm_surface_internal_get_bo(buffer, i);
-            handles[i] = tbm_bo_get_handle(bo, TBM_DEVICE_DEFAULT).u32;
-        }
-        count = tbm_surface_internal_get_num_planes(format);
-        for (i = 0; i < count; i++)
-            tbm_surface_internal_get_plane_data(buffer, i, &size, &offsets[i], &pitches[i]);
-
-        ret = drmModeAddFB2(drm_data->drm_fd, width, height, format,
-                            handles, pitches, offsets, &display_buffer->fb_id, 0);
-        if (ret < 0)
-        {
-            TDM_ERR("add fb failed: %m");
-            return TDM_ERROR_OPERATION_FAILED;
-        }
-        TDM_DBG("drm_data->drm_fd : %d, display_buffer->fb_id:%u", drm_data->drm_fd, display_buffer->fb_id);
-
-        if (IS_RGB(format))
-            display_buffer->width = pitches[0] >> 2;
-        else
-            display_buffer->width = pitches[0];
-    }
-
-    layer_data->display_buffer = display_buffer;
-    layer_data->display_buffer_changed = 1;
-
-    return TDM_ERROR_NONE;
+       tdm_drm_layer_data *layer_data = layer;
+       tdm_drm_data *drm_data;
+       tdm_drm_display_buffer *display_buffer;
+       tdm_error err = TDM_ERROR_NONE;
+       int ret, i, count;
+
+       RETURN_VAL_IF_FAIL(layer_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(buffer, TDM_ERROR_INVALID_PARAMETER);
+
+       drm_data = layer_data->drm_data;
+
+       display_buffer = _tdm_drm_display_find_buffer(drm_data, buffer);
+       if (!display_buffer) {
+               display_buffer = calloc(1, sizeof(tdm_drm_display_buffer));
+               if (!display_buffer) {
+                       TDM_ERR("alloc failed");
+                       return TDM_ERROR_OUT_OF_MEMORY;
+               }
+               display_buffer->buffer = buffer;
+
+               err = tdm_buffer_add_destroy_handler(buffer, _tdm_drm_display_cb_destroy_buffer,
+                                                    drm_data);
+               if (err != TDM_ERROR_NONE) {
+                       TDM_ERR("add destroy handler fail");
+                       free(display_buffer);
+                       return TDM_ERROR_OPERATION_FAILED;
+               }
+
+               LIST_ADDTAIL(&display_buffer->link, &drm_data->buffer_list);
+       }
+
+       if (display_buffer->fb_id == 0) {
+               unsigned int width;
+               unsigned int height;
+               unsigned int format;
+               unsigned int handles[4] = {0,};
+               unsigned int pitches[4] = {0,};
+               unsigned int offsets[4] = {0,};
+               unsigned int size;
+
+               width = tbm_surface_get_width(buffer);
+               height = tbm_surface_get_height(buffer);
+               format = tbm_surface_get_format(buffer);
+               count = tbm_surface_internal_get_num_bos(buffer);
+               for (i = 0; i < count; i++) {
+                       tbm_bo bo = tbm_surface_internal_get_bo(buffer, i);
+                       handles[i] = tbm_bo_get_handle(bo, TBM_DEVICE_DEFAULT).u32;
+               }
+               count = tbm_surface_internal_get_num_planes(format);
+               for (i = 0; i < count; i++)
+                       tbm_surface_internal_get_plane_data(buffer, i, &size, &offsets[i], &pitches[i]);
+
+               ret = drmModeAddFB2(drm_data->drm_fd, width, height, format,
+                                   handles, pitches, offsets, &display_buffer->fb_id, 0);
+               if (ret < 0) {
+                       TDM_ERR("add fb failed: %m");
+                       return TDM_ERROR_OPERATION_FAILED;
+               }
+               TDM_DBG("drm_data->drm_fd : %d, display_buffer->fb_id:%u", drm_data->drm_fd,
+                       display_buffer->fb_id);
+
+               if (IS_RGB(format))
+                       display_buffer->width = pitches[0] >> 2;
+               else
+                       display_buffer->width = pitches[0];
+       }
+
+       layer_data->display_buffer = display_buffer;
+       layer_data->display_buffer_changed = 1;
+
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
 drm_layer_unset_buffer(tdm_layer *layer)
 {
-    tdm_drm_layer_data *layer_data = layer;
+       tdm_drm_layer_data *layer_data = layer;
 
-    RETURN_VAL_IF_FAIL(layer_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(layer_data, TDM_ERROR_INVALID_PARAMETER);
 
-    layer_data->display_buffer = NULL;
-    layer_data->display_buffer_changed = 1;
+       layer_data->display_buffer = NULL;
+       layer_data->display_buffer_changed = 1;
 
-    return TDM_ERROR_NONE;
+       return TDM_ERROR_NONE;
 }
index c85b1de..eeda432 100644 (file)
@@ -7,72 +7,70 @@
 
 #include "tdm_drm.h"
 
-typedef struct
-{
-    tbm_format  tbm_format;
-    uint32_t    drm_format;
+typedef struct {
+       tbm_format  tbm_format;
+       uint32_t    drm_format;
 } tbm_drm_format_data;
 
-static const tbm_drm_format_data formats[] =
-{
-    {TBM_FORMAT_C8, DRM_FORMAT_C8},
-    {TBM_FORMAT_RGB332, DRM_FORMAT_RGB332},
-    {TBM_FORMAT_BGR233, DRM_FORMAT_BGR233},
-    {TBM_FORMAT_XRGB4444, DRM_FORMAT_XRGB4444},
-    {TBM_FORMAT_XBGR4444, DRM_FORMAT_XBGR4444},
-    {TBM_FORMAT_RGBX4444, DRM_FORMAT_RGBX4444},
-    {TBM_FORMAT_BGRX4444, DRM_FORMAT_BGRX4444},
-    {TBM_FORMAT_ARGB4444, DRM_FORMAT_ARGB4444},
-    {TBM_FORMAT_ABGR4444, DRM_FORMAT_ABGR4444},
-    {TBM_FORMAT_RGBA4444, DRM_FORMAT_RGBA4444},
-    {TBM_FORMAT_BGRA4444, DRM_FORMAT_BGRA4444},
-    {TBM_FORMAT_XRGB1555, DRM_FORMAT_XRGB1555},
-    {TBM_FORMAT_XBGR1555, DRM_FORMAT_XBGR1555},
-    {TBM_FORMAT_RGBX5551, DRM_FORMAT_RGBX5551},
-    {TBM_FORMAT_BGRX5551, DRM_FORMAT_BGRX5551},
-    {TBM_FORMAT_ARGB1555, DRM_FORMAT_ARGB1555},
-    {TBM_FORMAT_ABGR1555, DRM_FORMAT_ABGR1555},
-    {TBM_FORMAT_RGBA5551, DRM_FORMAT_RGBA5551},
-    {TBM_FORMAT_BGRA5551, DRM_FORMAT_BGRA5551},
-    {TBM_FORMAT_RGB565, DRM_FORMAT_RGB565},
-    {TBM_FORMAT_BGR565, DRM_FORMAT_BGR565},
-    {TBM_FORMAT_RGB888, DRM_FORMAT_RGB888},
-    {TBM_FORMAT_BGR888, DRM_FORMAT_BGR888},
-    {TBM_FORMAT_XRGB8888, DRM_FORMAT_XRGB8888},
-    {TBM_FORMAT_XBGR8888, DRM_FORMAT_XBGR8888},
-    {TBM_FORMAT_RGBX8888, DRM_FORMAT_RGBX8888},
-    {TBM_FORMAT_BGRX8888, DRM_FORMAT_BGRX8888},
-    {TBM_FORMAT_ARGB8888, DRM_FORMAT_ARGB8888},
-    {TBM_FORMAT_ABGR8888, DRM_FORMAT_ABGR8888},
-    {TBM_FORMAT_RGBA8888, DRM_FORMAT_RGBA8888},
-    {TBM_FORMAT_BGRA8888, DRM_FORMAT_BGRA8888},
-    {TBM_FORMAT_XRGB2101010, DRM_FORMAT_XRGB2101010},
-    {TBM_FORMAT_XBGR2101010, DRM_FORMAT_XBGR2101010},
-    {TBM_FORMAT_RGBX1010102, DRM_FORMAT_RGBX1010102},
-    {TBM_FORMAT_BGRX1010102, DRM_FORMAT_BGRX1010102},
-    {TBM_FORMAT_ARGB2101010, DRM_FORMAT_ARGB2101010},
-    {TBM_FORMAT_ABGR2101010, DRM_FORMAT_ABGR2101010},
-    {TBM_FORMAT_RGBA1010102, DRM_FORMAT_RGBA1010102},
-    {TBM_FORMAT_BGRA1010102, DRM_FORMAT_BGRA1010102},
-    {TBM_FORMAT_YUYV, DRM_FORMAT_YUYV},
-    {TBM_FORMAT_YVYU, DRM_FORMAT_YVYU},
-    {TBM_FORMAT_UYVY, DRM_FORMAT_UYVY},
-    {TBM_FORMAT_VYUY, DRM_FORMAT_VYUY},
-    {TBM_FORMAT_AYUV, DRM_FORMAT_AYUV},
-    {TBM_FORMAT_NV12, DRM_FORMAT_NV12},
-    {TBM_FORMAT_NV21, DRM_FORMAT_NV21},
-    {TBM_FORMAT_NV16, DRM_FORMAT_NV16},
-    {TBM_FORMAT_NV61, DRM_FORMAT_NV61},
-    {TBM_FORMAT_YUV410, DRM_FORMAT_YUV410},
-    {TBM_FORMAT_YVU410, DRM_FORMAT_YVU410},
-    {TBM_FORMAT_YUV411, DRM_FORMAT_YUV411},
-    {TBM_FORMAT_YVU411, DRM_FORMAT_YVU411},
-    {TBM_FORMAT_YUV420, DRM_FORMAT_YUV420},
-    {TBM_FORMAT_YVU420, DRM_FORMAT_YVU420},
-    {TBM_FORMAT_YUV422, DRM_FORMAT_YUV422},
-    {TBM_FORMAT_YVU422, DRM_FORMAT_YVU422},
-    {TBM_FORMAT_YUV444, DRM_FORMAT_YUV444},
-    {TBM_FORMAT_YVU444, DRM_FORMAT_YVU444},
+static const tbm_drm_format_data formats[] = {
+       {TBM_FORMAT_C8, DRM_FORMAT_C8},
+       {TBM_FORMAT_RGB332, DRM_FORMAT_RGB332},
+       {TBM_FORMAT_BGR233, DRM_FORMAT_BGR233},
+       {TBM_FORMAT_XRGB4444, DRM_FORMAT_XRGB4444},
+       {TBM_FORMAT_XBGR4444, DRM_FORMAT_XBGR4444},
+       {TBM_FORMAT_RGBX4444, DRM_FORMAT_RGBX4444},
+       {TBM_FORMAT_BGRX4444, DRM_FORMAT_BGRX4444},
+       {TBM_FORMAT_ARGB4444, DRM_FORMAT_ARGB4444},
+       {TBM_FORMAT_ABGR4444, DRM_FORMAT_ABGR4444},
+       {TBM_FORMAT_RGBA4444, DRM_FORMAT_RGBA4444},
+       {TBM_FORMAT_BGRA4444, DRM_FORMAT_BGRA4444},
+       {TBM_FORMAT_XRGB1555, DRM_FORMAT_XRGB1555},
+       {TBM_FORMAT_XBGR1555, DRM_FORMAT_XBGR1555},
+       {TBM_FORMAT_RGBX5551, DRM_FORMAT_RGBX5551},
+       {TBM_FORMAT_BGRX5551, DRM_FORMAT_BGRX5551},
+       {TBM_FORMAT_ARGB1555, DRM_FORMAT_ARGB1555},
+       {TBM_FORMAT_ABGR1555, DRM_FORMAT_ABGR1555},
+       {TBM_FORMAT_RGBA5551, DRM_FORMAT_RGBA5551},
+       {TBM_FORMAT_BGRA5551, DRM_FORMAT_BGRA5551},
+       {TBM_FORMAT_RGB565, DRM_FORMAT_RGB565},
+       {TBM_FORMAT_BGR565, DRM_FORMAT_BGR565},
+       {TBM_FORMAT_RGB888, DRM_FORMAT_RGB888},
+       {TBM_FORMAT_BGR888, DRM_FORMAT_BGR888},
+       {TBM_FORMAT_XRGB8888, DRM_FORMAT_XRGB8888},
+       {TBM_FORMAT_XBGR8888, DRM_FORMAT_XBGR8888},
+       {TBM_FORMAT_RGBX8888, DRM_FORMAT_RGBX8888},
+       {TBM_FORMAT_BGRX8888, DRM_FORMAT_BGRX8888},
+       {TBM_FORMAT_ARGB8888, DRM_FORMAT_ARGB8888},
+       {TBM_FORMAT_ABGR8888, DRM_FORMAT_ABGR8888},
+       {TBM_FORMAT_RGBA8888, DRM_FORMAT_RGBA8888},
+       {TBM_FORMAT_BGRA8888, DRM_FORMAT_BGRA8888},
+       {TBM_FORMAT_XRGB2101010, DRM_FORMAT_XRGB2101010},
+       {TBM_FORMAT_XBGR2101010, DRM_FORMAT_XBGR2101010},
+       {TBM_FORMAT_RGBX1010102, DRM_FORMAT_RGBX1010102},
+       {TBM_FORMAT_BGRX1010102, DRM_FORMAT_BGRX1010102},
+       {TBM_FORMAT_ARGB2101010, DRM_FORMAT_ARGB2101010},
+       {TBM_FORMAT_ABGR2101010, DRM_FORMAT_ABGR2101010},
+       {TBM_FORMAT_RGBA1010102, DRM_FORMAT_RGBA1010102},
+       {TBM_FORMAT_BGRA1010102, DRM_FORMAT_BGRA1010102},
+       {TBM_FORMAT_YUYV, DRM_FORMAT_YUYV},
+       {TBM_FORMAT_YVYU, DRM_FORMAT_YVYU},
+       {TBM_FORMAT_UYVY, DRM_FORMAT_UYVY},
+       {TBM_FORMAT_VYUY, DRM_FORMAT_VYUY},
+       {TBM_FORMAT_AYUV, DRM_FORMAT_AYUV},
+       {TBM_FORMAT_NV12, DRM_FORMAT_NV12},
+       {TBM_FORMAT_NV21, DRM_FORMAT_NV21},
+       {TBM_FORMAT_NV16, DRM_FORMAT_NV16},
+       {TBM_FORMAT_NV61, DRM_FORMAT_NV61},
+       {TBM_FORMAT_YUV410, DRM_FORMAT_YUV410},
+       {TBM_FORMAT_YVU410, DRM_FORMAT_YVU410},
+       {TBM_FORMAT_YUV411, DRM_FORMAT_YUV411},
+       {TBM_FORMAT_YVU411, DRM_FORMAT_YVU411},
+       {TBM_FORMAT_YUV420, DRM_FORMAT_YUV420},
+       {TBM_FORMAT_YVU420, DRM_FORMAT_YVU420},
+       {TBM_FORMAT_YUV422, DRM_FORMAT_YUV422},
+       {TBM_FORMAT_YVU422, DRM_FORMAT_YVU422},
+       {TBM_FORMAT_YUV444, DRM_FORMAT_YUV444},
+       {TBM_FORMAT_YVU444, DRM_FORMAT_YVU444},
 };
 
 #define NUM_FORMATS (sizeof(formats) / sizeof(formats[0]))
@@ -80,27 +78,27 @@ static const tbm_drm_format_data formats[] =
 uint32_t
 tdm_drm_format_to_drm_format(tbm_format format)
 {
-    int i;
+       int i;
 
-    for (i = 0; i < NUM_FORMATS; i++)
-        if (formats[i].tbm_format == format)
-            return formats[i].drm_format;
+       for (i = 0; i < NUM_FORMATS; i++)
+               if (formats[i].tbm_format == format)
+                       return formats[i].drm_format;
 
-    TDM_ERR("tbm format '%c%c%c%c' not found", FOURCC_STR(format));
+       TDM_ERR("tbm format '%c%c%c%c' not found", FOURCC_STR(format));
 
-    return 0;
+       return 0;
 }
 
 tbm_format
 tdm_drm_format_to_tbm_format(uint32_t format)
 {
-    int i;
+       int i;
 
-    for (i = 0; i < NUM_FORMATS; i++)
-        if (formats[i].drm_format == format)
-            return formats[i].tbm_format;
+       for (i = 0; i < NUM_FORMATS; i++)
+               if (formats[i].drm_format == format)
+                       return formats[i].tbm_format;
 
-    TDM_ERR("drm format '%c%c%c%c' not found", FOURCC_STR(format));
+       TDM_ERR("drm format '%c%c%c%c' not found", FOURCC_STR(format));
 
-    return 0;
+       return 0;
 }
index 9720eb2..1da577f 100644 (file)
@@ -6,35 +6,32 @@
 
 #include "tdm_drm.h"
 
-typedef struct _tdm_drm_pp_buffer
-{
-    tbm_surface_h src;
-    tbm_surface_h dst;
+typedef struct _tdm_drm_pp_buffer {
+       tbm_surface_h src;
+       tbm_surface_h dst;
 
-    struct list_head link;
+       struct list_head link;
 } tdm_drm_pp_buffer;
 
-typedef struct _tdm_drm_pp_data
-{
-    tdm_drm_data *drm_data;
+typedef struct _tdm_drm_pp_data {
+       tdm_drm_data *drm_data;
 
-    tdm_info_pp info;
+       tdm_info_pp info;
 
-    struct list_head pending_buffer_list;
+       struct list_head pending_buffer_list;
 
-    tdm_pp_done_handler done_func;
-    void *done_user_data;
+       tdm_pp_done_handler done_func;
+       void *done_user_data;
 
-    struct list_head link;
+       struct list_head link;
 } tdm_drm_pp_data;
 
 
-static tbm_format pp_formats[] =
-{
-    TBM_FORMAT_ARGB8888,
-    TBM_FORMAT_XRGB8888,
-    TBM_FORMAT_YUV420,
-    TBM_FORMAT_YVU420
+static tbm_format pp_formats[] = {
+       TBM_FORMAT_ARGB8888,
+       TBM_FORMAT_XRGB8888,
+       TBM_FORMAT_YUV420,
+       TBM_FORMAT_YVU420
 };
 
 #define NUM_PP_FORMAT   (sizeof(pp_formats) / sizeof(pp_formats[0]))
@@ -45,18 +42,17 @@ static struct list_head pp_list;
 static pixman_format_code_t
 _tdm_drm_pp_pixman_get_format(tbm_format tbmfmt)
 {
-    switch (tbmfmt)
-    {
-    case TBM_FORMAT_ARGB8888:
-        return PIXMAN_a8r8g8b8;
-    case TBM_FORMAT_XRGB8888:
-        return PIXMAN_x8r8g8b8;
-    case TBM_FORMAT_YUV420:
-    case TBM_FORMAT_YVU420:
-        return PIXMAN_yv12;
-    default:
-        return 0;
-    }
+       switch (tbmfmt) {
+       case TBM_FORMAT_ARGB8888:
+               return PIXMAN_a8r8g8b8;
+       case TBM_FORMAT_XRGB8888:
+               return PIXMAN_x8r8g8b8;
+       case TBM_FORMAT_YUV420:
+       case TBM_FORMAT_YVU420:
+               return PIXMAN_yv12;
+       default:
+               return 0;
+       }
 }
 
 int
@@ -67,337 +63,322 @@ _tdm_drm_pp_pixman_convert(pixman_op_t op,
                            int dbw, int dbh, int dx, int dy, int dw, int dh,
                            int rotate, int hflip, int vflip)
 {
-    pixman_image_t    *src_img;
-    pixman_image_t    *dst_img;
-    struct pixman_f_transform ft;
-    pixman_transform_t transform;
-    int                src_stride, dst_stride;
-    int                src_bpp;
-    int                dst_bpp;
-    double             scale_x, scale_y;
-    int                rotate_step;
-    int                ret = 0;
-
-    RETURN_VAL_IF_FAIL(srcbuf != NULL, 0);
-    RETURN_VAL_IF_FAIL(dstbuf != NULL, 0);
-
-    TDM_DBG("src(%dx%d: %d,%d %dx%d) dst(%dx%d: %d,%d %dx%d) flip(%d,%d), rot(%d)",
-            sbw, sbh, sx, sy, sw, sh, dbw, dbh, dx, dy, dw, dh, hflip, vflip, rotate);
-
-    src_bpp = PIXMAN_FORMAT_BPP(src_format) / 8;
-    RETURN_VAL_IF_FAIL(src_bpp > 0, 0);
-
-    dst_bpp = PIXMAN_FORMAT_BPP(dst_format) / 8;
-    RETURN_VAL_IF_FAIL(dst_bpp > 0, 0);
-
-    rotate_step = (rotate + 360) / 90 % 4;
-
-    src_stride = sbw * src_bpp;
-    dst_stride = dbw * dst_bpp;
-
-    src_img = pixman_image_create_bits(src_format, sbw, sbh, (uint32_t*)srcbuf, src_stride);
-    dst_img = pixman_image_create_bits(dst_format, dbw, dbh, (uint32_t*)dstbuf, dst_stride);
-
-    GOTO_IF_FAIL(src_img != NULL, CANT_CONVERT);
-    GOTO_IF_FAIL(dst_img != NULL, CANT_CONVERT);
-
-    pixman_f_transform_init_identity(&ft);
-
-    if (hflip)
-    {
-        pixman_f_transform_scale(&ft, NULL, -1, 1);
-        pixman_f_transform_translate(&ft, NULL, dw, 0);
-    }
-
-    if (vflip)
-    {
-        pixman_f_transform_scale(&ft, NULL, 1, -1);
-        pixman_f_transform_translate(&ft, NULL, 0, dh);
-    }
-
-    if (rotate_step > 0)
-    {
-        int c = 0, s = 0, tx = 0, ty = 0;
-        switch (rotate_step)
-        {
-        case 1: /* 90 degrees */
-            s = -1, tx = -dw;
-            break;
-        case 2: /* 180 degrees */
-            c = -1, tx = -dw, ty = -dh;
-            break;
-        case 3: /* 270 degrees */
-            s = 1, ty = -dh;
-            break;
-        default:
-            break;
-        }
-
-        pixman_f_transform_translate(&ft, NULL, tx, ty);
-        pixman_f_transform_rotate(&ft, NULL, c, s);
-    }
-
-    if (rotate_step % 2 == 0)
-    {
-        scale_x = (double)sw / dw;
-        scale_y = (double)sh / dh;
-    }
-    else
-    {
-        scale_x = (double)sw / dh;
-        scale_y = (double)sh / dw;
-    }
-
-    pixman_f_transform_scale(&ft, NULL, scale_x, scale_y);
-    pixman_f_transform_translate(&ft, NULL, sx, sy);
-
-    pixman_transform_from_pixman_f_transform(&transform, &ft);
-    pixman_image_set_transform(src_img, &transform);
-
-    pixman_image_composite(op, src_img, NULL, dst_img, 0, 0, 0, 0, dx, dy, dw, dh);
-
-    ret = 1;
+       pixman_image_t    *src_img;
+       pixman_image_t    *dst_img;
+       struct pixman_f_transform ft;
+       pixman_transform_t transform;
+       int                src_stride, dst_stride;
+       int                src_bpp;
+       int                dst_bpp;
+       double             scale_x, scale_y;
+       int                rotate_step;
+       int                ret = 0;
+
+       RETURN_VAL_IF_FAIL(srcbuf != NULL, 0);
+       RETURN_VAL_IF_FAIL(dstbuf != NULL, 0);
+
+       TDM_DBG("src(%dx%d: %d,%d %dx%d) dst(%dx%d: %d,%d %dx%d) flip(%d,%d), rot(%d)",
+               sbw, sbh, sx, sy, sw, sh, dbw, dbh, dx, dy, dw, dh, hflip, vflip, rotate);
+
+       src_bpp = PIXMAN_FORMAT_BPP(src_format) / 8;
+       RETURN_VAL_IF_FAIL(src_bpp > 0, 0);
+
+       dst_bpp = PIXMAN_FORMAT_BPP(dst_format) / 8;
+       RETURN_VAL_IF_FAIL(dst_bpp > 0, 0);
+
+       rotate_step = (rotate + 360) / 90 % 4;
+
+       src_stride = sbw * src_bpp;
+       dst_stride = dbw * dst_bpp;
+
+       src_img = pixman_image_create_bits(src_format, sbw, sbh, (uint32_t *)srcbuf,
+                                          src_stride);
+       dst_img = pixman_image_create_bits(dst_format, dbw, dbh, (uint32_t *)dstbuf,
+                                          dst_stride);
+
+       GOTO_IF_FAIL(src_img != NULL, CANT_CONVERT);
+       GOTO_IF_FAIL(dst_img != NULL, CANT_CONVERT);
+
+       pixman_f_transform_init_identity(&ft);
+
+       if (hflip) {
+               pixman_f_transform_scale(&ft, NULL, -1, 1);
+               pixman_f_transform_translate(&ft, NULL, dw, 0);
+       }
+
+       if (vflip) {
+               pixman_f_transform_scale(&ft, NULL, 1, -1);
+               pixman_f_transform_translate(&ft, NULL, 0, dh);
+       }
+
+       if (rotate_step > 0) {
+               int c = 0, s = 0, tx = 0, ty = 0;
+               switch (rotate_step) {
+               case 1: /* 90 degrees */
+                       s = -1, tx = -dw;
+                       break;
+               case 2: /* 180 degrees */
+                       c = -1, tx = -dw, ty = -dh;
+                       break;
+               case 3: /* 270 degrees */
+                       s = 1, ty = -dh;
+                       break;
+               default:
+                       break;
+               }
+
+               pixman_f_transform_translate(&ft, NULL, tx, ty);
+               pixman_f_transform_rotate(&ft, NULL, c, s);
+       }
+
+       if (rotate_step % 2 == 0) {
+               scale_x = (double)sw / dw;
+               scale_y = (double)sh / dh;
+       } else {
+               scale_x = (double)sw / dh;
+               scale_y = (double)sh / dw;
+       }
+
+       pixman_f_transform_scale(&ft, NULL, scale_x, scale_y);
+       pixman_f_transform_translate(&ft, NULL, sx, sy);
+
+       pixman_transform_from_pixman_f_transform(&transform, &ft);
+       pixman_image_set_transform(src_img, &transform);
+
+       pixman_image_composite(op, src_img, NULL, dst_img, 0, 0, 0, 0, dx, dy, dw, dh);
+
+       ret = 1;
 
 CANT_CONVERT:
-    if (src_img)
-        pixman_image_unref(src_img);
-    if (dst_img)
-        pixman_image_unref(dst_img);
+       if (src_img)
+               pixman_image_unref(src_img);
+       if (dst_img)
+               pixman_image_unref(dst_img);
 
-    return ret;
+       return ret;
 }
 
 static tdm_error
 _tdm_drm_pp_convert(tdm_drm_pp_buffer *buffer, tdm_info_pp *info)
 {
-    tbm_surface_info_s src_info, dst_info;
-    pixman_format_code_t src_format, dst_format;
-    int sbw, dbw;
-    int rotate = 0, hflip = 0;
-
-    RETURN_VAL_IF_FAIL(buffer != NULL, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(buffer->src != NULL, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(buffer->dst != NULL, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(info != NULL, TDM_ERROR_INVALID_PARAMETER);
-
-    /* not handle buffers which have 2 more gem handles */
-
-    memset(&src_info, 0, sizeof(tbm_surface_info_s));
-    tbm_surface_get_info(buffer->src, &src_info);
-    RETURN_VAL_IF_FAIL(src_info.planes[0].ptr != NULL, TDM_ERROR_INVALID_PARAMETER);
-
-    memset(&dst_info, 0, sizeof(tbm_surface_info_s));
-    tbm_surface_get_info(buffer->dst, &dst_info);
-    RETURN_VAL_IF_FAIL(dst_info.planes[0].ptr != NULL, TDM_ERROR_INVALID_PARAMETER);
-
-    src_format = _tdm_drm_pp_pixman_get_format(src_info.format);
-    RETURN_VAL_IF_FAIL(src_format > 0, TDM_ERROR_INVALID_PARAMETER);
-    dst_format = _tdm_drm_pp_pixman_get_format(dst_info.format);
-    RETURN_VAL_IF_FAIL(dst_format > 0, TDM_ERROR_INVALID_PARAMETER);
-
-    if (src_info.format == TBM_FORMAT_YUV420)
-    {
-        if (dst_info.format == TBM_FORMAT_XRGB8888)
-            dst_format = PIXMAN_x8b8g8r8;
-        else if (dst_info.format == TBM_FORMAT_ARGB8888)
-            dst_format = PIXMAN_a8b8g8r8;
-        else if (dst_info.format == TBM_FORMAT_YVU420)
-        {
-            TDM_ERR("can't convert %c%c%c%c to %c%c%c%c",
-                    FOURCC_STR(src_info.format), FOURCC_STR(dst_info.format));
-            return TDM_ERROR_OPERATION_FAILED;
-        }
-    }
-    /* need checking for other formats also? */
-
-    if (IS_RGB(src_info.format))
-        sbw = src_info.planes[0].stride >> 2;
-    else
-        sbw = src_info.planes[0].stride;
-
-    if (IS_RGB(src_info.format))
-        dbw = dst_info.planes[0].stride >> 2;
-    else
-        dbw = dst_info.planes[0].stride;
-
-    rotate = (info->transform % 4) * 90;
-    if (info->transform >= TDM_TRANSFORM_FLIPPED)
-        hflip = 1;
-
-    _tdm_drm_pp_pixman_convert(PIXMAN_OP_SRC,
-                               src_info.planes[0].ptr, dst_info.planes[0].ptr,
-                               src_format, dst_format,
-                               sbw, src_info.height,
-                               info->src_config.pos.x, info->src_config.pos.y,
-                               info->src_config.pos.w, info->src_config.pos.h,
-                               dbw, dst_info.height,
-                               info->dst_config.pos.x, info->dst_config.pos.y,
-                               info->dst_config.pos.w, info->dst_config.pos.h,
-                               rotate, hflip, 0);
-
-    return TDM_ERROR_NONE;
+       tbm_surface_info_s src_info, dst_info;
+       pixman_format_code_t src_format, dst_format;
+       int sbw, dbw;
+       int rotate = 0, hflip = 0;
+
+       RETURN_VAL_IF_FAIL(buffer != NULL, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(buffer->src != NULL, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(buffer->dst != NULL, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(info != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+       /* not handle buffers which have 2 more gem handles */
+
+       memset(&src_info, 0, sizeof(tbm_surface_info_s));
+       tbm_surface_get_info(buffer->src, &src_info);
+       RETURN_VAL_IF_FAIL(src_info.planes[0].ptr != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+       memset(&dst_info, 0, sizeof(tbm_surface_info_s));
+       tbm_surface_get_info(buffer->dst, &dst_info);
+       RETURN_VAL_IF_FAIL(dst_info.planes[0].ptr != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+       src_format = _tdm_drm_pp_pixman_get_format(src_info.format);
+       RETURN_VAL_IF_FAIL(src_format > 0, TDM_ERROR_INVALID_PARAMETER);
+       dst_format = _tdm_drm_pp_pixman_get_format(dst_info.format);
+       RETURN_VAL_IF_FAIL(dst_format > 0, TDM_ERROR_INVALID_PARAMETER);
+
+       if (src_info.format == TBM_FORMAT_YUV420) {
+               if (dst_info.format == TBM_FORMAT_XRGB8888)
+                       dst_format = PIXMAN_x8b8g8r8;
+               else if (dst_info.format == TBM_FORMAT_ARGB8888)
+                       dst_format = PIXMAN_a8b8g8r8;
+               else if (dst_info.format == TBM_FORMAT_YVU420) {
+                       TDM_ERR("can't convert %c%c%c%c to %c%c%c%c",
+                               FOURCC_STR(src_info.format), FOURCC_STR(dst_info.format));
+                       return TDM_ERROR_OPERATION_FAILED;
+               }
+       }
+       /* need checking for other formats also? */
+
+       if (IS_RGB(src_info.format))
+               sbw = src_info.planes[0].stride >> 2;
+       else
+               sbw = src_info.planes[0].stride;
+
+       if (IS_RGB(src_info.format))
+               dbw = dst_info.planes[0].stride >> 2;
+       else
+               dbw = dst_info.planes[0].stride;
+
+       rotate = (info->transform % 4) * 90;
+       if (info->transform >= TDM_TRANSFORM_FLIPPED)
+               hflip = 1;
+
+       _tdm_drm_pp_pixman_convert(PIXMAN_OP_SRC,
+                                  src_info.planes[0].ptr, dst_info.planes[0].ptr,
+                                  src_format, dst_format,
+                                  sbw, src_info.height,
+                                  info->src_config.pos.x, info->src_config.pos.y,
+                                  info->src_config.pos.w, info->src_config.pos.h,
+                                  dbw, dst_info.height,
+                                  info->dst_config.pos.x, info->dst_config.pos.y,
+                                  info->dst_config.pos.w, info->dst_config.pos.h,
+                                  rotate, hflip, 0);
+
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
 tdm_drm_pp_get_capability(tdm_drm_data *drm_data, tdm_caps_pp *caps)
 {
-    int i;
-
-    if (!caps)
-    {
-        TDM_ERR("invalid params");
-        return TDM_ERROR_INVALID_PARAMETER;
-    }
-
-    caps->capabilities = TDM_PP_CAPABILITY_ASYNC;
-
-    caps->format_count = NUM_PP_FORMAT;
-
-    /* will be freed in frontend */
-    caps->formats = calloc(1, sizeof pp_formats);
-    if (!caps->formats)
-    {
-        TDM_ERR("alloc failed");
-        return TDM_ERROR_OUT_OF_MEMORY;
-    }
-    for (i = 0; i < caps->format_count; i++)
-        caps->formats[i] = pp_formats[i];
-
-    caps->min_w = 16;
-    caps->min_h = 8;
-    caps->max_w = -1;   /* not defined */
-    caps->max_h = -1;
-    caps->preferred_align = 16;
-
-    return TDM_ERROR_NONE;
+       int i;
+
+       if (!caps) {
+               TDM_ERR("invalid params");
+               return TDM_ERROR_INVALID_PARAMETER;
+       }
+
+       caps->capabilities = TDM_PP_CAPABILITY_ASYNC;
+
+       caps->format_count = NUM_PP_FORMAT;
+
+       /* will be freed in frontend */
+       caps->formats = calloc(1, sizeof pp_formats);
+       if (!caps->formats) {
+               TDM_ERR("alloc failed");
+               return TDM_ERROR_OUT_OF_MEMORY;
+       }
+       for (i = 0; i < caps->format_count; i++)
+               caps->formats[i] = pp_formats[i];
+
+       caps->min_w = 16;
+       caps->min_h = 8;
+       caps->max_w = -1;   /* not defined */
+       caps->max_h = -1;
+       caps->preferred_align = 16;
+
+       return TDM_ERROR_NONE;
 }
 
-tdm_pp*
+tdm_pp *
 tdm_drm_pp_create(tdm_drm_data *drm_data, tdm_error *error)
 {
-    tdm_drm_pp_data *pp_data = calloc(1, sizeof(tdm_drm_pp_data));
-    if (!pp_data)
-    {
-        TDM_ERR("alloc failed");
-        if (error)
-            *error = TDM_ERROR_OUT_OF_MEMORY;
-        return NULL;
-    }
-
-    pp_data->drm_data = drm_data;
-
-    LIST_INITHEAD(&pp_data->pending_buffer_list);
-
-    if (!pp_list_init)
-    {
-        pp_list_init = 1;
-        LIST_INITHEAD(&pp_list);
-    }
-    LIST_ADDTAIL(&pp_data->link, &pp_list);
-
-    return pp_data;
+       tdm_drm_pp_data *pp_data = calloc(1, sizeof(tdm_drm_pp_data));
+       if (!pp_data) {
+               TDM_ERR("alloc failed");
+               if (error)
+                       *error = TDM_ERROR_OUT_OF_MEMORY;
+               return NULL;
+       }
+
+       pp_data->drm_data = drm_data;
+
+       LIST_INITHEAD(&pp_data->pending_buffer_list);
+
+       if (!pp_list_init) {
+               pp_list_init = 1;
+               LIST_INITHEAD(&pp_list);
+       }
+       LIST_ADDTAIL(&pp_data->link, &pp_list);
+
+       return pp_data;
 }
 
 void
 drm_pp_destroy(tdm_pp *pp)
 {
-    tdm_drm_pp_data *pp_data = pp;
-    tdm_drm_pp_buffer *b = NULL, *bb = NULL;
+       tdm_drm_pp_data *pp_data = pp;
+       tdm_drm_pp_buffer *b = NULL, *bb = NULL;
 
-    if (!pp_data)
-        return;
+       if (!pp_data)
+               return;
 
-    LIST_FOR_EACH_ENTRY_SAFE(b, bb, &pp_data->pending_buffer_list, link)
-    {
-        LIST_DEL(&b->link);
-        free(b);
-    }
+       LIST_FOR_EACH_ENTRY_SAFE(b, bb, &pp_data->pending_buffer_list, link) {
+               LIST_DEL(&b->link);
+               free(b);
+       }
 
-    LIST_DEL(&pp_data->link);
+       LIST_DEL(&pp_data->link);
 
-    free(pp_data);
+       free(pp_data);
 }
 
 tdm_error
 drm_pp_set_info(tdm_pp *pp, tdm_info_pp *info)
 {
-    tdm_drm_pp_data *pp_data = pp;
+       tdm_drm_pp_data *pp_data = pp;
 
-    RETURN_VAL_IF_FAIL(pp_data, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(info, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(pp_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(info, TDM_ERROR_INVALID_PARAMETER);
 
-    pp_data->info = *info;
+       pp_data->info = *info;
 
-    return TDM_ERROR_NONE;
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
 drm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst)
 {
-    tdm_drm_pp_data *pp_data = pp;
-    tdm_drm_pp_buffer *buffer;
+       tdm_drm_pp_data *pp_data = pp;
+       tdm_drm_pp_buffer *buffer;
 
-    RETURN_VAL_IF_FAIL(pp_data, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(src, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(dst, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(pp_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(src, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(dst, TDM_ERROR_INVALID_PARAMETER);
 
-    if (tbm_surface_internal_get_num_bos(src) > 1 ||
-        tbm_surface_internal_get_num_bos(dst) > 1)
-    {
-        TDM_ERR("can't handle multiple tbm bos");
-        return TDM_ERROR_OPERATION_FAILED;
-    }
+       if (tbm_surface_internal_get_num_bos(src) > 1 ||
+           tbm_surface_internal_get_num_bos(dst) > 1) {
+               TDM_ERR("can't handle multiple tbm bos");
+               return TDM_ERROR_OPERATION_FAILED;
+       }
 
-    buffer = calloc(1, sizeof(tdm_drm_pp_buffer));
-    if (!buffer)
-    {
-        TDM_ERR("alloc failed");
-        return TDM_ERROR_NONE;
-    }
+       buffer = calloc(1, sizeof(tdm_drm_pp_buffer));
+       if (!buffer) {
+               TDM_ERR("alloc failed");
+               return TDM_ERROR_NONE;
+       }
 
-    LIST_ADDTAIL(&buffer->link, &pp_data->pending_buffer_list);
+       LIST_ADDTAIL(&buffer->link, &pp_data->pending_buffer_list);
 
-    buffer->src = src;
-    buffer->dst = dst;
+       buffer->src = src;
+       buffer->dst = dst;
 
-    return TDM_ERROR_NONE;
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
 drm_pp_commit(tdm_pp *pp)
 {
-    tdm_drm_pp_data *pp_data = pp;
-    tdm_drm_pp_buffer *b = NULL, *bb = NULL;
+       tdm_drm_pp_data *pp_data = pp;
+       tdm_drm_pp_buffer *b = NULL, *bb = NULL;
 
-    RETURN_VAL_IF_FAIL(pp_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(pp_data, TDM_ERROR_INVALID_PARAMETER);
 
-    LIST_FOR_EACH_ENTRY_SAFE(b, bb, &pp_data->pending_buffer_list, link)
-    {
-        LIST_DEL(&b->link);
+       LIST_FOR_EACH_ENTRY_SAFE(b, bb, &pp_data->pending_buffer_list, link) {
+               LIST_DEL(&b->link);
 
-        _tdm_drm_pp_convert(b, &pp_data->info);
+               _tdm_drm_pp_convert(b, &pp_data->info);
 
-        if (pp_data->done_func)
-            pp_data->done_func(pp_data,
-                               b->src,
-                               b->dst,
-                               pp_data->done_user_data);
-        free(b);
-    }
+               if (pp_data->done_func)
+                       pp_data->done_func(pp_data,
+                                          b->src,
+                                          b->dst,
+                                          pp_data->done_user_data);
+               free(b);
+       }
 
-    return TDM_ERROR_NONE;
+       return TDM_ERROR_NONE;
 }
 
 tdm_error
 drm_pp_set_done_handler(tdm_pp *pp, tdm_pp_done_handler func, void *user_data)
 {
-    tdm_drm_pp_data *pp_data = pp;
+       tdm_drm_pp_data *pp_data = pp;
 
-    RETURN_VAL_IF_FAIL(pp_data, TDM_ERROR_INVALID_PARAMETER);
-    RETURN_VAL_IF_FAIL(func, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(pp_data, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(func, TDM_ERROR_INVALID_PARAMETER);
 
-    pp_data->done_func = func;
-    pp_data->done_user_data = user_data;
+       pp_data->done_func = func;
+       pp_data->done_user_data = user_data;
 
-    return TDM_ERROR_NONE;
+       return TDM_ERROR_NONE;
 }