Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
0003  */
0004 
0005 #ifndef _DPU_FORMATS_H
0006 #define _DPU_FORMATS_H
0007 
0008 #include <drm/drm_fourcc.h>
0009 #include "msm_gem.h"
0010 #include "dpu_hw_mdss.h"
0011 
0012 /**
0013  * dpu_get_dpu_format_ext() - Returns dpu format structure pointer.
0014  * @format:          DRM FourCC Code
0015  * @modifiers:       format modifier array from client, one per plane
0016  */
0017 const struct dpu_format *dpu_get_dpu_format_ext(
0018         const uint32_t format,
0019         const uint64_t modifier);
0020 
0021 #define dpu_get_dpu_format(f) dpu_get_dpu_format_ext(f, 0)
0022 
0023 /**
0024  * dpu_find_format - validate if the pixel format is supported
0025  * @format:     dpu format
0026  * @supported_formats:  supported formats by dpu HW
0027  * @num_formatss:   total number of formats
0028  *
0029  * Return: false if not valid format, true on success
0030  */
0031 static inline bool dpu_find_format(u32 format, const u32 *supported_formats,
0032                     size_t num_formats)
0033 {
0034     int i;
0035 
0036     for (i = 0; i < num_formats; i++) {
0037         /* check for valid formats supported */
0038         if (format == supported_formats[i])
0039             return true;
0040     }
0041 
0042     return false;
0043 }
0044 
0045 /**
0046  * dpu_get_msm_format - get an dpu_format by its msm_format base
0047  *                     callback function registers with the msm_kms layer
0048  * @kms:             kms driver
0049  * @format:          DRM FourCC Code
0050  * @modifiers:       data layout modifier
0051  */
0052 const struct msm_format *dpu_get_msm_format(
0053         struct msm_kms *kms,
0054         const uint32_t format,
0055         const uint64_t modifiers);
0056 
0057 /**
0058  * dpu_format_check_modified_format - validate format and buffers for
0059  *                   dpu non-standard, i.e. modified format
0060  * @kms:             kms driver
0061  * @msm_fmt:         pointer to the msm_fmt base pointer of an dpu_format
0062  * @cmd:             fb_cmd2 structure user request
0063  * @bos:             gem buffer object list
0064  *
0065  * Return: error code on failure, 0 on success
0066  */
0067 int dpu_format_check_modified_format(
0068         const struct msm_kms *kms,
0069         const struct msm_format *msm_fmt,
0070         const struct drm_mode_fb_cmd2 *cmd,
0071         struct drm_gem_object **bos);
0072 
0073 /**
0074  * dpu_format_populate_layout - populate the given format layout based on
0075  *                     mmu, fb, and format found in the fb
0076  * @aspace:            address space pointer
0077  * @fb:                framebuffer pointer
0078  * @fmtl:              format layout structure to populate
0079  *
0080  * Return: error code on failure, -EAGAIN if success but the addresses
0081  *         are the same as before or 0 if new addresses were populated
0082  */
0083 int dpu_format_populate_layout(
0084         struct msm_gem_address_space *aspace,
0085         struct drm_framebuffer *fb,
0086         struct dpu_hw_fmt_layout *fmtl);
0087 
0088 #endif /*_DPU_FORMATS_H */