/* SPDX-License-Identifier: GPL-2.0-or-later */
/****************************************************************
Siano Mobile Silicon, Inc.
MDTV receiver kernel modules.
Copyright (C) 2006-2008, Uri Shkolnik, Anatoly Greenblat
****************************************************************/
#ifndef __SMS_CORE_API_H__
#define __SMS_CORE_API_H__
#define pr_fmt(fmt) "%s:%s: " fmt, KBUILD_MODNAME, __func__
#include <linux/device.h>
#include <linux/list.h>
#include <linux/mm.h>
#include <linux/scatterlist.h>
#include <linux/types.h>
#include <linux/mutex.h>
#include <linux/wait.h>
#include <linux/timer.h>
#include <media/media-device.h>
#include <asm/page.h>
#include "smsir.h"
/*
* Define the firmware names used by the driver.
* Those should match what's used at smscoreapi.c and sms-cards.c
* including the MODULE_FIRMWARE() macros at the end of smscoreapi.c
*/
#define SMS_FW_ATSC_DENVER "atsc_denver.inp"
#define SMS_FW_CMMB_MING_APP "cmmb_ming_app.inp"
#define SMS_FW_CMMB_VEGA_12MHZ "cmmb_vega_12mhz.inp"
#define SMS_FW_CMMB_VENICE_12MHZ "cmmb_venice_12mhz.inp"
#define SMS_FW_DVBH_RIO "dvbh_rio.inp"
#define SMS_FW_DVB_NOVA_12MHZ_B0 "dvb_nova_12mhz_b0.inp"
#define SMS_FW_DVB_NOVA_12MHZ "dvb_nova_12mhz.inp"
#define SMS_FW_DVB_RIO "dvb_rio.inp"
#define SMS_FW_FM_RADIO "fm_radio.inp"
#define SMS_FW_FM_RADIO_RIO "fm_radio_rio.inp"
#define SMS_FW_DVBT_HCW_55XXX "sms1xxx-hcw-55xxx-dvbt-02.fw"
#define SMS_FW_ISDBT_HCW_55XXX "sms1xxx-hcw-55xxx-isdbt-02.fw"
#define SMS_FW_ISDBT_NOVA_12MHZ_B0 "isdbt_nova_12mhz_b0.inp"
#define SMS_FW_ISDBT_NOVA_12MHZ "isdbt_nova_12mhz.inp"
#define SMS_FW_ISDBT_PELE "isdbt_pele.inp"
#define SMS_FW_ISDBT_RIO "isdbt_rio.inp"
#define SMS_FW_DVBT_NOVA_A "sms1xxx-nova-a-dvbt-01.fw"
#define SMS_FW_DVBT_NOVA_B "sms1xxx-nova-b-dvbt-01.fw"
#define SMS_FW_DVBT_STELLAR "sms1xxx-stellar-dvbt-01.fw"
#define SMS_FW_TDMB_DENVER "tdmb_denver.inp"
#define SMS_FW_TDMB_NOVA_12MHZ_B0 "tdmb_nova_12mhz_b0.inp"
#define SMS_FW_TDMB_NOVA_12MHZ "tdmb_nova_12mhz.inp"
#define SMS_PROTOCOL_MAX_RAOUNDTRIP_MS (10000)
#define SMS_ALLOC_ALIGNMENT 128
#define SMS_DMA_ALIGNMENT 16
#define SMS_ALIGN_ADDRESS(addr) \
((((uintptr_t)(addr)) + (SMS_DMA_ALIGNMENT-1)) & ~(SMS_DMA_ALIGNMENT-1))
#define SMS_DEVICE_FAMILY1 0
#define SMS_DEVICE_FAMILY2 1
#define SMS_ROM_NO_RESPONSE 2
#define SMS_DEVICE_NOT_READY 0x8000000
enum sms_device_type_st {
SMS_UNKNOWN_TYPE = -1,
SMS_STELLAR = 0,
SMS_NOVA_A0,
SMS_NOVA_B0,
SMS_VEGA,
SMS_VENICE,
SMS_MING,
SMS_PELE,
SMS_RIO,
SMS_DENVER_1530,
SMS_DENVER_2160,
SMS_NUM_OF_DEVICE_TYPES
};
enum sms_power_mode_st {
SMS_POWER_MODE_ACTIVE,
SMS_POWER_MODE_SUSPENDED
};
struct smscore_device_t;
struct smscore_client_t;
struct smscore_buffer_t;
typedef int (*hotplug_t)(struct smscore_device_t *coredev,
struct device *device, int arrival);
typedef int (*setmode_t)(void *context, int mode);
typedef void (*detectmode_t)(void *context, int *mode);
typedef int (*sendrequest_t)(void *context, void *buffer, size_t size);
typedef int (*preload_t)(void *context);
typedef int (*postload_t)(void *context);
typedef int (*onresponse_t)(void *context, struct smscore_buffer_t *cb);
typedef void (*onremove_t)(void *context);
struct smscore_buffer_t {
/* public members, once passed to clients can be changed freely */
struct list_head entry;
int size;
int offset;
/* private members, read-only for clients */
void *p;
dma_addr_t phys;
unsigned long offset_in_common;
};
struct smsdevice_params_t {
struct device *device;
struct usb_device *usb_device;
int buffer_size;
int num_buffers;
char devpath[32];
unsigned long flags;
setmode_t setmode_handler;
detectmode_t detectmode_handler;
sendrequest_t sendrequest_handler;
preload_t preload_handler;
postload_t postload_handler;
void *context;
enum sms_device_type_st device_type;
};
struct smsclient_params_t {
int initial_id;
int data_type;
onresponse_t onresponse_handler;
onremove_t onremove_handler;
void *context;
};
struct smscore_device_t {
struct list_head entry;
struct list_head clients;
struct list_head subclients;
spinlock_t clientslock;
struct list_head buffers;
spinlock_t bufferslock;
int num_buffers;
void *common_buffer;
int common_buffer_size;
dma_addr_t common_buffer_phys;
void *context;
struct device *device;
struct usb_device *usb_device;
char devpath[32];
unsigned long device_flags;
setmode_t setmode_handler;
detectmode_t detectmode_handler;
sendrequest_t sendrequest_handler;
preload_t preload_handler;
postload_t postload_handler;
int mode, modes_supported;
gfp_t gfp_buf_flags;
/* host <--> device messages */
struct completion version_ex_done, data_download_done, trigger_done;
struct completion data_validity_done, device_ready_done;
struct completion init_device_done, reload_start_done, resume_done;
struct completion gpio_configuration_done, gpio_set_level_done;
struct completion gpio_get_level_done, ir_init_done;
/* Buffer management */
wait_queue_head_t buffer_mng_waitq;
/* GPIO */
int gpio_get_res;
/* Target hardware board */
int board_id;
/* Firmware */
u8 *fw_buf;
u32 fw_buf_size;
u16 fw_version;
/* Infrared (IR) */
struct ir_t ir;
/*
* Identify if device is USB or not.
* Used by smsdvb-sysfs to know the root node for debugfs
*/
bool is_usb_device;
int led_state;
#if defined(CONFIG_MEDIA_CONTROLLER_DVB)
struct media_device *media_dev;
#endif
};
/* GPIO definitions for antenna frequency d