Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1 | /* 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 Ip | c475b08 | 2016-06-26 09:27:23 -0400 | [diff] [blame] | 13 | #ifndef _SDE_FORMATS_H |
| 14 | #define _SDE_FORMATS_H |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 15 | |
| 16 | #include <drm/drm_fourcc.h> |
| 17 | #include "sde_hw_mdss.h" |
| 18 | |
| 19 | /** |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 20 | * sde_get_sde_format_ext() - Returns sde format structure pointer. |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 21 | * @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 Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 24 | */ |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 25 | const 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 Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 33 | * sde_get_msm_format - get an sde_format by its msm_format base |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 34 | * 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 | */ |
| 40 | const 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 Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 47 | * sde_populate_formats - populate the given array with fourcc codes supported |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 48 | * @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 Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 52 | * Return: number of elements populated |
| 53 | */ |
| 54 | uint32_t sde_populate_formats( |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 55 | const struct sde_format_extended *format_list, |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 56 | uint32_t *pixel_formats, |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 57 | uint64_t *pixel_modifiers, |
| 58 | uint32_t pixel_formats_max); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 59 | |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 60 | /** |
| 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 | */ |
| 70 | int 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 Ip | b6eb236 | 2016-09-08 16:18:13 -0400 | [diff] [blame] | 83 | * 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 Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 85 | */ |
| 86 | int sde_format_populate_layout( |
| 87 | int mmu_id, |
| 88 | struct drm_framebuffer *fb, |
| 89 | struct sde_hw_fmt_layout *fmtl); |
| 90 | |
Alan Kwong | bb27c09 | 2016-07-20 16:41:25 -0400 | [diff] [blame] | 91 | /** |
| 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 | */ |
| 101 | int 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 Ip | c475b08 | 2016-06-26 09:27:23 -0400 | [diff] [blame] | 107 | #endif /*_SDE_FORMATS_H */ |