/* 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 kmutex_init(_p_) mutex_init(_p_)
#define kmutex_lock(_p_) mutex_lock(_p_)
#define kmutex_trylock(_p_) mutex_trylock(_p_)
#define kmutex_unlock(_p_) mutex_unlock(_p_)
/*
* 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 (*loadfirmware_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