1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef OHOS_HDI_LIGHT_V1_0_LIGHTTYPES_H
17#define OHOS_HDI_LIGHT_V1_0_LIGHTTYPES_H
18
19#include <cstdbool>
20#include <cstdint>
21#include <string>
22
23#ifndef HDI_BUFF_MAX_SIZE
24#define HDI_BUFF_MAX_SIZE (1024 * 200)
25#endif
26
27#ifndef HDI_CHECK_VALUE_RETURN
28#define HDI_CHECK_VALUE_RETURN(lv, compare, rv, ret) do { \
29    if ((lv) compare (rv)) { \
30        return ret; \
31    } \
32} while (false)
33#endif
34
35#ifndef HDI_CHECK_VALUE_RET_GOTO
36#define HDI_CHECK_VALUE_RET_GOTO(lv, compare, rv, ret, value, table) do { \
37    if ((lv) compare (rv)) { \
38        ret = value; \
39        goto table; \
40    } \
41} while (false)
42#endif
43
44namespace OHOS {
45class MessageParcel;
46}
47
48namespace OHOS {
49namespace HDI {
50namespace Light {
51namespace V1_0 {
52
53using namespace OHOS;
54
55enum HdfLightId : int32_t {
56    HDF_LIGHT_ID_BATTERY = 1,
57    HDF_LIGHT_ID_NOTIFICATIONS = 2,
58    HDF_LIGHT_ID_ATTENTION = 3,
59    HDF_LIGHT_ID_BUTT = 4,
60};
61
62enum HdfLightType : int32_t {
63    HDF_LIGHT_TYPE_SINGLE_COLOR = 1,
64    HDF_LIGHT_TYPE_RGB_COLOR = 2,
65    HDF_LIGHT_TYPE_WRGB_COLOR = 3,
66};
67
68struct HdfLightInfo {
69    std::string lightName;
70    int32_t lightId;
71    int32_t lightNumber;
72    int32_t lightType;
73};
74
75enum HdfLightFlashMode : int32_t {
76    HDF_LIGHT_FLASH_NONE = 0,
77    HDF_LIGHT_FLASH_BLINK = 1,
78    HDF_LIGHT_FLASH_GRADIENT = 2,
79    HDF_LIGHT_FLASH_BUTT = 3,
80};
81
82struct HdfLightFlashEffect {
83    int32_t flashMode;
84    int32_t onTime;
85    int32_t offTime;
86} __attribute__ ((aligned(8)));
87
88struct RGBColor {
89    uint8_t r;
90    uint8_t g;
91    uint8_t b;
92    uint8_t reserved;
93} __attribute__ ((aligned(8)));
94
95struct WRGBColor {
96    uint8_t w;
97    uint8_t r;
98    uint8_t g;
99    uint8_t b;
100} __attribute__ ((aligned(8)));
101
102union ColorValue {
103    int32_t singleColor;
104    OHOS::HDI::Light::V1_0::WRGBColor wrgbColor;
105    OHOS::HDI::Light::V1_0::RGBColor rgbColor;
106}  __attribute__ ((aligned(8)));
107
108struct HdfLightColor {
109    OHOS::HDI::Light::V1_0::ColorValue colorValue;
110} __attribute__ ((aligned(8)));
111
112struct HdfLightEffect {
113    OHOS::HDI::Light::V1_0::HdfLightColor lightColor;
114    OHOS::HDI::Light::V1_0::HdfLightFlashEffect flashEffect;
115} __attribute__ ((aligned(8)));
116
117bool HdfLightInfoBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Light::V1_0::HdfLightInfo& dataBlock);
118
119bool HdfLightInfoBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Light::V1_0::HdfLightInfo& dataBlock);
120
121bool HdfLightFlashEffectBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Light::V1_0::HdfLightFlashEffect& dataBlock);
122
123bool HdfLightFlashEffectBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Light::V1_0::HdfLightFlashEffect& dataBlock);
124
125bool RGBColorBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Light::V1_0::RGBColor& dataBlock);
126
127bool RGBColorBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Light::V1_0::RGBColor& dataBlock);
128
129bool WRGBColorBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Light::V1_0::WRGBColor& dataBlock);
130
131bool WRGBColorBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Light::V1_0::WRGBColor& dataBlock);
132
133bool HdfLightColorBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Light::V1_0::HdfLightColor& dataBlock);
134
135bool HdfLightColorBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Light::V1_0::HdfLightColor& dataBlock);
136
137bool HdfLightEffectBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Light::V1_0::HdfLightEffect& dataBlock);
138
139bool HdfLightEffectBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Light::V1_0::HdfLightEffect& dataBlock);
140
141} // V1_0
142} // Light
143} // HDI
144} // OHOS
145
146#endif // OHOS_HDI_LIGHT_V1_0_LIGHTTYPES_H
147
148