blob: 5dcdfbb653ed664cf23e9b25de1b5d11633c434a [file] [log] [blame]
Narendra Muppalla1b0b3352015-09-29 10:16:51 -07001/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
Clarence Ipc475b082016-06-26 09:27:23 -040013#ifndef _SDE_FORMATS_H
14#define _SDE_FORMATS_H
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070015
16#include <drm/drm_fourcc.h>
17#include "sde_hw_mdss.h"
18
19/**
Lloyd Atkinsonfa2489c2016-05-25 15:16:03 -040020 * sde_get_sde_format_ext() - Returns sde format structure pointer.
Lloyd Atkinson9a673492016-07-05 11:41:57 -040021 * @format: DRM FourCC Code
22 * @modifiers: format modifier array from client, one per plane
23 * @modifiers_len: number of planes and array size for plane_modifiers
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040024 */
Lloyd Atkinson9a673492016-07-05 11:41:57 -040025const struct sde_format *sde_get_sde_format_ext(
26 const uint32_t format,
27 const uint64_t *modifiers,
28 const uint32_t modifiers_len);
29
30#define sde_get_sde_format(f) sde_get_sde_format_ext(f, NULL, 0)
31
32/**
Lloyd Atkinsonfa2489c2016-05-25 15:16:03 -040033 * sde_get_msm_format - get an sde_format by its msm_format base
Lloyd Atkinson9a673492016-07-05 11:41:57 -040034 * callback function registers with the msm_kms layer
35 * @kms: kms driver
36 * @format: DRM FourCC Code
37 * @modifiers: format modifier array from client, one per plane
38 * @modifiers_len: number of planes and array size for plane_modifiers
39 */
40const struct msm_format *sde_get_msm_format(
41 struct msm_kms *kms,
42 const uint32_t format,
43 const uint64_t *modifiers,
44 const uint32_t modifiers_len);
45
46/**
Lloyd Atkinsonfa2489c2016-05-25 15:16:03 -040047 * sde_populate_formats - populate the given array with fourcc codes supported
Clarence Ipea3d6262016-07-15 16:20:11 -040048 * @format_list: pointer to list of possible formats
49 * @pixel_formats: array to populate with fourcc codes
50 * @pixel_modifiers: array to populate with drm modifiers, can be NULL
51 * @pixel_formats_max: length of pixel formats array
Lloyd Atkinson9a673492016-07-05 11:41:57 -040052 * Return: number of elements populated
53 */
54uint32_t sde_populate_formats(
Clarence Ipea3d6262016-07-15 16:20:11 -040055 const struct sde_format_extended *format_list,
Lloyd Atkinson9a673492016-07-05 11:41:57 -040056 uint32_t *pixel_formats,
Clarence Ipea3d6262016-07-15 16:20:11 -040057 uint64_t *pixel_modifiers,
58 uint32_t pixel_formats_max);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070059
Lloyd Atkinsonfa2489c2016-05-25 15:16:03 -040060/**
61 * sde_format_check_modified_format - validate format and buffers for
62 * sde non-standard, i.e. modified format
63 * @kms: kms driver
64 * @msm_fmt: pointer to the msm_fmt base pointer of an sde_format
65 * @cmd: fb_cmd2 structure user request
66 * @bos: gem buffer object list
67 *
68 * Return: error code on failure, 0 on success
69 */
70int sde_format_check_modified_format(
71 const struct msm_kms *kms,
72 const struct msm_format *msm_fmt,
73 const struct drm_mode_fb_cmd2 *cmd,
74 struct drm_gem_object **bos);
75
76/**
77 * sde_format_populate_layout - populate the given format layout based on
78 * mmu, fb, and format found in the fb
79 * @mmu_id: mmu id handle
80 * @fb: framebuffer pointer
81 * @fmtl: format layout structure to populate
82 *
Clarence Ipb6eb2362016-09-08 16:18:13 -040083 * Return: error code on failure, -EAGAIN if success but the addresses
84 * are the same as before or 0 if new addresses were populated
Lloyd Atkinsonfa2489c2016-05-25 15:16:03 -040085 */
86int sde_format_populate_layout(
87 int mmu_id,
88 struct drm_framebuffer *fb,
89 struct sde_hw_fmt_layout *fmtl);
90
Alan Kwongbb27c092016-07-20 16:41:25 -040091/**
92 * sde_format_populate_layout_with_roi - populate the given format layout
93 * based on mmu, fb, roi, and format found in the fb
94 * @mmu_id: mmu id handle
95 * @fb: framebuffer pointer
96 * @roi: region of interest (optional)
97 * @fmtl: format layout structure to populate
98 *
99 * Return: error code on failure, 0 on success
100 */
101int sde_format_populate_layout_with_roi(
102 int mmu_id,
103 struct drm_framebuffer *fb,
104 struct sde_rect *roi,
105 struct sde_hw_fmt_layout *fmtl);
106
Clarence Ipc475b082016-06-26 09:27:23 -0400107#endif /*_SDE_FORMATS_H */