#include "i915_private_android.h"
-#include <cstdlib>
#include <errno.h>
+#include <cstdlib>
#include <fcntl.h>
-#include <i915_drm.h>
-#include <unistd.h>
#include <xf86drm.h>
+#include <unistd.h>
cros_gralloc_driver::cros_gralloc_driver() : drv_(nullptr)
{
return 0;
}
-int32_t cros_gralloc_driver::setinterlace(buffer_handle_t handle, uint32_t interlace)
-{
- uint32_t id;
- SCOPED_SPIN_LOCK(mutex_);
-
- auto hnd = cros_gralloc_convert_handle(handle);
- if (!hnd) {
- cros_gralloc_error("Invalid handle.");
- return -EINVAL;
- }
-
- if (drmPrimeFDToHandle(drv_get_fd(drv_), hnd->fds[0], &id)) {
- cros_gralloc_error("drmPrimeFDToHandle failed.");
- return -errno;
- }
-
- drm_i915_gem_access_userdata access_userdata;
- access_userdata.handle = id;
- access_userdata.write = 1;
- access_userdata.userdata = interlace;
-
- if (drmIoctl(drv_get_fd(drv_), DRM_IOCTL_I915_GEM_ACCESS_USERDATA, &access_userdata)) {
- cros_gralloc_error("access userdata failed");
- return -errno;
- }
-
- return 0;
-}
-
-int32_t cros_gralloc_driver::getinterlace(buffer_handle_t handle, uint32_t *interlace)
-{
- uint32_t id;
- SCOPED_SPIN_LOCK(mutex_);
-
- auto hnd = cros_gralloc_convert_handle(handle);
- if (!hnd) {
- cros_gralloc_error("Invalid handle.");
- return -EINVAL;
- }
-
- if (drmPrimeFDToHandle(drv_get_fd(drv_), hnd->fds[0], &id)) {
- cros_gralloc_error("drmPrimeFDToHandle failed.");
- return -errno;
- }
-
- drm_i915_gem_access_userdata access_userdata;
- access_userdata.handle = id;
- access_userdata.write = 0;
- access_userdata.userdata = 0;
-
- if (drmIoctl(drv_get_fd(drv_), DRM_IOCTL_I915_GEM_ACCESS_USERDATA, &access_userdata)) {
- cros_gralloc_error("access userdata failed");
- return -errno;
- }
- *interlace = access_userdata.userdata;
-
- return 0;
-}
-
int32_t cros_gralloc_driver::retain(buffer_handle_t handle)
{
uint32_t id;
- SCOPED_SPIN_LOCK(mutex_);
+ SCOPED_SPIN_LOCK(mutex_);
auto hnd = cros_gralloc_convert_handle(handle);
if (!hnd) {
int32_t get_backing_store(buffer_handle_t handle, uint64_t *out_store);
- int32_t setinterlace(buffer_handle_t handle, uint32_t interlace);
-
- int32_t getinterlace(buffer_handle_t handle, uint32_t *interlace);
-
private:
cros_gralloc_driver(cros_gralloc_driver const &);
cros_gralloc_driver operator=(cros_gralloc_driver const &);
return asFP<GRALLOC1_PFN_UNLOCK>(unlockHook);
case GRALLOC1_FUNCTION_SET_MODIFIER:
return asFP<GRALLOC1_PFN_SET_MODIFIER>(setModifierHook);
- case GRALLOC1_FUNCTION_SET_INTERLACE:
- return asFP<GRALLOC1_PFN_SET_INTERLACE>(setInterlaceHook);
- case GRALLOC1_FUNCTION_GET_INTERLACE:
- return asFP<GRALLOC1_PFN_GET_INTERLACE>(getInterlaceHook);
- case GRALLOC1_FUNCTION_SET_PROTECTIONINFO:
- return asFP<GRALLOC1_PFN_SET_PROTECTIONINFO>(setProtectionInfoHook);
+ case GRALLOC1_FUNCTION_SET_INTERLACE:
+ return asFP<GRALLOC1_PFN_SET_INTERLACE>(setInterlaceHook);
+ case GRALLOC1_FUNCTION_SET_PROTECTIONINFO:
+ return asFP<GRALLOC1_PFN_SET_PROTECTIONINFO>(setProtectionInfoHook);
case GRALLOC1_FUNCTION_INVALID:
ALOGE("Invalid function descriptor");
return nullptr;
int32_t CrosGralloc1::setInterlace(buffer_handle_t buffer, uint32_t interlace)
{
auto hnd = (cros_gralloc_handle*) cros_gralloc_convert_handle(buffer);
- if (!hnd) {
- return CROS_GRALLOC_ERROR_BAD_HANDLE;
- }
- return driver->setinterlace(buffer, interlace);
-}
-
-int32_t CrosGralloc1::getInterlace(buffer_handle_t buffer, uint32_t *interlace)
-{
- auto hnd = (cros_gralloc_handle *)cros_gralloc_convert_handle(buffer);
- if (!hnd) {
- return CROS_GRALLOC_ERROR_BAD_HANDLE;
- }
- return driver->getinterlace(buffer, interlace);
+ if (!hnd) {
+ return CROS_GRALLOC_ERROR_BAD_HANDLE;
+ }
+ hnd->is_interlaced = interlace;
+ return CROS_GRALLOC_ERROR_NONE;
}
int32_t CrosGralloc1::setProtectionInfo(buffer_handle_t buffer, uint32_t protection_info)
uint32_t height);
int32_t setFormat(gralloc1_buffer_descriptor_t descriptorId, int32_t format);
- int32_t setInterlace(buffer_handle_t buffer, uint32_t interlace);
- int32_t getInterlace(buffer_handle_t buffer, uint32_t *interlace);
- int32_t setProtectionInfo(buffer_handle_t buffer, uint32_t protection_info);
+ int32_t setInterlace(buffer_handle_t buffer, uint32_t interlace);
+ int32_t setProtectionInfo(buffer_handle_t buffer, uint32_t protection_info);
int32_t createDescriptor(gralloc1_buffer_descriptor_t *outDescriptor);
static int32_t createDescriptorHook(gralloc1_device_t *device,
return getAdapter(device)->setFormat(descriptorId, format);
}
- static int32_t setInterlaceHook(gralloc1_device_t *device, buffer_handle_t buffer,
- uint32_t interlace)
- {
- return getAdapter(device)->setInterlace(buffer, interlace);
- }
-
- static int32_t getInterlaceHook(gralloc1_device_t *device, buffer_handle_t buffer,
- uint32_t *interlace)
- {
- return getAdapter(device)->getInterlace(buffer, interlace);
- }
+ static int32_t setInterlaceHook(gralloc1_device_t *device,
+ buffer_handle_t buffer, uint32_t interlace)
+ {
+ return getAdapter(device)->setInterlace(buffer, interlace);
+ }
- static int32_t setProtectionInfoHook(gralloc1_device_t *device, buffer_handle_t buffer,
- uint32_t protection_info)
- {
+ static int32_t setProtectionInfoHook(gralloc1_device_t *device,
+ buffer_handle_t buffer, uint32_t protection_info)
+ {
return getAdapter(device)->setProtectionInfo(buffer, protection_info);
}
GRALLOC1_FUNCTION_GET_PRIME = 103,
GRALLOC1_FUNCTION_SET_INTERLACE = 104,
GRALLOC1_FUNCTION_SET_PROTECTIONINFO = 105,
- GRALLOC1_FUNCTION_GET_INTERLACE = 106,
GRALLOC1_LAST_CUSTOM = 500 };
typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_SET_MODIFIER)(
typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_GET_PRIME)(
gralloc1_device_t *device, buffer_handle_t buffer, uint32_t *prime);
-typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_SET_INTERLACE)(gralloc1_device_t *device,
- buffer_handle_t buffer,
- uint32_t interlace);
+typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_SET_INTERLACE)(
+ gralloc1_device_t *device, buffer_handle_t buffer, uint32_t interlace);
-typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_GET_INTERLACE)(gralloc1_device_t *device,
- buffer_handle_t buffer,
- uint32_t *interlace);
-
-typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_SET_PROTECTIONINFO)(gralloc1_device_t *device,
- buffer_handle_t buffer,
- uint32_t protection_info);
+typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_SET_PROTECTIONINFO)(
+ gralloc1_device_t *device, buffer_handle_t buffer, uint32_t protection_info);
typedef union intel_protection_info_type_t {
uint32_t value;