1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIBADFHWC_ADFHWC_H_
#define _LIBADFHWC_ADFHWC_H_
#include <stdbool.h>
#include <stdint.h>
#include <sys/cdefs.h>
#include <video/adf.h>
#include <hardware/hwcomposer.h>
#include <hardware/hwcomposer2.h>
struct adf_hwc_helper;
struct adf_hwc_event_callbacks {
/**
* Called on vsync (required)
*/
void (*vsync)(void *data, int disp, uint64_t timestamp);
/**
* Called on hotplug (required)
*/
void (*hotplug)(void *data, int disp, bool connected);
/**
* Called on hardware-custom ADF events (optional)
*/
void (*custom_event)(void *data, int disp, struct adf_event *event);
};
/**
* Converts HAL pixel formats to equivalent ADF/DRM format FourCCs.
*/
static inline uint32_t adf_fourcc_for_hal_pixel_format(int format)
{
switch (format) {
case HAL_PIXEL_FORMAT_RGBA_8888:
return DRM_FORMAT_RGBA8888;
case HAL_PIXEL_FORMAT_RGBX_8888:
return DRM_FORMAT_RGBX8888;
case HAL_PIXEL_FORMAT_RGB_888:
return DRM_FORMAT_RGB888;
case HAL_PIXEL_FORMAT_RGB_565:
return DRM_FORMAT_RGB565;
case HAL_PIXEL_FORMAT_BGRA_8888:
return DRM_FORMAT_BGRA8888;
case HAL_PIXEL_FORMAT_YV12:
return DRM_FORMAT_YVU420;
case HAL_PIXEL_FORMAT_YCbCr_422_SP:
return DRM_FORMAT_NV16;
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
return DRM_FORMAT_NV21;
case HAL_PIXEL_FORMAT_YCbCr_422_I:
return DRM_FORMAT_YUYV;
default:
return 0;
}
}
/**
* Converts HAL display types to equivalent ADF interface flags.
*/
static inline uint32_t adf_hwc_interface_flag_for_disp(int disp)
{
switch (disp) {
case HWC_DISPLAY_PRIMARY:
return ADF_INTF_FLAG_PRIMARY;
case HWC_DISPLAY_EXTERNAL:
return ADF_INTF_FLAG_EXTERNAL;
default:
return 0;
}
}
__BEGIN_DECLS
/**
* Create a HWC helper for the specified ADF interfaces.
*
* intf_fds must be indexed by HWC display type: e.g.,
* intf_fds[HWC_DISPLAY_PRIMARY] is the fd for the primary display
* interface. n_intfs must be >= 1.
*
* The caller retains ownership of the fds in intf_fds and must close()
* them when they are no longer needed.
*
* On error, returns -errno.
*/
int adf_hwc_open(int *intf_fds, size_t n_intfs,
const struct adf_hwc_event_callbacks *event_cb, void *event_cb_data,
struct adf_hwc_helper **dev);
/**
* Destroys a HWC helper.
*/
void adf_hwc_close(struct adf_hwc_helper *dev);
/**
* Generic implementations of common HWC ops.
*
* The HWC should not point its ops directly at these helpers. Instead, the HWC
* should provide stub ops which call these helpers after converting the
* hwc_composer_device_1* to a struct adf_hwc_helper*.
*/
int adf_eventControl(struct adf_hwc_helper *dev, int disp, int event,
int enabled);
int adf_blank(struct adf_hwc_helper *dev, int disp, int blank);
int adf_query_display_types_supported(struct adf_hwc_helper *dev, int *value);
int adf_getDisplayConfigs(struct adf_hwc_helper *dev, int disp,
uint32_t *configs, size_t *numConfigs);
int adf_getDisplayAttributes(struct adf_hwc_helper *dev, int disp,
uint32_t config, const uint32_t *attributes, int32_t *values);
/**
* Generic implementation of common HWC2 functions.
*
* The HWC2 should not return these functions directly through getFunction.
* Instead, the HWC2 should return stub functions which call these helpers.
*/
int adf_getDisplayAttributes_hwc2(struct adf_hwc_helper *dev, int disp,
uint32_t config, const uint32_t *attributes, int32_t *values);
int adf_set_active_config_hwc2(struct adf_hwc_helper *dev, int disp,
uint32_t config);
__END_DECLS
#endif /* _LIBADFHWC_ADFHWC_H_ */
|