18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * vivid-rds-gen.h - rds (radio data system) generator support functions.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef _VIVID_RDS_GEN_H_
98c2ecf20Sopenharmony_ci#define _VIVID_RDS_GEN_H_
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci/*
128c2ecf20Sopenharmony_ci * It takes almost exactly 5 seconds to transmit 57 RDS groups.
138c2ecf20Sopenharmony_ci * Each group has 4 blocks and each block has a payload of 16 bits + a
148c2ecf20Sopenharmony_ci * block identification. The driver will generate the contents of these
158c2ecf20Sopenharmony_ci * 57 groups only when necessary and it will just be played continuously.
168c2ecf20Sopenharmony_ci */
178c2ecf20Sopenharmony_ci#define VIVID_RDS_GEN_GROUPS 57
188c2ecf20Sopenharmony_ci#define VIVID_RDS_GEN_BLKS_PER_GRP 4
198c2ecf20Sopenharmony_ci#define VIVID_RDS_GEN_BLOCKS (VIVID_RDS_GEN_BLKS_PER_GRP * VIVID_RDS_GEN_GROUPS)
208c2ecf20Sopenharmony_ci#define VIVID_RDS_NSEC_PER_BLK (u32)(5ull * NSEC_PER_SEC / VIVID_RDS_GEN_BLOCKS)
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_cistruct vivid_rds_gen {
238c2ecf20Sopenharmony_ci	struct v4l2_rds_data	data[VIVID_RDS_GEN_BLOCKS];
248c2ecf20Sopenharmony_ci	bool			use_rbds;
258c2ecf20Sopenharmony_ci	u16			picode;
268c2ecf20Sopenharmony_ci	u8			pty;
278c2ecf20Sopenharmony_ci	bool			mono_stereo;
288c2ecf20Sopenharmony_ci	bool			art_head;
298c2ecf20Sopenharmony_ci	bool			compressed;
308c2ecf20Sopenharmony_ci	bool			dyn_pty;
318c2ecf20Sopenharmony_ci	bool			ta;
328c2ecf20Sopenharmony_ci	bool			tp;
338c2ecf20Sopenharmony_ci	bool			ms;
348c2ecf20Sopenharmony_ci	char			psname[8 + 1];
358c2ecf20Sopenharmony_ci	char			radiotext[64 + 1];
368c2ecf20Sopenharmony_ci};
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_civoid vivid_rds_gen_fill(struct vivid_rds_gen *rds, unsigned freq,
398c2ecf20Sopenharmony_ci		    bool use_alternate);
408c2ecf20Sopenharmony_civoid vivid_rds_generate(struct vivid_rds_gen *rds);
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#endif
43