Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Abilis Systems Single DVB-T Receiver
0004  * Copyright (C) 2008 Pierrick Hascoet <pierrick.hascoet@abilis.com>
0005  */
0006 #ifndef _AS10X_CMD_H_
0007 #define _AS10X_CMD_H_
0008 
0009 #include <linux/kernel.h>
0010 
0011 #include "as102_fe_types.h"
0012 
0013 /*********************************/
0014 /*       MACRO DEFINITIONS       */
0015 /*********************************/
0016 #define AS10X_CMD_ERROR     -1
0017 
0018 #define SERVICE_PROG_ID     0x0002
0019 #define SERVICE_PROG_VERSION    0x0001
0020 
0021 #define HIER_NONE       0x00
0022 #define HIER_LOW_PRIORITY   0x01
0023 
0024 #define HEADER_SIZE (sizeof(struct as10x_cmd_header_t))
0025 
0026 /* context request types */
0027 #define GET_CONTEXT_DATA    1
0028 #define SET_CONTEXT_DATA    2
0029 
0030 /* ODSP suspend modes */
0031 #define CFG_MODE_ODSP_RESUME    0
0032 #define CFG_MODE_ODSP_SUSPEND   1
0033 
0034 /* Dump memory size */
0035 #define DUMP_BLOCK_SIZE_MAX 0x20
0036 
0037 /*********************************/
0038 /*     TYPE DEFINITION           */
0039 /*********************************/
0040 enum control_proc {
0041     CONTROL_PROC_TURNON         = 0x0001,
0042     CONTROL_PROC_TURNON_RSP         = 0x0100,
0043     CONTROL_PROC_SET_REGISTER       = 0x0002,
0044     CONTROL_PROC_SET_REGISTER_RSP       = 0x0200,
0045     CONTROL_PROC_GET_REGISTER       = 0x0003,
0046     CONTROL_PROC_GET_REGISTER_RSP       = 0x0300,
0047     CONTROL_PROC_SETTUNE            = 0x000A,
0048     CONTROL_PROC_SETTUNE_RSP        = 0x0A00,
0049     CONTROL_PROC_GETTUNESTAT        = 0x000B,
0050     CONTROL_PROC_GETTUNESTAT_RSP        = 0x0B00,
0051     CONTROL_PROC_GETTPS         = 0x000D,
0052     CONTROL_PROC_GETTPS_RSP         = 0x0D00,
0053     CONTROL_PROC_SETFILTER          = 0x000E,
0054     CONTROL_PROC_SETFILTER_RSP      = 0x0E00,
0055     CONTROL_PROC_REMOVEFILTER       = 0x000F,
0056     CONTROL_PROC_REMOVEFILTER_RSP       = 0x0F00,
0057     CONTROL_PROC_GET_IMPULSE_RESP       = 0x0012,
0058     CONTROL_PROC_GET_IMPULSE_RESP_RSP   = 0x1200,
0059     CONTROL_PROC_START_STREAMING        = 0x0013,
0060     CONTROL_PROC_START_STREAMING_RSP    = 0x1300,
0061     CONTROL_PROC_STOP_STREAMING     = 0x0014,
0062     CONTROL_PROC_STOP_STREAMING_RSP     = 0x1400,
0063     CONTROL_PROC_GET_DEMOD_STATS        = 0x0015,
0064     CONTROL_PROC_GET_DEMOD_STATS_RSP    = 0x1500,
0065     CONTROL_PROC_ELNA_CHANGE_MODE       = 0x0016,
0066     CONTROL_PROC_ELNA_CHANGE_MODE_RSP   = 0x1600,
0067     CONTROL_PROC_ODSP_CHANGE_MODE       = 0x0017,
0068     CONTROL_PROC_ODSP_CHANGE_MODE_RSP   = 0x1700,
0069     CONTROL_PROC_AGC_CHANGE_MODE        = 0x0018,
0070     CONTROL_PROC_AGC_CHANGE_MODE_RSP    = 0x1800,
0071 
0072     CONTROL_PROC_CONTEXT            = 0x00FC,
0073     CONTROL_PROC_CONTEXT_RSP        = 0xFC00,
0074     CONTROL_PROC_DUMP_MEMORY        = 0x00FD,
0075     CONTROL_PROC_DUMP_MEMORY_RSP        = 0xFD00,
0076     CONTROL_PROC_DUMPLOG_MEMORY     = 0x00FE,
0077     CONTROL_PROC_DUMPLOG_MEMORY_RSP     = 0xFE00,
0078     CONTROL_PROC_TURNOFF            = 0x00FF,
0079     CONTROL_PROC_TURNOFF_RSP        = 0xFF00
0080 };
0081 
0082 union as10x_turn_on {
0083     /* request */
0084     struct {
0085         /* request identifier */
0086         __le16 proc_id;
0087     } __packed req;
0088     /* response */
0089     struct {
0090         /* response identifier */
0091         __le16 proc_id;
0092         /* error */
0093         uint8_t error;
0094     } __packed rsp;
0095 } __packed;
0096 
0097 union as10x_turn_off {
0098     /* request */
0099     struct {
0100         /* request identifier */
0101         __le16 proc_id;
0102     } __packed req;
0103     /* response */
0104     struct {
0105         /* response identifier */
0106         __le16 proc_id;
0107         /* error */
0108         uint8_t err;
0109     } __packed rsp;
0110 } __packed;
0111 
0112 union as10x_set_tune {
0113     /* request */
0114     struct {
0115         /* request identifier */
0116         __le16 proc_id;
0117         /* tune params */
0118         struct as10x_tune_args args;
0119     } __packed req;
0120     /* response */
0121     struct {
0122         /* response identifier */
0123         __le16 proc_id;
0124         /* response error */
0125         uint8_t error;
0126     } __packed rsp;
0127 } __packed;
0128 
0129 union as10x_get_tune_status {
0130     /* request */
0131     struct {
0132         /* request identifier */
0133         __le16 proc_id;
0134     } __packed req;
0135     /* response */
0136     struct {
0137         /* response identifier */
0138         __le16 proc_id;
0139         /* response error */
0140         uint8_t error;
0141         /* tune status */
0142         struct as10x_tune_status sts;
0143     } __packed rsp;
0144 } __packed;
0145 
0146 union as10x_get_tps {
0147     /* request */
0148     struct {
0149         /* request identifier */
0150         __le16 proc_id;
0151     } __packed req;
0152     /* response */
0153     struct {
0154         /* response identifier */
0155         __le16 proc_id;
0156         /* response error */
0157         uint8_t error;
0158         /* tps details */
0159         struct as10x_tps tps;
0160     } __packed rsp;
0161 } __packed;
0162 
0163 union as10x_common {
0164     /* request */
0165     struct {
0166         /* request identifier */
0167         __le16  proc_id;
0168     } __packed req;
0169     /* response */
0170     struct {
0171         /* response identifier */
0172         __le16 proc_id;
0173         /* response error */
0174         uint8_t error;
0175     } __packed rsp;
0176 } __packed;
0177 
0178 union as10x_add_pid_filter {
0179     /* request */
0180     struct {
0181         /* request identifier */
0182         __le16  proc_id;
0183         /* PID to filter */
0184         __le16  pid;
0185         /* stream type (MPE, PSI/SI or PES )*/
0186         uint8_t stream_type;
0187         /* PID index in filter table */
0188         uint8_t idx;
0189     } __packed req;
0190     /* response */
0191     struct {
0192         /* response identifier */
0193         __le16 proc_id;
0194         /* response error */
0195         uint8_t error;
0196         /* Filter id */
0197         uint8_t filter_id;
0198     } __packed rsp;
0199 } __packed;
0200 
0201 union as10x_del_pid_filter {
0202     /* request */
0203     struct {
0204         /* request identifier */
0205         __le16  proc_id;
0206         /* PID to remove */
0207         __le16  pid;
0208     } __packed req;
0209     /* response */
0210     struct {
0211         /* response identifier */
0212         __le16 proc_id;
0213         /* response error */
0214         uint8_t error;
0215     } __packed rsp;
0216 } __packed;
0217 
0218 union as10x_start_streaming {
0219     /* request */
0220     struct {
0221         /* request identifier */
0222         __le16 proc_id;
0223     } __packed req;
0224     /* response */
0225     struct {
0226         /* response identifier */
0227         __le16 proc_id;
0228         /* error */
0229         uint8_t error;
0230     } __packed rsp;
0231 } __packed;
0232 
0233 union as10x_stop_streaming {
0234     /* request */
0235     struct {
0236         /* request identifier */
0237         __le16 proc_id;
0238     } __packed req;
0239     /* response */
0240     struct {
0241         /* response identifier */
0242         __le16 proc_id;
0243         /* error */
0244         uint8_t error;
0245     } __packed rsp;
0246 } __packed;
0247 
0248 union as10x_get_demod_stats {
0249     /* request */
0250     struct {
0251         /* request identifier */
0252         __le16 proc_id;
0253     } __packed req;
0254     /* response */
0255     struct {
0256         /* response identifier */
0257         __le16 proc_id;
0258         /* error */
0259         uint8_t error;
0260         /* demod stats */
0261         struct as10x_demod_stats stats;
0262     } __packed rsp;
0263 } __packed;
0264 
0265 union as10x_get_impulse_resp {
0266     /* request */
0267     struct {
0268         /* request identifier */
0269         __le16 proc_id;
0270     } __packed req;
0271     /* response */
0272     struct {
0273         /* response identifier */
0274         __le16 proc_id;
0275         /* error */
0276         uint8_t error;
0277         /* impulse response ready */
0278         uint8_t is_ready;
0279     } __packed rsp;
0280 } __packed;
0281 
0282 union as10x_fw_context {
0283     /* request */
0284     struct {
0285         /* request identifier */
0286         __le16 proc_id;
0287         /* value to write (for set context)*/
0288         struct as10x_register_value reg_val;
0289         /* context tag */
0290         __le16 tag;
0291         /* context request type */
0292         __le16 type;
0293     } __packed req;
0294     /* response */
0295     struct {
0296         /* response identifier */
0297         __le16 proc_id;
0298         /* value read (for get context) */
0299         struct as10x_register_value reg_val;
0300         /* context request type */
0301         __le16 type;
0302         /* error */
0303         uint8_t error;
0304     } __packed rsp;
0305 } __packed;
0306 
0307 union as10x_set_register {
0308     /* request */
0309     struct {
0310         /* response identifier */
0311         __le16 proc_id;
0312         /* register description */
0313         struct as10x_register_addr reg_addr;
0314         /* register content */
0315         struct as10x_register_value reg_val;
0316     } __packed req;
0317     /* response */
0318     struct {
0319         /* response identifier */
0320         __le16 proc_id;
0321         /* error */
0322         uint8_t error;
0323     } __packed rsp;
0324 } __packed;
0325 
0326 union as10x_get_register {
0327     /* request */
0328     struct {
0329         /* response identifier */
0330         __le16 proc_id;
0331         /* register description */
0332         struct as10x_register_addr reg_addr;
0333     } __packed req;
0334     /* response */
0335     struct {
0336         /* response identifier */
0337         __le16 proc_id;
0338         /* error */
0339         uint8_t error;
0340         /* register content */
0341         struct as10x_register_value reg_val;
0342     } __packed rsp;
0343 } __packed;
0344 
0345 union as10x_cfg_change_mode {
0346     /* request */
0347     struct {
0348         /* request identifier */
0349         __le16 proc_id;
0350         /* mode */
0351         uint8_t mode;
0352     } __packed req;
0353     /* response */
0354     struct {
0355         /* response identifier */
0356         __le16 proc_id;
0357         /* error */
0358         uint8_t error;
0359     } __packed rsp;
0360 } __packed;
0361 
0362 struct as10x_cmd_header_t {
0363     __le16 req_id;
0364     __le16 prog;
0365     __le16 version;
0366     __le16 data_len;
0367 } __packed;
0368 
0369 #define DUMP_BLOCK_SIZE 16
0370 
0371 union as10x_dump_memory {
0372     /* request */
0373     struct {
0374         /* request identifier */
0375         __le16 proc_id;
0376         /* dump memory type request */
0377         uint8_t dump_req;
0378         /* register description */
0379         struct as10x_register_addr reg_addr;
0380         /* nb blocks to read */
0381         __le16 num_blocks;
0382     } __packed req;
0383     /* response */
0384     struct {
0385         /* response identifier */
0386         __le16 proc_id;
0387         /* error */
0388         uint8_t error;
0389         /* dump response */
0390         uint8_t dump_rsp;
0391         /* data */
0392         union {
0393             uint8_t  data8[DUMP_BLOCK_SIZE];
0394             __le16 data16[DUMP_BLOCK_SIZE / sizeof(__le16)];
0395             __le32 data32[DUMP_BLOCK_SIZE / sizeof(__le32)];
0396         } __packed u;
0397     } __packed rsp;
0398 } __packed;
0399 
0400 union as10x_dumplog_memory {
0401     struct {
0402         /* request identifier */
0403         __le16 proc_id;
0404         /* dump memory type request */
0405         uint8_t dump_req;
0406     } __packed req;
0407     struct {
0408         /* request identifier */
0409         __le16 proc_id;
0410         /* error */
0411         uint8_t error;
0412         /* dump response */
0413         uint8_t dump_rsp;
0414         /* dump data */
0415         uint8_t data[DUMP_BLOCK_SIZE];
0416     } __packed rsp;
0417 } __packed;
0418 
0419 union as10x_raw_data {
0420     /* request */
0421     struct {
0422         __le16 proc_id;
0423         uint8_t data[64 - sizeof(struct as10x_cmd_header_t)
0424                  - 2 /* proc_id */];
0425     } __packed req;
0426     /* response */
0427     struct {
0428         __le16 proc_id;
0429         uint8_t error;
0430         uint8_t data[64 - sizeof(struct as10x_cmd_header_t)
0431                  - 2 /* proc_id */ - 1 /* rc */];
0432     } __packed rsp;
0433 } __packed;
0434 
0435 struct as10x_cmd_t {
0436     struct as10x_cmd_header_t header;
0437     union {
0438         union as10x_turn_on     turn_on;
0439         union as10x_turn_off        turn_off;
0440         union as10x_set_tune        set_tune;
0441         union as10x_get_tune_status get_tune_status;
0442         union as10x_get_tps     get_tps;
0443         union as10x_common      common;
0444         union as10x_add_pid_filter  add_pid_filter;
0445         union as10x_del_pid_filter  del_pid_filter;
0446         union as10x_start_streaming start_streaming;
0447         union as10x_stop_streaming  stop_streaming;
0448         union as10x_get_demod_stats get_demod_stats;
0449         union as10x_get_impulse_resp    get_impulse_rsp;
0450         union as10x_fw_context      context;
0451         union as10x_set_register    set_register;
0452         union as10x_get_register    get_register;
0453         union as10x_cfg_change_mode cfg_change_mode;
0454         union as10x_dump_memory     dump_memory;
0455         union as10x_dumplog_memory  dumplog_memory;
0456         union as10x_raw_data        raw_data;
0457     } __packed body;
0458 } __packed;
0459 
0460 struct as10x_token_cmd_t {
0461     /* token cmd */
0462     struct as10x_cmd_t c;
0463     /* token response */
0464     struct as10x_cmd_t r;
0465 } __packed;
0466 
0467 
0468 /**************************/
0469 /* FUNCTION DECLARATION   */
0470 /**************************/
0471 
0472 void as10x_cmd_build(struct as10x_cmd_t *pcmd, uint16_t proc_id,
0473               uint16_t cmd_len);
0474 int as10x_rsp_parse(struct as10x_cmd_t *r, uint16_t proc_id);
0475 
0476 /* as10x cmd */
0477 int as10x_cmd_turn_on(struct as10x_bus_adapter_t *adap);
0478 int as10x_cmd_turn_off(struct as10x_bus_adapter_t *adap);
0479 
0480 int as10x_cmd_set_tune(struct as10x_bus_adapter_t *adap,
0481                struct as10x_tune_args *ptune);
0482 
0483 int as10x_cmd_get_tune_status(struct as10x_bus_adapter_t *adap,
0484                   struct as10x_tune_status *pstatus);
0485 
0486 int as10x_cmd_get_tps(struct as10x_bus_adapter_t *adap,
0487               struct as10x_tps *ptps);
0488 
0489 int as10x_cmd_get_demod_stats(struct as10x_bus_adapter_t  *adap,
0490                   struct as10x_demod_stats *pdemod_stats);
0491 
0492 int as10x_cmd_get_impulse_resp(struct as10x_bus_adapter_t *adap,
0493                    uint8_t *is_ready);
0494 
0495 /* as10x cmd stream */
0496 int as10x_cmd_add_PID_filter(struct as10x_bus_adapter_t *adap,
0497                  struct as10x_ts_filter *filter);
0498 int as10x_cmd_del_PID_filter(struct as10x_bus_adapter_t *adap,
0499                  uint16_t pid_value);
0500 
0501 int as10x_cmd_start_streaming(struct as10x_bus_adapter_t *adap);
0502 int as10x_cmd_stop_streaming(struct as10x_bus_adapter_t *adap);
0503 
0504 /* as10x cmd cfg */
0505 int as10x_cmd_set_context(struct as10x_bus_adapter_t *adap,
0506               uint16_t tag,
0507               uint32_t value);
0508 int as10x_cmd_get_context(struct as10x_bus_adapter_t *adap,
0509               uint16_t tag,
0510               uint32_t *pvalue);
0511 
0512 int as10x_cmd_eLNA_change_mode(struct as10x_bus_adapter_t *adap, uint8_t mode);
0513 int as10x_context_rsp_parse(struct as10x_cmd_t *prsp, uint16_t proc_id);
0514 #endif