fidl_data_zbi/
graphics.rs

1// Copyright 2022 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// DO NOT EDIT.
6// Generated from FIDL library `zbi` by zither, a Fuchsia platform tool.
7
8#![allow(unused_imports)]
9
10use zerocopy::IntoBytes;
11
12/// Gives a pixel format representation.
13///
14/// Bits [23:16] (i.e., the third byte) encode the number of bytes per pixel
15/// in the representation.
16#[repr(u32)]
17#[derive(Clone, Copy, Debug, Eq, IntoBytes, PartialEq)]
18pub enum PixelFormat {
19    None = 0x00000000,
20    Rgb565 = 0x00020001,
21    Rgb332 = 0x00010002,
22    Rgb2220 = 0x00010003,
23    Argb8888 = 0x00040004,
24    RgbX888 = 0x00040005,
25    Mono8 = 0x00010007,
26    Nv12 = 0x00010008,
27    I420 = 0x00010009,
28    Rgb888 = 0x00030009,
29    Abgr8888 = 0x0004000a,
30    Bgr888X = 0x0004000b,
31    Argb2101010 = 0x0004000c,
32    Abgr2101010 = 0x0004000d,
33}
34
35impl PixelFormat {
36    pub fn from_raw(raw: u32) -> Option<Self> {
37        match raw {
38            0x00000000 => Some(Self::None),
39
40            0x00020001 => Some(Self::Rgb565),
41
42            0x00010002 => Some(Self::Rgb332),
43
44            0x00010003 => Some(Self::Rgb2220),
45
46            0x00040004 => Some(Self::Argb8888),
47
48            0x00040005 => Some(Self::RgbX888),
49
50            0x00010007 => Some(Self::Mono8),
51
52            0x00010008 => Some(Self::Nv12),
53
54            0x00010009 => Some(Self::I420),
55
56            0x00030009 => Some(Self::Rgb888),
57
58            0x0004000a => Some(Self::Abgr8888),
59
60            0x0004000b => Some(Self::Bgr888X),
61
62            0x0004000c => Some(Self::Argb2101010),
63
64            0x0004000d => Some(Self::Abgr2101010),
65
66            _ => None,
67        }
68    }
69}
70
71/// ZBI_TYPE_FRAMEBUFFER payload.
72#[repr(C)]
73#[derive(Clone, Copy, Debug, Eq, IntoBytes, PartialEq)]
74pub struct Swfb {
75    /// Physical memory address.
76    pub base: u64,
77
78    /// Pixel layout and format.
79    pub width: u32,
80    pub height: u32,
81    pub stride: u32,
82    pub format: PixelFormat,
83}