1e41f4b71Sopenharmony_ci# Display VDI 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## Overview 4e41f4b71Sopenharmony_ciThe display vendor device interface (VDI) is provided for chip vendor devices to access to the OpenHarmony display driver framework model. 5e41f4b71Sopenharmony_ciThe display VDI interface consists of the following: 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci- Composer: implements layer composition and display. 8e41f4b71Sopenharmony_ci- Buffer: implements allocation and release of the surface buffer. 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci### Composer 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci**Figure 1** Display composer HDI architecture 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ciThe framework model consists of the following layers: 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci+ Framework layer: interacts with the HDI implementation layer to implements composition and display of layers and manages hardware devices of the display module. 19e41f4b71Sopenharmony_ci+ HDI implementation layer: implements the OpenHarmony Composer HDI interface. 20e41f4b71Sopenharmony_ci+ Vendor driver layer: supports multi-platform adaptation by shielding the differences between underlying chips and OSs. 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ci### Buffer 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci**Figure 2** Display buffer HDI architecture 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ciThe framework model consists of the following layers: 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci+ Framework layer: interacts with the HDI implementation layer to implements allocation and release of graphics buffers. 31e41f4b71Sopenharmony_ci+ HDI implementation layer: implements the OpenHarmony buffer HDI interface. 32e41f4b71Sopenharmony_ci+ Vendor driver layer: supports multi-platform adaptation by shielding the differences between underlying chips and OSs. 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci## Development Guidelines 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci### Composer 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci#### Available APIs 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ciYou can obtain the VDI declaration file **/drivers/peripheral/display/composer/hdi_service/include/idisplay_composer_vdi.h** from [https://gitee.com/openharmony/drivers_peripheral/tree/master/display/composer](https://gitee.com/openharmony/drivers_peripheral/tree/master/display/composer). 42e41f4b71Sopenharmony_ci- idisplay_composer_vdi.h 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ci | API | Description | 45e41f4b71Sopenharmony_ci | ------------------------------------------------------------ | ------------------------------------------------------------ | 46e41f4b71Sopenharmony_ci | int32_t RegHotPlugCallback(HotPlugCallback cb, void* data) | Registers a callback for a hot plug event. | 47e41f4b71Sopenharmony_ci | int32_t GetDisplayCapability(uint32_t devId, DisplayCapability& info) | Obtains the capability set of a display device. | 48e41f4b71Sopenharmony_ci | int32_t GetDisplaySupportedModes(uint32_t devId, std::vector\<DisplayModeInfo\>& modes) | Obtains the supported display modes of a display device. | 49e41f4b71Sopenharmony_ci | int32_t GetDisplayMode(uint32_t devId, uint32_t& modeId) | Obtains the current display mode of a display device. | 50e41f4b71Sopenharmony_ci | int32_t SetDisplayMode(uint32_t devId, uint32_t modeId) | Sets the display mode of a display device. | 51e41f4b71Sopenharmony_ci | int32_t GetDisplayPowerStatus(uint32_t devId, DispPowerStatus& status) | Obtains the power status of a display device. | 52e41f4b71Sopenharmony_ci | int32_t SetDisplayPowerStatus(uint32_t devId, DispPowerStatus status) | Sets the power status of a display device. | 53e41f4b71Sopenharmony_ci | int32_t GetDisplayBacklight(uint32_t devId, uint32_t& level) | Obtains the backlight value of a display device. | 54e41f4b71Sopenharmony_ci | int32_t SetDisplayBacklight(uint32_t devId, uint32_t level) | Sets the backlight value for a display device. | 55e41f4b71Sopenharmony_ci | int32_t GetDisplayProperty(uint32_t devId, uint32_t id, uint64_t& value) | Obtains a property of a display device. | 56e41f4b71Sopenharmony_ci | int32_t GetDisplayCompChange(uint32_t devId, std::vector\<uint32_t\>& layers, std::vector\<int32_t\>& types) | Obtains the layer whose composition type is changed for a display device. | 57e41f4b71Sopenharmony_ci | int32_t SetDisplayClientCrop(uint32_t devId, const IRect& rect) | Sets the cropping area of a display device. | 58e41f4b71Sopenharmony_ci | int32_t SetDisplayClientBuffer(uint32_t devId, const BufferHandle& buffer, int32_t fence) | Sets the display buffer of the display device. | 59e41f4b71Sopenharmony_ci | int32_t SetDisplayClientDamage(uint32_t devId, std::vector\<IRect\>& rects) | Sets the dirty region of a display device. | 60e41f4b71Sopenharmony_ci | int32_t SetDisplayVsyncEnabled(uint32_t devId, bool enabled) | Enables the vertical sync signal. | 61e41f4b71Sopenharmony_ci | int32_t RegDisplayVBlankCallback(uint32_t devId, VBlankCallback cb, void* data) | Registers a VBlank event callback. | 62e41f4b71Sopenharmony_ci | int32_t GetDisplayReleaseFence(uint32_t devId, std::vector\<uint32_t\>& layers, std::vector\<int32_t\>& fences) | Obtains the display layer fence. | 63e41f4b71Sopenharmony_ci | int32_t CreateVirtualDisplay(uint32_t width, uint32_t height, int32_t& format, uint32_t& devId) | Creates a virtual display device. | 64e41f4b71Sopenharmony_ci | int32_t DestroyVirtualDisplay(uint32_t devId) | Destroys a virtual display device. | 65e41f4b71Sopenharmony_ci | int32_t SetVirtualDisplayBuffer(uint32_t devId, const BufferHandle& buffer, const int32_t fence) | Sets the output buffer of a virtual display. | 66e41f4b71Sopenharmony_ci | int32_t SetDisplayProperty(uint32_t devId, uint32_t id, uint64_t value) | Sets a property for a display device. | 67e41f4b71Sopenharmony_ci | int32_t Commit(uint32_t devId, int32_t& fence) | Commits a composition request. | 68e41f4b71Sopenharmony_ci | int32_t CreateLayer(uint32_t devId, const LayerInfo& layerInfo, uint32_t& layerId) | Creates a layer. | 69e41f4b71Sopenharmony_ci | int32_t DestroyLayer(uint32_t devId, uint32_t layerId) | Destroys a layer. | 70e41f4b71Sopenharmony_ci | int32_t PrepareDisplayLayers(uint32_t devId, bool& needFlushFb) | Prepares the layers to display. | 71e41f4b71Sopenharmony_ci | int32_t SetLayerAlpha(uint32_t devId, uint32_t layerId, const LayerAlpha& alpha) | Sets the alpha value of a layer. | 72e41f4b71Sopenharmony_ci | int32_t SetLayerRegion(uint32_t devId, uint32_t layerId, const IRect& rect) | Sets the region for a layer. | 73e41f4b71Sopenharmony_ci | int32_t SetLayerCrop(uint32_t devId, uint32_t layerId, const IRect& rect) | Sets the cropping area for a layer. | 74e41f4b71Sopenharmony_ci | int32_t SetLayerZorder(uint32_t devId, uint32_t layerId, uint32_t zorder) | Sets the Z-axis order for a layer. | 75e41f4b71Sopenharmony_ci | int32_t SetLayerPreMulti(uint32_t devId, uint32_t layerId, bool preMul) | Sets the premultiplication for a layer. | 76e41f4b71Sopenharmony_ci | int32_t SetLayerTransformMode(uint32_t devId, uint32_t layerId, TransformType type) | Sets the transform mode for a layer. | 77e41f4b71Sopenharmony_ci | int32_t SetLayerDirtyRegion(uint32_t devId, uint32_t layerId, const std::vector\<IRect\>& rects) | Sets the dirty region of a layer. | 78e41f4b71Sopenharmony_ci | int32_t SetLayerVisibleRegion(uint32_t devId, uint32_t layerId, std::vector\<IRect\>& rects) | Sets the visible region of a layer. | 79e41f4b71Sopenharmony_ci | int32_t SetLayerBuffer(uint32_t devId, uint32_t layerId, const BufferHandle& buffer, int32_t fence) | Sets the buffer for a layer. | 80e41f4b71Sopenharmony_ci | int32_t SetLayerCompositionType(uint32_t devId, uint32_t layerId, CompositionType type) | Sets the expected composition type for the client. | 81e41f4b71Sopenharmony_ci | int32_t SetLayerBlendType(uint32_t devId, uint32_t layerId, BlendType type) | Sets the blend type for a layer. | 82e41f4b71Sopenharmony_ci | int32_t SetLayerMaskInfo(uint32_t devId, uint32_t layerId, const MaskInfo maskInfo) | Sets the layer mask information. | 83e41f4b71Sopenharmony_ci | int32_t SetLayerColor(uint32_t devId, uint32_t layerId, const LayerColor& layerColor) | Sets the color for a layer. | 84e41f4b71Sopenharmony_ci 85e41f4b71Sopenharmony_ci#### How to Develop 86e41f4b71Sopenharmony_ciThe following walks you through on how to implement the rk3568 composer VDI. 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ci1. Implement the composer VDI APIs. 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ciImplement the APIs defined in **idisplay_composer_vdi.h**. 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci```c++ 93e41f4b71Sopenharmony_ci class DisplayComposerVdiImpl : public IDisplayComposerVdi { 94e41f4b71Sopenharmony_ci public: 95e41f4b71Sopenharmony_ci DisplayComposerVdiImpl(); 96e41f4b71Sopenharmony_ci virtual ~DisplayComposerVdiImpl(); 97e41f4b71Sopenharmony_ci virtual int32_t RegHotPlugCallback(HotPlugCallback cb, void* data) override; 98e41f4b71Sopenharmony_ci virtual int32_t GetDisplayCapability(uint32_t devId, DisplayCapability& info) override; 99e41f4b71Sopenharmony_ci virtual int32_t GetDisplaySupportedModes(uint32_t devId, std::vector<DisplayModeInfo>& modes) override; 100e41f4b71Sopenharmony_ci virtual int32_t GetDisplayMode(uint32_t devId, uint32_t& modeId) override; 101e41f4b71Sopenharmony_ci virtual int32_t SetDisplayMode(uint32_t devId, uint32_t modeId) override; 102e41f4b71Sopenharmony_ci virtual int32_t GetDisplayPowerStatus(uint32_t devId, DispPowerStatus& status) override; 103e41f4b71Sopenharmony_ci virtual int32_t SetDisplayPowerStatus(uint32_t devId, DispPowerStatus status) override; 104e41f4b71Sopenharmony_ci virtual int32_t GetDisplayBacklight(uint32_t devId, uint32_t& level) override; 105e41f4b71Sopenharmony_ci virtual int32_t SetDisplayBacklight(uint32_t devId, uint32_t level) override; 106e41f4b71Sopenharmony_ci virtual int32_t GetDisplayProperty(uint32_t devId, uint32_t id, uint64_t& value) override; 107e41f4b71Sopenharmony_ci virtual int32_t GetDisplayCompChange(uint32_t devId, std::vector<uint32_t>& layers, 108e41f4b71Sopenharmony_ci std::vector<int32_t>& types) override; 109e41f4b71Sopenharmony_ci virtual int32_t SetDisplayClientCrop(uint32_t devId, const IRect& rect) override; 110e41f4b71Sopenharmony_ci virtual int32_t SetDisplayClientBuffer(uint32_t devId, const BufferHandle& buffer, int32_t fence) override; 111e41f4b71Sopenharmony_ci virtual int32_t SetDisplayClientDamage(uint32_t devId, std::vector<IRect>& rects) override; 112e41f4b71Sopenharmony_ci virtual int32_t SetDisplayVsyncEnabled(uint32_t devId, bool enabled) override; 113e41f4b71Sopenharmony_ci virtual int32_t RegDisplayVBlankCallback(uint32_t devId, VBlankCallback cb, void* data) override; 114e41f4b71Sopenharmony_ci virtual int32_t GetDisplayReleaseFence(uint32_t devId, std::vector<uint32_t>& layers, 115e41f4b71Sopenharmony_ci std::vector<int32_t>& fences) override; 116e41f4b71Sopenharmony_ci virtual int32_t CreateVirtualDisplay(uint32_t width, uint32_t height, int32_t& format, uint32_t& devId) override; 117e41f4b71Sopenharmony_ci virtual int32_t DestroyVirtualDisplay(uint32_t devId) override; 118e41f4b71Sopenharmony_ci virtual int32_t SetVirtualDisplayBuffer(uint32_t devId, const BufferHandle& buffer, const int32_t fence) override; 119e41f4b71Sopenharmony_ci virtual int32_t SetDisplayProperty(uint32_t devId, uint32_t id, uint64_t value) override; 120e41f4b71Sopenharmony_ci virtual int32_t Commit(uint32_t devId, int32_t& fence) override; 121e41f4b71Sopenharmony_ci virtual int32_t CreateLayer(uint32_t devId, const LayerInfo& layerInfo, uint32_t& layerId) override; 122e41f4b71Sopenharmony_ci virtual int32_t DestroyLayer(uint32_t devId, uint32_t layerId) override; 123e41f4b71Sopenharmony_ci virtual int32_t PrepareDisplayLayers(uint32_t devId, bool& needFlushFb) override; 124e41f4b71Sopenharmony_ci virtual int32_t SetLayerAlpha(uint32_t devId, uint32_t layerId, const LayerAlpha& alpha) override; 125e41f4b71Sopenharmony_ci virtual int32_t SetLayerRegion(uint32_t devId, uint32_t layerId, const IRect& rect) override; 126e41f4b71Sopenharmony_ci virtual int32_t SetLayerCrop(uint32_t devId, uint32_t layerId, const IRect& rect) override; 127e41f4b71Sopenharmony_ci virtual int32_t SetLayerZorder(uint32_t devId, uint32_t layerId, uint32_t zorder) override; 128e41f4b71Sopenharmony_ci virtual int32_t SetLayerPreMulti(uint32_t devId, uint32_t layerId, bool preMul) override; 129e41f4b71Sopenharmony_ci virtual int32_t SetLayerTransformMode(uint32_t devId, uint32_t layerId, TransformType type) override; 130e41f4b71Sopenharmony_ci virtual int32_t SetLayerDirtyRegion(uint32_t devId, uint32_t layerId, const std::vector<IRect>& rects) override; 131e41f4b71Sopenharmony_ci virtual int32_t SetLayerVisibleRegion(uint32_t devId, uint32_t layerId, std::vector<IRect>& rects) override; 132e41f4b71Sopenharmony_ci virtual int32_t SetLayerBuffer(uint32_t devId, uint32_t layerId, 133e41f4b71Sopenharmony_ci const BufferHandle& buffer, int32_t fence) override; 134e41f4b71Sopenharmony_ci virtual int32_t SetLayerCompositionType(uint32_t devId, uint32_t layerId, CompositionType type) override; 135e41f4b71Sopenharmony_ci virtual int32_t SetLayerBlendType(uint32_t devId, uint32_t layerId, BlendType type) override; 136e41f4b71Sopenharmony_ci virtual int32_t SetLayerMaskInfo(uint32_t devId, uint32_t layerId, const MaskInfo maskInfo) override; 137e41f4b71Sopenharmony_ci virtual int32_t SetLayerColor(uint32_t devId, uint32_t layerId, const LayerColor& layerColor) override; 138e41f4b71Sopenharmony_ci }; 139e41f4b71Sopenharmony_ci using CreateComposerVdiFunc = IDisplayComposerVdi* (*)(); 140e41f4b71Sopenharmony_ci using DestroyComposerVdiFunc = void (*)(IDisplayComposerVdi* vdi); 141e41f4b71Sopenharmony_ci extern "C" IDisplayComposerVdi* CreateComposerVdi(); 142e41f4b71Sopenharmony_ci extern "C" void DestroyComposerVdi(IDisplayComposerVdi* vdi); 143e41f4b71Sopenharmony_ci``` 144e41f4b71Sopenharmony_ci 145e41f4b71Sopenharmony_ci2. Build a shared library. 146e41f4b71Sopenharmony_ci 147e41f4b71Sopenharmony_ciBuild a shared library named **libdisplay_composer_vdi_impl.z.so**. Write the **BUILD.gn** file. You can obtain the **BUILD.gn** file of rk3568 from [https://gitee.com/openharmony/device_soc_rockchip/blob/master/rk3568/hardware/display/BUILD.gn](https://gitee.com/openharmony/device_soc_rockchip/blob/master/rk3568/hardware/display/BUILD.gn). 148e41f4b71Sopenharmony_ci 149e41f4b71Sopenharmony_ci``` 150e41f4b71Sopenharmony_ci ohos_shared_library("libdisplay_composer_vdi_impl") { 151e41f4b71Sopenharmony_ci sources = [ "src/display_device/display_composer_vdi_impl.cpp" ] 152e41f4b71Sopenharmony_ci 153e41f4b71Sopenharmony_ci include_dirs = [ 154e41f4b71Sopenharmony_ci "src/display_device", 155e41f4b71Sopenharmony_ci "${root_path}/drivers/peripheral/display/utils/include", 156e41f4b71Sopenharmony_ci "${root_path}/drivers/interface/display/composer", 157e41f4b71Sopenharmony_ci "${root_path}/drivers/peripheral/display/composer/hdi_service/include", 158e41f4b71Sopenharmony_ci "${root_path}/drivers/interface/display/composer/hdifd_parcelable", 159e41f4b71Sopenharmony_ci ] 160e41f4b71Sopenharmony_ci 161e41f4b71Sopenharmony_ci deps = [ ":display_composer_vendor" ] 162e41f4b71Sopenharmony_ci 163e41f4b71Sopenharmony_ci external_deps = [ 164e41f4b71Sopenharmony_ci "c_utils:utils", 165e41f4b71Sopenharmony_ci "drivers_interface_display:display_composer_idl_headers", 166e41f4b71Sopenharmony_ci "graphic_chipsetsdk:buffer_handle", 167e41f4b71Sopenharmony_ci "hilog:libhilog", 168e41f4b71Sopenharmony_ci "ipc:ipc_single", 169e41f4b71Sopenharmony_ci ] 170e41f4b71Sopenharmony_ci 171e41f4b71Sopenharmony_ci install_enable = true 172e41f4b71Sopenharmony_ci install_images = [ chipset_base_dir ] 173e41f4b71Sopenharmony_ci subsystem_name = "hdf" 174e41f4b71Sopenharmony_ci part_name = "rockchip_products" 175e41f4b71Sopenharmony_ci } 176e41f4b71Sopenharmony_ci``` 177e41f4b71Sopenharmony_ciIn the root directory of your project, run the following command to build the share library: 178e41f4b71Sopenharmony_ci 179e41f4b71Sopenharmony_ci``` 180e41f4b71Sopenharmony_ci ./build.sh -p rk3568 -T display_composer_model 181e41f4b71Sopenharmony_ci``` 182e41f4b71Sopenharmony_ciThen, you can find **libdisplay_composer_vdi_impl.z.so** in the **out/rk3568/hdf/rockchip_products** directory. 183e41f4b71Sopenharmony_ci 184e41f4b71Sopenharmony_ci#### Development Example 185e41f4b71Sopenharmony_ci 186e41f4b71Sopenharmony_ciA default VDI implementation is provided for your reference. For details, see **drivers/peripheral/display/composer/vdi_base** at [https://gitee.com/openharmony/drivers_peripheral/tree/master/display/composer/vdi_base](https://gitee.com/openharmony/drivers_peripheral/tree/master/display/composer/vdi_base). 187e41f4b71Sopenharmony_ci 188e41f4b71Sopenharmony_ci### Buffer 189e41f4b71Sopenharmony_ci 190e41f4b71Sopenharmony_ci#### Available APIs 191e41f4b71Sopenharmony_ci 192e41f4b71Sopenharmony_ciYou can obtain the VDI declaration file **/drivers/peripheral/display/buffer/hdi_service/include/idisplay_buffer_vdi.h** from [https://gitee.com/openharmony/drivers_peripheral/tree/master/display/buffer](https://gitee.com/openharmony/drivers_peripheral/tree/master/display/buffer). 193e41f4b71Sopenharmony_ci- idisplay_composer_vdi.h 194e41f4b71Sopenharmony_ci 195e41f4b71Sopenharmony_ci | API | Description | 196e41f4b71Sopenharmony_ci | ------------------------------------------------------------ | ------------------------------------------------------------ | 197e41f4b71Sopenharmony_ci | int32_t AllocMem(const AllocInfo& info, BufferHandle*& handle) | Allocates a buffer. | 198e41f4b71Sopenharmony_ci | void FreeMem(const BufferHandle& handle) | Releases a buffer. | 199e41f4b71Sopenharmony_ci | void* Mmap(const BufferHandle& handle) | Maps a buffer to the memory. | 200e41f4b71Sopenharmony_ci | int32_t Unmap(const BufferHandle& handle) | Unmaps a buffer. | 201e41f4b71Sopenharmony_ci | int32_t FlushCache(const BufferHandle& handle) | Flushes a buffer. | 202e41f4b71Sopenharmony_ci | int32_t InvalidateCache(const BufferHandle& handle) | Invalidates a buffer. | 203e41f4b71Sopenharmony_ci | int32_t IsSupportedAlloc(const std::vector<VerifyAllocInfo>& infos, std::vector<bool>& supporteds) | Checks whether the requested buffer can be allocated. | 204e41f4b71Sopenharmony_ci | int32_t RegisterBuffer(const BufferHandle& handle) | Registers a buffer. | 205e41f4b71Sopenharmony_ci | int32_t GetMetadata(const BufferHandle& handle, uint32_t key, std::vector<uint8_t>& value) | Obtains the metadata of a buffer. | 206e41f4b71Sopenharmony_ci | int32_t ListMetadataKeys(const BufferHandle& handle, std::vector<uint32_t>& keys) | Lists the keys of the metadata. | 207e41f4b71Sopenharmony_ci | int32_t EraseMetadataKey(const BufferHandle& handle, uint32_t key) | Erases the metadata of the specified key. | 208e41f4b71Sopenharmony_ci 209e41f4b71Sopenharmony_ci#### How to Develop 210e41f4b71Sopenharmony_ciThe following walks you through on how to implement the rk3568 buffer VDI. 211e41f4b71Sopenharmony_ci 212e41f4b71Sopenharmony_ci1. Implement the buffer VDI APIs. 213e41f4b71Sopenharmony_ci 214e41f4b71Sopenharmony_ci Implement the APIs defined in **idisplay_buffer_vdi.h**. 215e41f4b71Sopenharmony_ci 216e41f4b71Sopenharmony_ci```c++ 217e41f4b71Sopenharmony_ci class DisplayBufferVdiImpl : public IDisplayBufferVdi { 218e41f4b71Sopenharmony_ci public: 219e41f4b71Sopenharmony_ci DisplayBufferVdiImpl(); 220e41f4b71Sopenharmony_ci virtual ~DisplayBufferVdiImpl(); 221e41f4b71Sopenharmony_ci 222e41f4b71Sopenharmony_ci virtual int32_t AllocMem(const AllocInfo& info, BufferHandle*& handle) const override; 223e41f4b71Sopenharmony_ci virtual void FreeMem(const BufferHandle& handle) const override; 224e41f4b71Sopenharmony_ci virtual void *Mmap(const BufferHandle& handle) const override; 225e41f4b71Sopenharmony_ci virtual int32_t Unmap(const BufferHandle& handle) const override; 226e41f4b71Sopenharmony_ci virtual int32_t FlushCache(const BufferHandle& handle) const override; 227e41f4b71Sopenharmony_ci virtual int32_t InvalidateCache(const BufferHandle& handle) const override; 228e41f4b71Sopenharmony_ci virtual int32_t IsSupportedAlloc(const std::vector<VerifyAllocInfo>& infos, 229e41f4b71Sopenharmony_ci std::vector<bool>& supporteds) const override; 230e41f4b71Sopenharmony_ci virtual int32_t RegisterBuffer(const BufferHandle& handle) override; 231e41f4b71Sopenharmony_ci virtual int32_t SetMetadata(const BufferHandle& handle, uint32_t key, const std::vector<uint8_t>& value) override; 232e41f4b71Sopenharmony_ci virtual int32_t GetMetadata(const BufferHandle& handle, uint32_t key, std::vector<uint8_t>& value) override; 233e41f4b71Sopenharmony_ci virtual int32_t ListMetadataKeys(const BufferHandle& handle, std::vector<uint32_t>& keys) override; 234e41f4b71Sopenharmony_ci virtual int32_t EraseMetadataKey(const BufferHandle& handle, uint32_t key) override; 235e41f4b71Sopenharmony_ci }; 236e41f4b71Sopenharmony_ci using CreateDisplayBufferVdiFunc = IDisplayBufferVdi* (*)(); 237e41f4b71Sopenharmony_ci using DestroyDisplayBufferVdiFunc = void (*)(IDisplayBufferVdi* vdi); 238e41f4b71Sopenharmony_ci extern "C" IDisplayBufferVdi* CreateDisplayBufferVdi(); 239e41f4b71Sopenharmony_ci extern "C" void DestroyDisplayBufferVdi(IDisplayBufferVdi* vdi); 240e41f4b71Sopenharmony_ci``` 241e41f4b71Sopenharmony_ci 242e41f4b71Sopenharmony_ci2. Build a shared library. 243e41f4b71Sopenharmony_ci 244e41f4b71Sopenharmony_ci Build a shared library named **libdisplay_buffer_vdi_impl.z.so**. Write the **BUILD.gn** file. You can obtain the **BUILD.gn** file of rk3568 from [https://gitee.com/openharmony/device_soc_rockchip/blob/master/rk3568/hardware/display/BUILD.gn](https://gitee.com/openharmony/device_soc_rockchip/blob/master/rk3568/hardware/display/BUILD.gn). 245e41f4b71Sopenharmony_ci 246e41f4b71Sopenharmony_ci``` 247e41f4b71Sopenharmony_ci ohos_shared_library("libdisplay_buffer_vdi_impl") { 248e41f4b71Sopenharmony_ci sources = [ "src/display_gralloc/display_buffer_vdi_impl.cpp" ] 249e41f4b71Sopenharmony_ci 250e41f4b71Sopenharmony_ci public_configs = [ ":libdisplay_buffer_vdi_impl_config" ] 251e41f4b71Sopenharmony_ci 252e41f4b71Sopenharmony_ci include_dirs = [ 253e41f4b71Sopenharmony_ci "./src/display_gralloc", 254e41f4b71Sopenharmony_ci "${root_path}/drivers/peripheral/base", 255e41f4b71Sopenharmony_ci "${root_path}/drivers/interface/display/composer/hdifd_parcelable", 256e41f4b71Sopenharmony_ci "${root_path}/drivers/interface/display/buffer", 257e41f4b71Sopenharmony_ci "${root_path}/drivers/peripheral/display/utils/include", 258e41f4b71Sopenharmony_ci "${root_path}/drivers/peripheral/display/buffer/hdi_service/include", 259e41f4b71Sopenharmony_ci ] 260e41f4b71Sopenharmony_ci 261e41f4b71Sopenharmony_ci output_name = "libdisplay_buffer_vdi_impl" 262e41f4b71Sopenharmony_ci cflags = [ 263e41f4b71Sopenharmony_ci "-DGRALLOC_GBM_SUPPORT", 264e41f4b71Sopenharmony_ci "-Wno-macro-redefined", 265e41f4b71Sopenharmony_ci ] 266e41f4b71Sopenharmony_ci deps = [ ":libdisplay_buffer_vendor" ] 267e41f4b71Sopenharmony_ci 268e41f4b71Sopenharmony_ci external_deps = [ 269e41f4b71Sopenharmony_ci "c_utils:utils", 270e41f4b71Sopenharmony_ci "drivers_interface_display:display_buffer_idl_headers", 271e41f4b71Sopenharmony_ci "drivers_interface_display:display_composer_idl_headers", 272e41f4b71Sopenharmony_ci "hdf_core:libhdf_utils", 273e41f4b71Sopenharmony_ci "hilog:libhilog", 274e41f4b71Sopenharmony_ci "ipc:ipc_single", 275e41f4b71Sopenharmony_ci ] 276e41f4b71Sopenharmony_ci 277e41f4b71Sopenharmony_ci install_enable = true 278e41f4b71Sopenharmony_ci install_images = [ chipset_base_dir ] 279e41f4b71Sopenharmony_ci innerapi_tags = [ "passthrough" ] 280e41f4b71Sopenharmony_ci subsystem_name = "hdf" 281e41f4b71Sopenharmony_ci part_name = "rockchip_products" 282e41f4b71Sopenharmony_ci } 283e41f4b71Sopenharmony_ci``` 284e41f4b71Sopenharmony_ci 285e41f4b71Sopenharmony_ciIn the root directory of your project, run the following command to build the share library: 286e41f4b71Sopenharmony_ci 287e41f4b71Sopenharmony_ci``` 288e41f4b71Sopenharmony_ci ./build.sh -p rk3568 -T display_buffer_model 289e41f4b71Sopenharmony_ci``` 290e41f4b71Sopenharmony_ciThen, you can find **libdisplay_buffer_vdi_impl.z.so** in the **out/rk3568/hdf/rockchip_products** directory. 291e41f4b71Sopenharmony_ci 292e41f4b71Sopenharmony_ci#### Development Example 293e41f4b71Sopenharmony_ci 294e41f4b71Sopenharmony_ciA default VDI implementation is provided for your reference. For details, see **drivers/peripheral/display/buffer/vdi_base** at [https://gitee.com/openharmony/drivers_peripheral/tree/master/display/buffer/vdi_base](https://gitee.com/openharmony/drivers_peripheral/tree/master/display/buffer/vdi_base). 295