162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * vivid-rds-gen.h - rds (radio data system) generator support functions.
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#ifndef _VIVID_RDS_GEN_H_
962306a36Sopenharmony_ci#define _VIVID_RDS_GEN_H_
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci/*
1262306a36Sopenharmony_ci * It takes almost exactly 5 seconds to transmit 57 RDS groups.
1362306a36Sopenharmony_ci * Each group has 4 blocks and each block has a payload of 16 bits + a
1462306a36Sopenharmony_ci * block identification. The driver will generate the contents of these
1562306a36Sopenharmony_ci * 57 groups only when necessary and it will just be played continuously.
1662306a36Sopenharmony_ci */
1762306a36Sopenharmony_ci#define VIVID_RDS_GEN_GROUPS 57
1862306a36Sopenharmony_ci#define VIVID_RDS_GEN_BLKS_PER_GRP 4
1962306a36Sopenharmony_ci#define VIVID_RDS_GEN_BLOCKS (VIVID_RDS_GEN_BLKS_PER_GRP * VIVID_RDS_GEN_GROUPS)
2062306a36Sopenharmony_ci#define VIVID_RDS_NSEC_PER_BLK (u32)(5ull * NSEC_PER_SEC / VIVID_RDS_GEN_BLOCKS)
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_cistruct vivid_rds_gen {
2362306a36Sopenharmony_ci	struct v4l2_rds_data	data[VIVID_RDS_GEN_BLOCKS];
2462306a36Sopenharmony_ci	bool			use_rbds;
2562306a36Sopenharmony_ci	u16			picode;
2662306a36Sopenharmony_ci	u8			pty;
2762306a36Sopenharmony_ci	bool			mono_stereo;
2862306a36Sopenharmony_ci	bool			art_head;
2962306a36Sopenharmony_ci	bool			compressed;
3062306a36Sopenharmony_ci	bool			dyn_pty;
3162306a36Sopenharmony_ci	bool			ta;
3262306a36Sopenharmony_ci	bool			tp;
3362306a36Sopenharmony_ci	bool			ms;
3462306a36Sopenharmony_ci	char			psname[8 + 1];
3562306a36Sopenharmony_ci	char			radiotext[64 + 1];
3662306a36Sopenharmony_ci};
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_civoid vivid_rds_gen_fill(struct vivid_rds_gen *rds, unsigned freq,
3962306a36Sopenharmony_ci		    bool use_alternate);
4062306a36Sopenharmony_civoid vivid_rds_generate(struct vivid_rds_gen *rds);
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci#endif
43