1ae4df11aSLaurent Pinchart /* 2ae4df11aSLaurent Pinchart * Copyright (c) 2016 Laurent Pinchart <laurent.pinchart@ideasonboard.com> 3ae4df11aSLaurent Pinchart * 4ae4df11aSLaurent Pinchart * Permission to use, copy, modify, distribute, and sell this software and its 5ae4df11aSLaurent Pinchart * documentation for any purpose is hereby granted without fee, provided that 6ae4df11aSLaurent Pinchart * the above copyright notice appear in all copies and that both that copyright 7ae4df11aSLaurent Pinchart * notice and this permission notice appear in supporting documentation, and 8ae4df11aSLaurent Pinchart * that the name of the copyright holders not be used in advertising or 9ae4df11aSLaurent Pinchart * publicity pertaining to distribution of the software without specific, 10ae4df11aSLaurent Pinchart * written prior permission. The copyright holders make no representations 11ae4df11aSLaurent Pinchart * about the suitability of this software for any purpose. It is provided "as 12ae4df11aSLaurent Pinchart * is" without express or implied warranty. 13ae4df11aSLaurent Pinchart * 14ae4df11aSLaurent Pinchart * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15ae4df11aSLaurent Pinchart * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16ae4df11aSLaurent Pinchart * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17ae4df11aSLaurent Pinchart * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18ae4df11aSLaurent Pinchart * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19ae4df11aSLaurent Pinchart * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 20ae4df11aSLaurent Pinchart * OF THIS SOFTWARE. 21ae4df11aSLaurent Pinchart */ 22ae4df11aSLaurent Pinchart #ifndef __DRM_FOURCC_H__ 23ae4df11aSLaurent Pinchart #define __DRM_FOURCC_H__ 24ae4df11aSLaurent Pinchart 25ae4df11aSLaurent Pinchart #include <linux/types.h> 26ae4df11aSLaurent Pinchart #include <uapi/drm/drm_fourcc.h> 27ae4df11aSLaurent Pinchart 286a0f9ebfSVille Syrjälä struct drm_device; 296a0f9ebfSVille Syrjälä struct drm_mode_fb_cmd2; 306a0f9ebfSVille Syrjälä 3184770cc2SLaurent Pinchart /** 3284770cc2SLaurent Pinchart * struct drm_format_info - information about a DRM format 3384770cc2SLaurent Pinchart * @format: 4CC format identifier (DRM_FORMAT_*) 3484770cc2SLaurent Pinchart * @depth: Color depth (number of bits per pixel excluding padding bits), 3584770cc2SLaurent Pinchart * valid for a subset of RGB formats only. This is a legacy field, do not 3684770cc2SLaurent Pinchart * use in new code and set to 0 for new formats. 3784770cc2SLaurent Pinchart * @num_planes: Number of color planes (1 to 3) 3884770cc2SLaurent Pinchart * @cpp: Number of bytes per pixel (per plane) 3984770cc2SLaurent Pinchart * @hsub: Horizontal chroma subsampling factor 4084770cc2SLaurent Pinchart * @vsub: Vertical chroma subsampling factor 414cc4e1b4SMaxime Ripard * @has_alpha: Does the format embeds an alpha component? 4284770cc2SLaurent Pinchart */ 4384770cc2SLaurent Pinchart struct drm_format_info { 4484770cc2SLaurent Pinchart u32 format; 4584770cc2SLaurent Pinchart u8 depth; 4684770cc2SLaurent Pinchart u8 num_planes; 4784770cc2SLaurent Pinchart u8 cpp[3]; 4884770cc2SLaurent Pinchart u8 hsub; 4984770cc2SLaurent Pinchart u8 vsub; 504cc4e1b4SMaxime Ripard bool has_alpha; 5184770cc2SLaurent Pinchart }; 5284770cc2SLaurent Pinchart 53b3c11ac2SEric Engestrom /** 54b3c11ac2SEric Engestrom * struct drm_format_name_buf - name of a DRM format 55b3c11ac2SEric Engestrom * @str: string buffer containing the format name 56b3c11ac2SEric Engestrom */ 57b3c11ac2SEric Engestrom struct drm_format_name_buf { 58b3c11ac2SEric Engestrom char str[32]; 59b3c11ac2SEric Engestrom }; 60b3c11ac2SEric Engestrom 61333d2da5SLaurent Pinchart const struct drm_format_info *__drm_format_info(u32 format); 6284770cc2SLaurent Pinchart const struct drm_format_info *drm_format_info(u32 format); 636a0f9ebfSVille Syrjälä const struct drm_format_info * 646a0f9ebfSVille Syrjälä drm_get_format_info(struct drm_device *dev, 656a0f9ebfSVille Syrjälä const struct drm_mode_fb_cmd2 *mode_cmd); 66ec5e3047SDaniel Vetter uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth); 67ae4df11aSLaurent Pinchart int drm_format_num_planes(uint32_t format); 68ae4df11aSLaurent Pinchart int drm_format_plane_cpp(uint32_t format, int plane); 69ae4df11aSLaurent Pinchart int drm_format_horz_chroma_subsampling(uint32_t format); 70ae4df11aSLaurent Pinchart int drm_format_vert_chroma_subsampling(uint32_t format); 71ae4df11aSLaurent Pinchart int drm_format_plane_width(int width, uint32_t format, int plane); 72ae4df11aSLaurent Pinchart int drm_format_plane_height(int height, uint32_t format, int plane); 73b3c11ac2SEric Engestrom const char *drm_get_format_name(uint32_t format, struct drm_format_name_buf *buf); 74ae4df11aSLaurent Pinchart 75ae4df11aSLaurent Pinchart #endif /* __DRM_FOURCC_H__ */ 76