From 6ce89d3c3ec5d07a21bd1fc33f6ff61d67acbe95 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Thu, 16 Aug 2012 15:41:28 -0700 Subject: Update the omap4xxx HWC to use the 1.0 interfaces Switch to HWC_DEVICE_API_VERSION_1_0 and the corresponding structures. This change removes special-case handling for Panda, which was using v0.2. This will likely break the Panda display. Change-Id: Id9ba6910ae2285d116f697bfa5af2c1f6b022ce0 --- hwc/hwc.c | 112 +++++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 82 insertions(+), 30 deletions(-) diff --git a/hwc/hwc.c b/hwc/hwc.c index efdeb68..07c63a2 100644 --- a/hwc/hwc.c +++ b/hwc/hwc.c @@ -29,6 +29,7 @@ #include #include #include +#define HWC_REMOVE_DEPRECATED_VERSIONS 1 #include #include #include @@ -120,7 +121,7 @@ typedef struct omap4_hwc_module omap4_hwc_module_t; struct omap4_hwc_device { /* static data */ - hwc_composer_device_t base; + hwc_composer_device_1_t base; hwc_procs_t *procs; pthread_t hdmi_thread; pthread_mutex_t lock; @@ -171,7 +172,7 @@ typedef struct omap4_hwc_device omap4_hwc_device_t; static int debug = 0; -static void dump_layer(hwc_layer_t const* l) +static void dump_layer(hwc_layer_1_t const* l) { ALOGD("\ttype=%d, flags=%08x, handle=%p, tr=%02x, blend=%04x, {%d,%d,%d,%d}, {%d,%d,%d,%d}", l->compositionType, l->flags, l->handle, l->transform, l->blending, @@ -238,7 +239,7 @@ static void dump_printf(struct dump_buf *buf, const char *fmt, ...) va_end(ap); } -static void dump_set_info(omap4_hwc_device_t *hwc_dev, hwc_layer_list_t* list) +static void dump_set_info(omap4_hwc_device_t *hwc_dev, hwc_display_contents_1_t* list) { struct dsscomp_setup_dispc_data *dsscomp = &hwc_dev->dsscomp_data; char logbuf[1024]; @@ -252,7 +253,7 @@ static void dump_set_info(omap4_hwc_device_t *hwc_dev, hwc_layer_list_t* list) for (i = 0; list && i < list->numHwLayers; i++) { if (i) dump_printf(&log, " "); - hwc_layer_t *layer = &list->hwLayers[i]; + hwc_layer_1_t *layer = &list->hwLayers[i]; IMG_native_handle_t *handle = (IMG_native_handle_t *)layer->handle; dump_printf(&log, "%p:%s,", handle, layer->compositionType == HWC_OVERLAY ? "DSS" : "SGX"); if ((layer->flags & HWC_SKIP_LAYER) || !handle) { @@ -309,7 +310,7 @@ static int omap4_hwc_is_valid_format(int format) } } -static int scaled(hwc_layer_t *layer) +static int scaled(hwc_layer_1_t *layer) { int w = WIDTH(layer->sourceCrop); int h = HEIGHT(layer->sourceCrop); @@ -320,7 +321,7 @@ static int scaled(hwc_layer_t *layer) return WIDTH(layer->displayFrame) != w || HEIGHT(layer->displayFrame) != h; } -static int is_protected(hwc_layer_t *layer) +static int is_protected(hwc_layer_1_t *layer) { IMG_native_handle_t *handle = (IMG_native_handle_t *)layer->handle; @@ -370,7 +371,7 @@ static int is_NV12(IMG_native_handle_t *handle) } } -static int dockable(hwc_layer_t *layer) +static int dockable(hwc_layer_1_t *layer) { IMG_native_handle_t *handle = (IMG_native_handle_t *)layer->handle; @@ -450,7 +451,7 @@ omap4_hwc_setup_layer_base(struct dss2_ovl_cfg *oc, int index, int format, int b static void omap4_hwc_setup_layer(omap4_hwc_device_t *hwc_dev, struct dss2_ovl_info *ovl, - hwc_layer_t *layer, int index, + hwc_layer_1_t *layer, int index, int format, int width, int height) { struct dss2_ovl_cfg *oc = &ovl->cfg; @@ -756,7 +757,7 @@ static int omap4_hwc_can_scale(__u32 src_w, __u32 src_h, __u32 dst_w, __u32 dst_ return 1; } -static int omap4_hwc_can_scale_layer(omap4_hwc_device_t *hwc_dev, hwc_layer_t *layer, IMG_native_handle_t *handle) +static int omap4_hwc_can_scale_layer(omap4_hwc_device_t *hwc_dev, hwc_layer_1_t *layer, IMG_native_handle_t *handle) { int src_w = WIDTH(layer->sourceCrop); int src_h = HEIGHT(layer->sourceCrop); @@ -774,7 +775,7 @@ static int omap4_hwc_can_scale_layer(omap4_hwc_device_t *hwc_dev, hwc_layer_t *l } static int omap4_hwc_is_valid_layer(omap4_hwc_device_t *hwc_dev, - hwc_layer_t *layer, + hwc_layer_1_t *layer, IMG_native_handle_t *handle) { /* Skip layers are handled by SF */ @@ -962,13 +963,13 @@ struct counts { unsigned int mem; }; -static void gather_layer_statistics(omap4_hwc_device_t *hwc_dev, struct counts *num, hwc_layer_list_t *list) +static void gather_layer_statistics(omap4_hwc_device_t *hwc_dev, struct counts *num, hwc_display_contents_1_t *list) { unsigned int i; /* Figure out how many layers we can support via DSS */ for (i = 0; list && i < list->numHwLayers; i++) { - hwc_layer_t *layer = &list->hwLayers[i]; + hwc_layer_1_t *layer = &list->hwLayers[i]; IMG_native_handle_t *handle = (IMG_native_handle_t *)layer->handle; layer->compositionType = HWC_FRAMEBUFFER; @@ -1076,7 +1077,7 @@ static int can_dss_render_all(omap4_hwc_device_t *hwc_dev, struct counts *num) } static inline int can_dss_render_layer(omap4_hwc_device_t *hwc_dev, - hwc_layer_t *layer) + hwc_layer_1_t *layer) { IMG_native_handle_t *handle = (IMG_native_handle_t *)layer->handle; @@ -1183,8 +1184,44 @@ static int setup_mirroring(omap4_hwc_device_t *hwc_dev) return 0; } -static int omap4_hwc_prepare(struct hwc_composer_device *dev, hwc_layer_list_t* list) +/* + * We're using "implicit" synchronization, so make sure we aren't passing any + * sync object descriptors around. + */ +static void check_sync_fds(size_t numDisplays, hwc_display_contents_1_t** displays) +{ + //ALOGD("checking sync FDs"); + unsigned int i, j; + for (i = 0; i < numDisplays; i++) { + hwc_display_contents_1_t* list = displays[i]; + if (list->flipFenceFd >= 0) { + ALOGW("flipFenceFd[%u] was %d", i, list->flipFenceFd); + list->flipFenceFd = -1; + } + + for (j = 0; j < list->numHwLayers; j++) { + hwc_layer_1_t* layer = &list->hwLayers[j]; + if (layer->acquireFenceFd >= 0) { + ALOGW("acquireFenceFd[%u][%u] was %d, closing", i, j, layer->acquireFenceFd); + close(layer->acquireFenceFd); + layer->acquireFenceFd = -1; + } + if (layer->releaseFenceFd >= 0) { + ALOGW("releaseFenceFd[%u][%u] was %d", i, j, layer->releaseFenceFd); + layer->releaseFenceFd = -1; + } + } + } +} + +static int omap4_hwc_prepare(struct hwc_composer_device_1 *dev, size_t numDisplays, + hwc_display_contents_1_t** displays) { + if (!numDisplays || displays == NULL) { + return 0; + } + + hwc_display_contents_1_t* list = displays[0]; // ignore displays beyond the first omap4_hwc_device_t *hwc_dev = (omap4_hwc_device_t *)dev; struct dsscomp_setup_dispc_data *dsscomp = &hwc_dev->dsscomp_data; struct counts num = { .composited_layers = list ? list->numHwLayers : 0 }; @@ -1224,7 +1261,7 @@ static int omap4_hwc_prepare(struct hwc_composer_device *dev, hwc_layer_list_t* unsigned int mem_used = 0; hwc_dev->ovls_blending = 0; for (i = 0; list && i < list->numHwLayers; i++) { - hwc_layer_t *layer = &list->hwLayers[i]; + hwc_layer_1_t *layer = &list->hwLayers[i]; IMG_native_handle_t *handle = (IMG_native_handle_t *)layer->handle; if (dsscomp->num_ovls < num.max_hw_overlays && @@ -1425,9 +1462,20 @@ static void omap4_hwc_reset_screen(omap4_hwc_device_t *hwc_dev) } } -static int omap4_hwc_set(struct hwc_composer_device *dev, hwc_display_t dpy, - hwc_surface_t sur, hwc_layer_list_t* list) +static int omap4_hwc_set(struct hwc_composer_device_1 *dev, + size_t numDisplays, hwc_display_contents_1_t** displays) { + if (!numDisplays || displays == NULL) { + ALOGD("set: empty display list"); + return 0; + } + hwc_display_t dpy = NULL; + hwc_surface_t sur = NULL; + hwc_display_contents_1_t* list = displays[0]; // ignore displays beyond the first + if (list != NULL) { + dpy = list->dpy; + sur = list->sur; + } omap4_hwc_device_t *hwc_dev = (omap4_hwc_device_t *)dev; struct dsscomp_setup_dispc_data *dsscomp = &hwc_dev->dsscomp_data; int err = 0; @@ -1472,6 +1520,8 @@ static int omap4_hwc_set(struct hwc_composer_device *dev, hwc_display_t dpy, if (err) ALOGE("Post2 error"); + check_sync_fds(numDisplays, displays); + err_out: pthread_mutex_unlock(&hwc_dev->lock); @@ -1481,7 +1531,7 @@ err_out: return err; } -static void omap4_hwc_dump(struct hwc_composer_device *dev, char *buff, int buff_len) +static void omap4_hwc_dump(struct hwc_composer_device_1 *dev, char *buff, int buff_len) { omap4_hwc_device_t *hwc_dev = (omap4_hwc_device_t *)dev; struct dsscomp_setup_dispc_data *dsscomp = &hwc_dev->dsscomp_data; @@ -1853,7 +1903,7 @@ static void *omap4_hwc_hdmi_thread(void *data) return NULL; } -static void omap4_hwc_registerProcs(struct hwc_composer_device* dev, +static void omap4_hwc_registerProcs(struct hwc_composer_device_1* dev, hwc_procs_t const* procs) { omap4_hwc_device_t *hwc_dev = (omap4_hwc_device_t *) dev; @@ -1861,7 +1911,7 @@ static void omap4_hwc_registerProcs(struct hwc_composer_device* dev, hwc_dev->procs = (typeof(hwc_dev->procs)) procs; } -static int omap4_hwc_query(struct hwc_composer_device* dev, +static int omap4_hwc_query(struct hwc_composer_device_1* dev, int what, int* value) { omap4_hwc_device_t *hwc_dev = (omap4_hwc_device_t *) dev; @@ -1882,8 +1932,8 @@ static int omap4_hwc_query(struct hwc_composer_device* dev, return 0; } -static int omap4_hwc_event_control(struct hwc_composer_device* dev, - int event, int enabled) +static int omap4_hwc_event_control(struct hwc_composer_device_1* dev, + int dpy, int event, int enabled) { omap4_hwc_device_t *hwc_dev = (omap4_hwc_device_t *) dev; @@ -1904,8 +1954,16 @@ static int omap4_hwc_event_control(struct hwc_composer_device* dev, } } -struct hwc_methods omap4_hwc_methods = { +static int omap4_blank(struct hwc_composer_device_1 *dev, int dpy, int blank) +{ + // We're using an older method of screen blanking based on + // early_suspend in the kernel. No need to do anything here. + return 0; +} + +struct hwc_methods_1 omap4_hwc_methods = { .eventControl = &omap4_hwc_event_control, + .blank = &omap4_blank, }; static int omap4_hwc_device_open(const hw_module_t* module, const char* name, @@ -1938,13 +1996,7 @@ static int omap4_hwc_device_open(const hw_module_t* module, const char* name, memset(hwc_dev, 0, sizeof(*hwc_dev)); hwc_dev->base.common.tag = HARDWARE_DEVICE_TAG; - char product_value[PROPERTY_VALUE_MAX]; - property_get("ro.product.board", product_value, ""); - if (strncmp("panda", product_value, PROPERTY_VALUE_MAX) == 0) - hwc_dev->base.common.version = HWC_DEVICE_API_VERSION_0_2; - else - hwc_dev->base.common.version = HWC_DEVICE_API_VERSION_0_3; - + hwc_dev->base.common.version = HWC_DEVICE_API_VERSION_1_0; hwc_dev->base.common.module = (hw_module_t *)module; hwc_dev->base.common.close = omap4_hwc_device_close; hwc_dev->base.prepare = omap4_hwc_prepare; -- cgit v1.1