OSDN Git Service

Revert "Use drm gem acess userdata IOCTL for set/get interlace"
authorLin Johnson <johnson.lin@intel.com>
Fri, 14 Sep 2018 06:38:35 +0000 (14:38 +0800)
committerLin Johnson <johnson.lin@intel.com>
Fri, 14 Sep 2018 06:38:35 +0000 (14:38 +0800)
This reverts commit b3f47fbc17eb33a85ce6f0796dfa3a6d0df13cfe.

cros_gralloc/cros_gralloc_driver.cc
cros_gralloc/cros_gralloc_driver.h
cros_gralloc/gralloc1/cros_gralloc1_module.cc
cros_gralloc/gralloc1/cros_gralloc1_module.h
cros_gralloc/i915_private_android_types.h

index 4574c5b..f78c7e0 100644 (file)
@@ -9,12 +9,11 @@
 
 #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)
 {
@@ -171,69 +170,10 @@ int32_t cros_gralloc_driver::allocate(const struct cros_gralloc_buffer_descripto
        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) {
index bf84092..375506f 100644 (file)
@@ -33,10 +33,6 @@ class cros_gralloc_driver
 
        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 &);
index f0b3f04..d9136fa 100644 (file)
@@ -221,12 +221,10 @@ gralloc1_function_pointer_t CrosGralloc1::doGetFunction(int32_t intDescriptor)
                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;
@@ -292,19 +290,11 @@ int32_t CrosGralloc1::setFormat(gralloc1_buffer_descriptor_t descriptorId, int32
 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)
index cd222ec..70e5176 100644 (file)
@@ -98,9 +98,8 @@ class CrosGralloc1 : public gralloc1_device_t
                              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,
@@ -136,21 +135,15 @@ class CrosGralloc1 : public gralloc1_device_t
                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);
         }
 
index 4ed993c..b1e0410 100644 (file)
@@ -69,7 +69,6 @@ enum { GRALLOC1_FUNCTION_SET_MODIFIER = 101,
        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)(
@@ -81,17 +80,11 @@ typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_GET_BYTE_STRIDE)(
 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;