| 1 |
// SPDX-License-Identifier: (LGPL-2.1-only OR BSD-3-Clause) |
| 2 |
/* |
| 3 |
* cec-htng-funcs - HDMI CEC wrapper functions for Hospitality Profile |
| 4 |
* |
| 5 |
* Copyright 2016-2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef _CEC_HTNG_FUNCS_H |
| 9 |
#define _CEC_HTNG_FUNCS_H |
| 10 |
|
| 11 |
#include "cec-htng.h" |
| 12 |
|
| 13 |
static inline void cec_msg_htng_init(struct cec_msg *msg, __u8 op) |
| 14 |
{ |
| 15 |
msg->len = 6; |
| 16 |
msg->msg[1] = CEC_MSG_VENDOR_COMMAND_WITH_ID; |
| 17 |
msg->msg[2] = VENDOR_ID_HTNG >> 16; |
| 18 |
msg->msg[3] = (VENDOR_ID_HTNG >> 8) & 0xff; |
| 19 |
msg->msg[4] = VENDOR_ID_HTNG & 0xff; |
| 20 |
msg->msg[5] = op; |
| 21 |
} |
| 22 |
|
| 23 |
/* HTNG Feature */ |
| 24 |
static inline void cec_msg_htng_tuner_1part_chan(struct cec_msg *msg, |
| 25 |
__u8 htng_tuner_type, |
| 26 |
__u16 chan) |
| 27 |
{ |
| 28 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_TUNER_1PART_CHAN); |
| 29 |
msg->msg[msg->len++] = htng_tuner_type; |
| 30 |
msg->msg[msg->len++] = chan >> 8; |
| 31 |
msg->msg[msg->len++] = chan & 0xff; |
| 32 |
} |
| 33 |
|
| 34 |
static inline void cec_ops_htng_tuner_1part_chan(const struct cec_msg *msg, |
| 35 |
__u8 *htng_tuner_type, |
| 36 |
__u16 *chan) |
| 37 |
{ |
| 38 |
*htng_tuner_type = msg->msg[6]; |
| 39 |
*chan = (msg->msg[7] << 8) | msg->msg[8]; |
| 40 |
} |
| 41 |
|
| 42 |
static inline void cec_msg_htng_tuner_2part_chan(struct cec_msg *msg, |
| 43 |
__u8 htng_tuner_type, |
| 44 |
__u8 major_chan, |
| 45 |
__u16 minor_chan) |
| 46 |
{ |
| 47 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_TUNER_2PART_CHAN); |
| 48 |
msg->msg[msg->len++] = htng_tuner_type; |
| 49 |
msg->msg[msg->len++] = major_chan; |
| 50 |
msg->msg[msg->len++] = minor_chan >> 8; |
| 51 |
msg->msg[msg->len++] = minor_chan & 0xff; |
| 52 |
} |
| 53 |
|
| 54 |
static inline void cec_ops_htng_tuner_2part_chan(const struct cec_msg *msg, |
| 55 |
__u8 *htng_tuner_type, |
| 56 |
__u8 *major_chan, |
| 57 |
__u16 *minor_chan) |
| 58 |
{ |
| 59 |
*htng_tuner_type = msg->msg[6]; |
| 60 |
*major_chan = msg->msg[7]; |
| 61 |
*minor_chan = (msg->msg[8] << 8) | msg->msg[9]; |
| 62 |
} |
| 63 |
|
| 64 |
static inline void cec_msg_htng_input_sel_av(struct cec_msg *msg, |
| 65 |
__u16 input) |
| 66 |
{ |
| 67 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_INPUT_SEL_AV); |
| 68 |
msg->msg[msg->len++] = input >> 8; |
| 69 |
msg->msg[msg->len++] = input & 0xff; |
| 70 |
} |
| 71 |
|
| 72 |
static inline void cec_ops_htng_input_sel_av(const struct cec_msg *msg, |
| 73 |
__u16 *input) |
| 74 |
{ |
| 75 |
*input = (msg->msg[6] << 8) | msg->msg[7]; |
| 76 |
} |
| 77 |
|
| 78 |
static inline void cec_msg_htng_input_sel_pc(struct cec_msg *msg, |
| 79 |
__u16 input) |
| 80 |
{ |
| 81 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_INPUT_SEL_PC); |
| 82 |
msg->msg[msg->len++] = input >> 8; |
| 83 |
msg->msg[msg->len++] = input & 0xff; |
| 84 |
} |
| 85 |
|
| 86 |
static inline void cec_ops_htng_input_sel_pc(const struct cec_msg *msg, |
| 87 |
__u16 *input) |
| 88 |
{ |
| 89 |
*input = (msg->msg[6] << 8) | msg->msg[7]; |
| 90 |
} |
| 91 |
|
| 92 |
static inline void cec_msg_htng_input_sel_hdmi(struct cec_msg *msg, |
| 93 |
__u16 input) |
| 94 |
{ |
| 95 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_INPUT_SEL_HDMI); |
| 96 |
msg->msg[msg->len++] = input >> 8; |
| 97 |
msg->msg[msg->len++] = input & 0xff; |
| 98 |
} |
| 99 |
|
| 100 |
static inline void cec_ops_htng_input_sel_hdmi(const struct cec_msg *msg, |
| 101 |
__u16 *input) |
| 102 |
{ |
| 103 |
*input = (msg->msg[6] << 8) | msg->msg[7]; |
| 104 |
} |
| 105 |
|
| 106 |
static inline void cec_msg_htng_input_sel_component(struct cec_msg *msg, |
| 107 |
__u16 input) |
| 108 |
{ |
| 109 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_INPUT_SEL_COMPONENT); |
| 110 |
msg->msg[msg->len++] = input >> 8; |
| 111 |
msg->msg[msg->len++] = input & 0xff; |
| 112 |
} |
| 113 |
|
| 114 |
static inline void cec_ops_htng_input_sel_component(const struct cec_msg *msg, |
| 115 |
__u16 *input) |
| 116 |
{ |
| 117 |
*input = (msg->msg[6] << 8) | msg->msg[7]; |
| 118 |
} |
| 119 |
|
| 120 |
static inline void cec_msg_htng_input_sel_dvi(struct cec_msg *msg, |
| 121 |
__u16 input) |
| 122 |
{ |
| 123 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_INPUT_SEL_DVI); |
| 124 |
msg->msg[msg->len++] = input >> 8; |
| 125 |
msg->msg[msg->len++] = input & 0xff; |
| 126 |
} |
| 127 |
|
| 128 |
static inline void cec_ops_htng_input_sel_dvi(const struct cec_msg *msg, |
| 129 |
__u16 *input) |
| 130 |
{ |
| 131 |
*input = (msg->msg[6] << 8) | msg->msg[7]; |
| 132 |
} |
| 133 |
|
| 134 |
static inline void cec_msg_htng_input_sel_dp(struct cec_msg *msg, |
| 135 |
__u16 input) |
| 136 |
{ |
| 137 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_INPUT_SEL_DP); |
| 138 |
msg->msg[msg->len++] = input >> 8; |
| 139 |
msg->msg[msg->len++] = input & 0xff; |
| 140 |
} |
| 141 |
|
| 142 |
static inline void cec_ops_htng_input_sel_dp(const struct cec_msg *msg, |
| 143 |
__u16 *input) |
| 144 |
{ |
| 145 |
*input = (msg->msg[6] << 8) | msg->msg[7]; |
| 146 |
} |
| 147 |
|
| 148 |
static inline void cec_msg_htng_input_sel_usb(struct cec_msg *msg, |
| 149 |
__u16 input) |
| 150 |
{ |
| 151 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_INPUT_SEL_USB); |
| 152 |
msg->msg[msg->len++] = input >> 8; |
| 153 |
msg->msg[msg->len++] = input & 0xff; |
| 154 |
} |
| 155 |
|
| 156 |
static inline void cec_ops_htng_input_sel_usb(const struct cec_msg *msg, |
| 157 |
__u16 *input) |
| 158 |
{ |
| 159 |
*input = (msg->msg[6] << 8) | msg->msg[7]; |
| 160 |
} |
| 161 |
|
| 162 |
static inline void cec_msg_htng_set_def_pwr_on_input_src(struct cec_msg *msg, |
| 163 |
__u8 htng_input_src, |
| 164 |
__u8 htng_tuner_type, |
| 165 |
__u8 major, |
| 166 |
__u16 input) |
| 167 |
{ |
| 168 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_DEF_PWR_ON_INPUT_SRC); |
| 169 |
msg->msg[msg->len++] = htng_input_src; |
| 170 |
msg->msg[msg->len++] = htng_tuner_type; |
| 171 |
if (htng_input_src == CEC_OP_HTNG_INPUT_SRC_TUNER_2PART) |
| 172 |
msg->msg[msg->len++] = major; |
| 173 |
msg->msg[msg->len++] = input >> 8; |
| 174 |
msg->msg[msg->len++] = input & 0xff; |
| 175 |
if (htng_input_src != CEC_OP_HTNG_INPUT_SRC_TUNER_2PART) |
| 176 |
msg->msg[msg->len++] = 0; |
| 177 |
} |
| 178 |
|
| 179 |
static inline void cec_ops_htng_set_def_pwr_on_input_src(const struct cec_msg *msg, |
| 180 |
__u8 *htng_input_src, |
| 181 |
__u8 *htng_tuner_type, |
| 182 |
__u8 *major, |
| 183 |
__u16 *input) |
| 184 |
{ |
| 185 |
*htng_input_src = msg->msg[6]; |
| 186 |
*htng_tuner_type = msg->msg[7]; |
| 187 |
if (*htng_input_src == CEC_OP_HTNG_INPUT_SRC_TUNER_2PART) { |
| 188 |
*major = msg->msg[8]; |
| 189 |
*input = (msg->msg[9] << 8) | msg->msg[10]; |
| 190 |
} else { |
| 191 |
*major = 0; |
| 192 |
*input = (msg->msg[8] << 8) | msg->msg[9]; |
| 193 |
} |
| 194 |
} |
| 195 |
|
| 196 |
static inline void cec_msg_htng_set_tv_speakers(struct cec_msg *msg, |
| 197 |
__u8 on) |
| 198 |
{ |
| 199 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_TV_SPEAKERS); |
| 200 |
msg->msg[msg->len++] = on; |
| 201 |
} |
| 202 |
|
| 203 |
static inline void cec_ops_htng_set_tv_speakers(const struct cec_msg *msg, |
| 204 |
__u8 *on) |
| 205 |
{ |
| 206 |
*on = msg->msg[6]; |
| 207 |
} |
| 208 |
|
| 209 |
static inline void cec_msg_htng_set_dig_audio(struct cec_msg *msg, |
| 210 |
__u8 on) |
| 211 |
{ |
| 212 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_DIG_AUDIO); |
| 213 |
msg->msg[msg->len++] = on; |
| 214 |
} |
| 215 |
|
| 216 |
static inline void cec_ops_htng_set_dig_audio(const struct cec_msg *msg, |
| 217 |
__u8 *on) |
| 218 |
{ |
| 219 |
*on = msg->msg[6]; |
| 220 |
} |
| 221 |
|
| 222 |
static inline void cec_msg_htng_set_ana_audio(struct cec_msg *msg, |
| 223 |
__u8 on) |
| 224 |
{ |
| 225 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_ANA_AUDIO); |
| 226 |
msg->msg[msg->len++] = on; |
| 227 |
} |
| 228 |
|
| 229 |
static inline void cec_ops_htng_set_ana_audio(const struct cec_msg *msg, |
| 230 |
__u8 *on) |
| 231 |
{ |
| 232 |
*on = msg->msg[6]; |
| 233 |
} |
| 234 |
|
| 235 |
static inline void cec_msg_htng_set_def_pwr_on_vol(struct cec_msg *msg, |
| 236 |
__u8 vol) |
| 237 |
{ |
| 238 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_DEF_PWR_ON_VOL); |
| 239 |
msg->msg[msg->len++] = vol; |
| 240 |
} |
| 241 |
|
| 242 |
static inline void cec_ops_htng_set_def_pwr_on_vol(const struct cec_msg *msg, |
| 243 |
__u8 *vol) |
| 244 |
{ |
| 245 |
*vol = msg->msg[6]; |
| 246 |
} |
| 247 |
|
| 248 |
static inline void cec_msg_htng_set_max_vol(struct cec_msg *msg, |
| 249 |
__u8 vol) |
| 250 |
{ |
| 251 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_MAX_VOL); |
| 252 |
msg->msg[msg->len++] = vol; |
| 253 |
} |
| 254 |
|
| 255 |
static inline void cec_ops_htng_set_max_vol(const struct cec_msg *msg, |
| 256 |
__u8 *vol) |
| 257 |
{ |
| 258 |
*vol = msg->msg[6]; |
| 259 |
} |
| 260 |
|
| 261 |
static inline void cec_msg_htng_set_min_vol(struct cec_msg *msg, |
| 262 |
__u8 vol) |
| 263 |
{ |
| 264 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_MIN_VOL); |
| 265 |
msg->msg[msg->len++] = vol; |
| 266 |
} |
| 267 |
|
| 268 |
static inline void cec_ops_htng_set_min_vol(const struct cec_msg *msg, |
| 269 |
__u8 *vol) |
| 270 |
{ |
| 271 |
*vol = msg->msg[6]; |
| 272 |
} |
| 273 |
|
| 274 |
static inline void cec_msg_htng_set_blue_screen(struct cec_msg *msg, |
| 275 |
__u8 blue) |
| 276 |
{ |
| 277 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_BLUE_SCREEN); |
| 278 |
msg->msg[msg->len++] = blue; |
| 279 |
} |
| 280 |
|
| 281 |
static inline void cec_ops_htng_set_blue_screen(const struct cec_msg *msg, |
| 282 |
__u8 *blue) |
| 283 |
{ |
| 284 |
*blue = msg->msg[6]; |
| 285 |
} |
| 286 |
|
| 287 |
static inline void cec_msg_htng_set_brightness(struct cec_msg *msg, |
| 288 |
__u8 brightness) |
| 289 |
{ |
| 290 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_BRIGHTNESS); |
| 291 |
msg->msg[msg->len++] = brightness; |
| 292 |
} |
| 293 |
|
| 294 |
static inline void cec_ops_htng_set_brightness(const struct cec_msg *msg, |
| 295 |
__u8 *brightness) |
| 296 |
{ |
| 297 |
*brightness = msg->msg[6]; |
| 298 |
} |
| 299 |
|
| 300 |
static inline void cec_msg_htng_set_color(struct cec_msg *msg, |
| 301 |
__u8 color) |
| 302 |
{ |
| 303 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_COLOR); |
| 304 |
msg->msg[msg->len++] = color; |
| 305 |
} |
| 306 |
|
| 307 |
static inline void cec_ops_htng_set_color(const struct cec_msg *msg, |
| 308 |
__u8 *color) |
| 309 |
{ |
| 310 |
*color = msg->msg[6]; |
| 311 |
} |
| 312 |
|
| 313 |
static inline void cec_msg_htng_set_contrast(struct cec_msg *msg, |
| 314 |
__u8 contrast) |
| 315 |
{ |
| 316 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_CONTRAST); |
| 317 |
msg->msg[msg->len++] = contrast; |
| 318 |
} |
| 319 |
|
| 320 |
static inline void cec_ops_htng_set_contrast(const struct cec_msg *msg, |
| 321 |
__u8 *contrast) |
| 322 |
{ |
| 323 |
*contrast = msg->msg[6]; |
| 324 |
} |
| 325 |
|
| 326 |
static inline void cec_msg_htng_set_sharpness(struct cec_msg *msg, |
| 327 |
__u8 sharpness) |
| 328 |
{ |
| 329 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_SHARPNESS); |
| 330 |
msg->msg[msg->len++] = sharpness; |
| 331 |
} |
| 332 |
|
| 333 |
static inline void cec_ops_htng_set_sharpness(const struct cec_msg *msg, |
| 334 |
__u8 *sharpness) |
| 335 |
{ |
| 336 |
*sharpness = msg->msg[6]; |
| 337 |
} |
| 338 |
|
| 339 |
static inline void cec_msg_htng_set_hue(struct cec_msg *msg, |
| 340 |
__u8 hue) |
| 341 |
{ |
| 342 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_HUE); |
| 343 |
msg->msg[msg->len++] = hue; |
| 344 |
} |
| 345 |
|
| 346 |
static inline void cec_ops_htng_set_hue(const struct cec_msg *msg, |
| 347 |
__u8 *hue) |
| 348 |
{ |
| 349 |
*hue = msg->msg[6]; |
| 350 |
} |
| 351 |
|
| 352 |
static inline void cec_msg_htng_set_led_backlight(struct cec_msg *msg, |
| 353 |
__u8 led_backlight) |
| 354 |
{ |
| 355 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_LED_BACKLIGHT); |
| 356 |
msg->msg[msg->len++] = led_backlight; |
| 357 |
} |
| 358 |
|
| 359 |
static inline void cec_ops_htng_set_led_backlight(const struct cec_msg *msg, |
| 360 |
__u8 *led_backlight) |
| 361 |
{ |
| 362 |
*led_backlight = msg->msg[6]; |
| 363 |
} |
| 364 |
|
| 365 |
static inline void cec_msg_htng_set_tv_osd_control(struct cec_msg *msg, |
| 366 |
__u8 on) |
| 367 |
{ |
| 368 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_TV_OSD_CONTROL); |
| 369 |
msg->msg[msg->len++] = on; |
| 370 |
} |
| 371 |
|
| 372 |
static inline void cec_ops_htng_set_tv_osd_control(const struct cec_msg *msg, |
| 373 |
__u8 *on) |
| 374 |
{ |
| 375 |
*on = msg->msg[6]; |
| 376 |
} |
| 377 |
|
| 378 |
static inline void cec_msg_htng_set_audio_only_display(struct cec_msg *msg, |
| 379 |
__u8 on) |
| 380 |
{ |
| 381 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_AUDIO_ONLY_DISPLAY); |
| 382 |
msg->msg[msg->len++] = on; |
| 383 |
} |
| 384 |
|
| 385 |
static inline void cec_ops_htng_set_audio_only_display(const struct cec_msg *msg, |
| 386 |
__u8 *on) |
| 387 |
{ |
| 388 |
*on = msg->msg[6]; |
| 389 |
} |
| 390 |
|
| 391 |
static inline void cec_msg_htng_set_date(struct cec_msg *msg, |
| 392 |
const char *date) |
| 393 |
{ |
| 394 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_DATE); |
| 395 |
memcpy(msg->msg + msg->len, date, 8); |
| 396 |
msg->len += 8; |
| 397 |
} |
| 398 |
|
| 399 |
static inline void cec_ops_htng_set_date(const struct cec_msg *msg, |
| 400 |
char *date) |
| 401 |
{ |
| 402 |
memcpy(date, msg->msg + 6, 8); |
| 403 |
date[8] = '\0'; |
| 404 |
} |
| 405 |
|
| 406 |
static inline void cec_msg_htng_set_date_format(struct cec_msg *msg, |
| 407 |
__u8 ddmm) |
| 408 |
{ |
| 409 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_DATE_FORMAT); |
| 410 |
msg->msg[msg->len++] = ddmm; |
| 411 |
} |
| 412 |
|
| 413 |
static inline void cec_ops_htng_set_date_format(const struct cec_msg *msg, |
| 414 |
__u8 *ddmm) |
| 415 |
{ |
| 416 |
*ddmm = msg->msg[6]; |
| 417 |
} |
| 418 |
|
| 419 |
static inline void cec_msg_htng_set_time(struct cec_msg *msg, |
| 420 |
const char *time) |
| 421 |
{ |
| 422 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_TIME); |
| 423 |
memcpy(msg->msg + msg->len, time, 6); |
| 424 |
msg->len += 6; |
| 425 |
} |
| 426 |
|
| 427 |
static inline void cec_ops_htng_set_time(const struct cec_msg *msg, |
| 428 |
char *time) |
| 429 |
{ |
| 430 |
memcpy(time, msg->msg + 6, 6); |
| 431 |
time[6] = '\0'; |
| 432 |
} |
| 433 |
|
| 434 |
static inline void cec_msg_htng_set_clk_brightness_standby(struct cec_msg *msg, |
| 435 |
__u8 brightness) |
| 436 |
{ |
| 437 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_CLK_BRIGHTNESS_STANDBY); |
| 438 |
msg->msg[msg->len++] = brightness; |
| 439 |
} |
| 440 |
|
| 441 |
static inline void cec_ops_htng_set_clk_brightness_standby(const struct cec_msg *msg, |
| 442 |
__u8 *brightness) |
| 443 |
{ |
| 444 |
*brightness = msg->msg[6]; |
| 445 |
} |
| 446 |
|
| 447 |
static inline void cec_msg_htng_set_clk_brightness_on(struct cec_msg *msg, |
| 448 |
__u8 brightness) |
| 449 |
{ |
| 450 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_CLK_BRIGHTNESS_ON); |
| 451 |
msg->msg[msg->len++] = brightness; |
| 452 |
} |
| 453 |
|
| 454 |
static inline void cec_ops_htng_set_clk_brightness_on(const struct cec_msg *msg, |
| 455 |
__u8 *brightness) |
| 456 |
{ |
| 457 |
*brightness = msg->msg[6]; |
| 458 |
} |
| 459 |
|
| 460 |
static inline void cec_msg_htng_led_control(struct cec_msg *msg, |
| 461 |
__u8 htng_led_control) |
| 462 |
{ |
| 463 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_LED_CONTROL); |
| 464 |
msg->msg[msg->len++] = htng_led_control; |
| 465 |
} |
| 466 |
|
| 467 |
static inline void cec_ops_htng_led_control(const struct cec_msg *msg, |
| 468 |
__u8 *htng_led_control) |
| 469 |
{ |
| 470 |
*htng_led_control = msg->msg[6]; |
| 471 |
} |
| 472 |
|
| 473 |
static inline void cec_msg_htng_lock_tv_pwr_button(struct cec_msg *msg, |
| 474 |
__u8 on) |
| 475 |
{ |
| 476 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_LOCK_TV_PWR_BUTTON); |
| 477 |
msg->msg[msg->len++] = on; |
| 478 |
} |
| 479 |
|
| 480 |
static inline void cec_ops_htng_lock_tv_pwr_button(const struct cec_msg *msg, |
| 481 |
__u8 *on) |
| 482 |
{ |
| 483 |
*on = msg->msg[6]; |
| 484 |
} |
| 485 |
|
| 486 |
static inline void cec_msg_htng_lock_tv_vol_buttons(struct cec_msg *msg, |
| 487 |
__u8 on) |
| 488 |
{ |
| 489 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_LOCK_TV_VOL_BUTTONS); |
| 490 |
msg->msg[msg->len++] = on; |
| 491 |
} |
| 492 |
|
| 493 |
static inline void cec_ops_htng_lock_tv_vol_buttons(const struct cec_msg *msg, |
| 494 |
__u8 *on) |
| 495 |
{ |
| 496 |
*on = msg->msg[6]; |
| 497 |
} |
| 498 |
|
| 499 |
static inline void cec_msg_htng_lock_tv_chan_buttons(struct cec_msg *msg, |
| 500 |
__u8 on) |
| 501 |
{ |
| 502 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_LOCK_TV_CHAN_BUTTONS); |
| 503 |
msg->msg[msg->len++] = on; |
| 504 |
} |
| 505 |
|
| 506 |
static inline void cec_ops_htng_lock_tv_chan_buttons(const struct cec_msg *msg, |
| 507 |
__u8 *on) |
| 508 |
{ |
| 509 |
*on = msg->msg[6]; |
| 510 |
} |
| 511 |
|
| 512 |
static inline void cec_msg_htng_lock_tv_input_buttons(struct cec_msg *msg, |
| 513 |
__u8 on) |
| 514 |
{ |
| 515 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_LOCK_TV_INPUT_BUTTONS); |
| 516 |
msg->msg[msg->len++] = on; |
| 517 |
} |
| 518 |
|
| 519 |
static inline void cec_ops_htng_lock_tv_input_buttons(const struct cec_msg *msg, |
| 520 |
__u8 *on) |
| 521 |
{ |
| 522 |
*on = msg->msg[6]; |
| 523 |
} |
| 524 |
|
| 525 |
static inline void cec_msg_htng_lock_tv_other_buttons(struct cec_msg *msg, |
| 526 |
__u8 on) |
| 527 |
{ |
| 528 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_LOCK_TV_OTHER_BUTTONS); |
| 529 |
msg->msg[msg->len++] = on; |
| 530 |
} |
| 531 |
|
| 532 |
static inline void cec_ops_htng_lock_tv_other_buttons(const struct cec_msg *msg, |
| 533 |
__u8 *on) |
| 534 |
{ |
| 535 |
*on = msg->msg[6]; |
| 536 |
} |
| 537 |
|
| 538 |
static inline void cec_msg_htng_lock_everything(struct cec_msg *msg, |
| 539 |
__u8 on) |
| 540 |
{ |
| 541 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_LOCK_EVERYTHING); |
| 542 |
msg->msg[msg->len++] = on; |
| 543 |
} |
| 544 |
|
| 545 |
static inline void cec_ops_htng_lock_everything(const struct cec_msg *msg, |
| 546 |
__u8 *on) |
| 547 |
{ |
| 548 |
*on = msg->msg[6]; |
| 549 |
} |
| 550 |
|
| 551 |
static inline void cec_msg_htng_lock_everything_but_pwr(struct cec_msg *msg, |
| 552 |
__u8 on) |
| 553 |
{ |
| 554 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_LOCK_EVERYTHING_BUT_PWR); |
| 555 |
msg->msg[msg->len++] = on; |
| 556 |
} |
| 557 |
|
| 558 |
static inline void cec_ops_htng_lock_everything_but_pwr(const struct cec_msg *msg, |
| 559 |
__u8 *on) |
| 560 |
{ |
| 561 |
*on = msg->msg[6]; |
| 562 |
} |
| 563 |
|
| 564 |
static inline void cec_msg_htng_hotel_mode(struct cec_msg *msg, |
| 565 |
__u8 on, __u8 options) |
| 566 |
{ |
| 567 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_HOTEL_MODE); |
| 568 |
msg->msg[msg->len++] = on; |
| 569 |
msg->msg[msg->len++] = options; |
| 570 |
} |
| 571 |
|
| 572 |
static inline void cec_ops_htng_hotel_mode(const struct cec_msg *msg, |
| 573 |
__u8 *on, __u8 *options) |
| 574 |
{ |
| 575 |
*on = msg->msg[6]; |
| 576 |
*options = msg->msg[7]; |
| 577 |
} |
| 578 |
|
| 579 |
static inline void cec_msg_htng_set_pwr_saving_profile(struct cec_msg *msg, |
| 580 |
__u8 on, __u8 val) |
| 581 |
{ |
| 582 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_PWR_SAVING_PROFILE); |
| 583 |
msg->msg[msg->len++] = on; |
| 584 |
msg->msg[msg->len++] = val; |
| 585 |
} |
| 586 |
|
| 587 |
static inline void cec_ops_htng_set_pwr_saving_profile(const struct cec_msg *msg, |
| 588 |
__u8 *on, __u8 *val) |
| 589 |
{ |
| 590 |
*on = msg->msg[6]; |
| 591 |
*val = msg->msg[7]; |
| 592 |
} |
| 593 |
|
| 594 |
static inline void cec_msg_htng_set_sleep_timer(struct cec_msg *msg, |
| 595 |
__u8 minutes) |
| 596 |
{ |
| 597 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_SLEEP_TIMER); |
| 598 |
msg->msg[msg->len++] = minutes; |
| 599 |
} |
| 600 |
|
| 601 |
static inline void cec_ops_htng_set_sleep_timer(const struct cec_msg *msg, |
| 602 |
__u8 *minutes) |
| 603 |
{ |
| 604 |
*minutes = msg->msg[6]; |
| 605 |
} |
| 606 |
|
| 607 |
static inline void cec_msg_htng_set_wakeup_time(struct cec_msg *msg, |
| 608 |
const char *time) |
| 609 |
{ |
| 610 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_WAKEUP_TIME); |
| 611 |
memcpy(msg->msg + 6, time, 4); |
| 612 |
msg->len += 4; |
| 613 |
} |
| 614 |
|
| 615 |
static inline void cec_ops_htng_set_wakeup_time(const struct cec_msg *msg, |
| 616 |
char *time) |
| 617 |
{ |
| 618 |
memcpy(time, msg->msg + 6, 4); |
| 619 |
time[4] = '\0'; |
| 620 |
} |
| 621 |
|
| 622 |
static inline void cec_msg_htng_set_auto_off_time(struct cec_msg *msg, |
| 623 |
const char *time) |
| 624 |
{ |
| 625 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_AUTO_OFF_TIME); |
| 626 |
memcpy(msg->msg + 6, time, 4); |
| 627 |
msg->len += 4; |
| 628 |
} |
| 629 |
|
| 630 |
static inline void cec_ops_htng_set_auto_off_time(const struct cec_msg *msg, |
| 631 |
char *time) |
| 632 |
{ |
| 633 |
memcpy(time, msg->msg + 6, 4); |
| 634 |
time[4] = '\0'; |
| 635 |
} |
| 636 |
|
| 637 |
static inline void cec_msg_htng_set_wakeup_src(struct cec_msg *msg, |
| 638 |
__u8 htng_input_src, |
| 639 |
__u8 htng_tuner_type, |
| 640 |
__u8 major, |
| 641 |
__u16 input) |
| 642 |
{ |
| 643 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_WAKEUP_SRC); |
| 644 |
msg->msg[msg->len++] = htng_input_src; |
| 645 |
msg->msg[msg->len++] = htng_tuner_type; |
| 646 |
if (htng_input_src == CEC_OP_HTNG_INPUT_SRC_TUNER_2PART) |
| 647 |
msg->msg[msg->len++] = major; |
| 648 |
msg->msg[msg->len++] = input >> 8; |
| 649 |
msg->msg[msg->len++] = input & 0xff; |
| 650 |
if (htng_input_src != CEC_OP_HTNG_INPUT_SRC_TUNER_2PART) |
| 651 |
msg->msg[msg->len++] = 0; |
| 652 |
} |
| 653 |
|
| 654 |
static inline void cec_ops_htng_set_wakeup_src(const struct cec_msg *msg, |
| 655 |
__u8 *htng_input_src, |
| 656 |
__u8 *htng_tuner_type, |
| 657 |
__u8 *major, |
| 658 |
__u16 *input) |
| 659 |
{ |
| 660 |
*htng_input_src = msg->msg[6]; |
| 661 |
*htng_tuner_type = msg->msg[7]; |
| 662 |
if (*htng_input_src == CEC_OP_HTNG_INPUT_SRC_TUNER_2PART) { |
| 663 |
*major = msg->msg[8]; |
| 664 |
*input = (msg->msg[9] << 8) | msg->msg[10]; |
| 665 |
} else { |
| 666 |
*major = 0; |
| 667 |
*input = (msg->msg[8] << 8) | msg->msg[9]; |
| 668 |
} |
| 669 |
} |
| 670 |
|
| 671 |
static inline void cec_msg_htng_set_init_wakeup_vol(struct cec_msg *msg, |
| 672 |
__u8 vol, |
| 673 |
__u8 minutes) |
| 674 |
{ |
| 675 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_SET_INIT_WAKEUP_VOL); |
| 676 |
msg->msg[msg->len++] = vol; |
| 677 |
msg->msg[msg->len++] = minutes; |
| 678 |
} |
| 679 |
|
| 680 |
static inline void cec_ops_htng_set_init_wakeup_vol(const struct cec_msg *msg, |
| 681 |
__u8 *vol, |
| 682 |
__u8 *minutes) |
| 683 |
{ |
| 684 |
*vol = msg->msg[6]; |
| 685 |
*minutes = msg->msg[7]; |
| 686 |
} |
| 687 |
|
| 688 |
static inline void cec_msg_htng_clr_all_sleep_wake(struct cec_msg *msg) |
| 689 |
{ |
| 690 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_CLR_ALL_SLEEP_WAKE); |
| 691 |
} |
| 692 |
|
| 693 |
static inline void cec_msg_htng_global_direct_tune_freq(struct cec_msg *msg, |
| 694 |
__u8 htng_chan_type, |
| 695 |
__u8 htng_prog_type, |
| 696 |
__u8 htng_system_type, |
| 697 |
__u16 freq, |
| 698 |
__u16 service_id, |
| 699 |
__u8 htng_mod_type, |
| 700 |
__u8 htng_symbol_rate, |
| 701 |
__u16 symbol_rate) |
| 702 |
{ |
| 703 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_GLOBAL_DIRECT_TUNE_FREQ); |
| 704 |
msg->msg[msg->len++] = (htng_chan_type & 7) | |
| 705 |
((htng_prog_type & 1) << 3) | |
| 706 |
(htng_system_type << 4); |
| 707 |
msg->msg[msg->len++] = freq >> 8; |
| 708 |
msg->msg[msg->len++] = freq & 0xff; |
| 709 |
msg->msg[msg->len++] = service_id >> 8; |
| 710 |
msg->msg[msg->len++] = service_id & 0xff; |
| 711 |
msg->msg[msg->len++] = (htng_mod_type & 0xf) | |
| 712 |
((htng_symbol_rate & 1) << 7); |
| 713 |
if (htng_symbol_rate == CEC_OP_HTNG_SYMBOL_RATE_MANUAL) { |
| 714 |
msg->msg[msg->len++] = symbol_rate >> 8; |
| 715 |
msg->msg[msg->len++] = symbol_rate & 0xff; |
| 716 |
} |
| 717 |
} |
| 718 |
|
| 719 |
static inline void cec_ops_htng_global_direct_tune_freq(const struct cec_msg *msg, |
| 720 |
__u8 *htng_chan_type, |
| 721 |
__u8 *htng_prog_type, |
| 722 |
__u8 *htng_system_type, |
| 723 |
__u16 *freq, |
| 724 |
__u16 *service_id, |
| 725 |
__u8 *htng_mod_type, |
| 726 |
__u8 *htng_symbol_rate, |
| 727 |
__u16 *symbol_rate) |
| 728 |
{ |
| 729 |
*htng_chan_type = msg->msg[6] & 7; |
| 730 |
*htng_prog_type = (msg->msg[6] >> 3) & 1; |
| 731 |
*htng_system_type = (msg->msg[6] >> 4) & 0xf; |
| 732 |
*freq = (msg->msg[7] << 8) | msg->msg[8]; |
| 733 |
*service_id = (msg->msg[9] << 8) | msg->msg[10]; |
| 734 |
*htng_mod_type = msg->msg[11] & 0xf; |
| 735 |
*htng_symbol_rate = (msg->msg[11] >> 7) & 1; |
| 736 |
if (*htng_symbol_rate == CEC_OP_HTNG_SYMBOL_RATE_MANUAL) |
| 737 |
*symbol_rate = (msg->msg[12] << 8) | msg->msg[13]; |
| 738 |
else |
| 739 |
*symbol_rate = 0; |
| 740 |
} |
| 741 |
|
| 742 |
static inline void cec_msg_htng_global_direct_tune_chan(struct cec_msg *msg, |
| 743 |
__u8 htng_chan_type, |
| 744 |
__u8 htng_prog_type, |
| 745 |
__u16 chan) |
| 746 |
{ |
| 747 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_GLOBAL_DIRECT_TUNE_CHAN); |
| 748 |
msg->msg[msg->len++] = (htng_chan_type & 7) | |
| 749 |
((htng_prog_type & 1) << 3); |
| 750 |
msg->msg[msg->len++] = chan >> 8; |
| 751 |
msg->msg[msg->len++] = chan & 0xff; |
| 752 |
} |
| 753 |
|
| 754 |
static inline void cec_ops_htng_global_direct_tune_chan(const struct cec_msg *msg, |
| 755 |
__u8 *htng_chan_type, |
| 756 |
__u8 *htng_prog_type, |
| 757 |
__u16 *chan) |
| 758 |
{ |
| 759 |
*htng_chan_type = msg->msg[6] & 7; |
| 760 |
*htng_prog_type = (msg->msg[6] >> 3) & 1; |
| 761 |
*chan = (msg->msg[7] << 8) | msg->msg[8]; |
| 762 |
} |
| 763 |
|
| 764 |
static inline void cec_msg_htng_global_direct_tune_ext_freq(struct cec_msg *msg, |
| 765 |
__u8 htng_ext_chan_type, |
| 766 |
__u8 htng_prog_type, |
| 767 |
__u8 htng_system_type, |
| 768 |
__u16 freq, |
| 769 |
__u16 service_id, |
| 770 |
__u8 htng_mod_type, |
| 771 |
__u8 htng_onid, |
| 772 |
__u16 onid, |
| 773 |
__u8 htng_nid, |
| 774 |
__u16 nid, |
| 775 |
__u8 htng_tsid_plp, |
| 776 |
__u16 tsid_plp, |
| 777 |
__u8 htng_symbol_rate, |
| 778 |
__u16 symbol_rate) |
| 779 |
{ |
| 780 |
cec_msg_htng_init(msg, CEC_MSG_HTNG_GLOBAL_DIRECT_TUNE_EXT_FREQ); |
| 781 |
msg->msg[msg->len++] = (htng_ext_chan_type & 7) | |
| 782 |
((htng_prog_type & 1) << 3) | |
| 783 |
(htng_system_type << 4); |
| 784 |
msg->msg[msg->len++] = freq >> 8; |
| 785 |
msg->msg[msg->len++] = freq & 0xff; |
| 786 |
msg->msg[msg->len++] = service_id >> 8; |
| 787 |
msg->msg[msg->len++] = service_id & 0xff; |
| 788 |
msg->msg[msg->len++] = (htng_mod_type & 0xf) | |
| 789 |
((htng_onid & 1) << 4) | |
| 790 |
((htng_nid & 1) << 5) | |
| 791 |
((htng_tsid_plp & 1) << 6) | |
| 792 |
((htng_symbol_rate & 1) << 7); |
| 793 |
if (htng_onid == CEC_OP_HTNG_ONID_MANUAL) { |
| 794 |
msg->msg[msg->len++] = onid >> 8; |
| 795 |
msg->msg[msg->len++] = onid & 0xff; |
| 796 |
} |
| 797 |
if (htng_nid == CEC_OP_HTNG_NID_MANUAL) { |
| 798 |
msg->msg[msg->len++] = nid >> 8; |
| 799 |
msg->msg[msg->len++] = nid & 0xff; |
| 800 |
} |
| 801 |
if (msg->len < CEC_MAX_MSG_SIZE && |
| 802 |
htng_tsid_plp == CEC_OP_HTNG_TSID_PLP_MANUAL) { |
| 803 |
msg->msg[msg->len++] = tsid_plp >> 8; |
| 804 |
msg->msg[msg->len++] = tsid_plp & 0xff; |
| 805 |
} |
| 806 |
if (msg->len < CEC_MAX_MSG_SIZE && |
| 807 |
htng_symbol_rate == CEC_OP_HTNG_SYMBOL_RATE_MANUAL) { |
| 808 |
msg->msg[msg->len++] = symbol_rate >> 8; |
| 809 |
msg->msg[msg->len++] = symbol_rate & 0xff; |
| 810 |
} |
| 811 |
} |
| 812 |
|
| 813 |
static inline void cec_ops_htng_global_direct_tune_ext_freq(const struct cec_msg *msg, |
| 814 |
__u8 *htng_ext_chan_type, |
| 815 |
__u8 *htng_prog_type, |
| 816 |
__u8 *htng_system_type, |
| 817 |
__u16 *freq, |
| 818 |
__u16 *service_id, |
| 819 |
__u8 *htng_mod_type, |
| 820 |
__u8 *htng_onid, |
| 821 |
__u16 *onid, |
| 822 |
__u8 *htng_nid, |
| 823 |
__u16 *nid, |
| 824 |
__u8 *htng_tsid_plp, |
| 825 |
__u16 *tsid_plp, |
| 826 |
__u8 *htng_symbol_rate, |
| 827 |
__u16 *symbol_rate) |
| 828 |
{ |
| 829 |
unsigned offset = 12; |
| 830 |
|
| 831 |
*htng_ext_chan_type = msg->msg[6] & 7; |
| 832 |
*htng_prog_type = (msg->msg[6] >> 3) & 1; |
| 833 |
*htng_system_type = (msg->msg[6] >> 4) & 0xf; |
| 834 |
*freq = (msg->msg[7] << 8) | msg->msg[8]; |
| 835 |
*service_id = (msg->msg[9] << 8) | msg->msg[10]; |
| 836 |
*htng_mod_type = msg->msg[11] & 0xf; |
| 837 |
*htng_onid = (msg->msg[11] >> 4) & 1; |
| 838 |
*htng_nid = (msg->msg[11] >> 5) & 1; |
| 839 |
*htng_tsid_plp = (msg->msg[11] >> 6) & 1; |
| 840 |
*htng_symbol_rate = (msg->msg[11] >> 7) & 1; |
| 841 |
if (*htng_onid == CEC_OP_HTNG_ONID_MANUAL) { |
| 842 |
*onid = (msg->msg[offset] << 8) | msg->msg[offset + 1]; |
| 843 |
offset += 2; |
| 844 |
} else { |
| 845 |
*onid = 0; |
| 846 |
} |
| 847 |
if (*htng_nid == CEC_OP_HTNG_NID_MANUAL) { |
| 848 |
*nid = (msg->msg[offset] << 8) | msg->msg[offset + 1]; |
| 849 |
offset += 2; |
| 850 |
} else { |
| 851 |
*nid = 0; |
| 852 |
} |
| 853 |
if (offset < CEC_MAX_MSG_SIZE && |
| 854 |
*htng_tsid_plp == CEC_OP_HTNG_TSID_PLP_MANUAL) { |
| 855 |
*tsid_plp = (msg->msg[offset] << 8) | msg->msg[offset + 1]; |
| 856 |
offset += 2; |
| 857 |
} else { |
| 858 |
*tsid_plp = 0; |
| 859 |
} |
| 860 |
if (offset < CEC_MAX_MSG_SIZE && |
| 861 |
*htng_symbol_rate == CEC_OP_HTNG_SYMBOL_RATE_MANUAL) { |
| 862 |
*symbol_rate = (msg->msg[offset] << 8) | msg->msg[offset + 1]; |
| 863 |
offset += 2; |
| 864 |
} else { |
| 865 |
*symbol_rate = 0; |
| 866 |
} |
| 867 |
} |
| 868 |
|
| 869 |
#endif |