您的位置:首页 > 其它

传真a8的启动流程

2015-10-20 11:46 375 查看

apps/c318/device.h

struct t38_param

typedef struct t38_param
{
/**	0 = No T.38 packet loss concealment (default) \n
1 = Packet loss concealment enabled, bad lines in page replaced by white lines \n
2 = Packet loss concealment enabled, bad lines in page replaced by last good line */
int loss_conceal;

/*	0 = No speed limit (default)
1 = 2400 bps limit
2 = 4800 bps limit
3 = 7200 bps limit
4 = 9600 bps limit
5 = 12000 bps limit
6 = 14400 bps limit
*/
int speed;

/*  0 = Redundancy (default),  1 = FEC */
int err_method;

/*  Number of FEC packets to send in UDPTL Range 0 (default) to 3 */
int numFEC;

/*  Number of IFP used to generate a FEC packet Range 0 (default) to 4 */
int numIFPs;
/*  fax data redundacy 0 - 3 ; Default- 0 */
int data_redundancy;
/*  0 - 7 ; Default- 3 */
int t30_redundancy;
/* dir: 1 -- 318 ==> outer; 2 -- outer ==> 318; 3 -- 318 <==> outer */
int dir;
}t38_param_t;
int device_channel_t38cfg(int dev, int ch_no, t38_param_t *param);
int device_channel_t38enble(int dev, int ch_no, int enable);


apps/c318/device.c

device_channel_t38cfg

int device_channel_t38cfg(int dev, int ch_no, t38_param_t *param)
{
struct device_operation *ops = device_ops[dev];

if(dev <= DEV_TYPE_UNKOWN || dev >= DEV_TYPE_MAX){
printf("error dev dev %d\n", dev);
return -1;
}

return ops->ch_t38cfg(ch_no, param);
}


device_channel_t38enble

int device_channel_t38enble(int dev, int ch_no, int enable)
{
struct device_operation *ops = device_ops[dev];

if(dev <= DEV_TYPE_UNKOWN || dev >= DEV_TYPE_MAX){
printf("error dev dev %d\n", dev);
return -1;
}

return ops->ch_t38en(ch_no, enable);
}



device_register



void device_register(int dev, struct device_operation *ops)
{
if(dev <= DEV_TYPE_UNKOWN || dev >= DEV_TYPE_MAX){
printf("error dev dev %d\n", dev);
return;
}

device_ops[dev] = ops;
}


device_soc318.c

comcerto_ops

static struct device_operation comcerto_ops =
{
.dev_init = comcerto_device_init,
.dev_exit = comcerto_device_exit,
.dev_cfg = comcerto_device_cfg,
.dev_raw = comcerto_device_raw,

.ch_init = comcerto_channel_init,
.ch_exit = comcerto_channel_exit,
.ch_stat = comcerto_channel_stat,
.ch_shutdown = comcerto_channel_shutdown,
.ch_ioctl = comcerto_channel_ioctl,
.ch_t38cfg = comcerto_channel_t38cfg,
.ch_t38en = comcerto_channel_t38en,
.ch_link = comcerto_channel_link,
.ch_loopback = comcerto_channel_loopback,
};


comcerto_register

static void __attribute__((constructor)) comcerto_register(void)
{
device_register(DEV_TYPE_SOC318, &comcerto_ops);
}


comcerto_channel_t38cfg

static int comcerto_channel_t38cfg(int ch_no, t38_param_t *param)
{
    unsigned int *pdata = (unsigned int*)BUF_TO_PARAM();
    
    *pdata++ = htonl(ch_no);
    *pdata++ = htonl(param->loss_conceal);
    *pdata++ = htonl(param->speed);
    *pdata++ = htonl(param->err_method);
    *pdata++ = htonl(param->numFEC);
    *pdata++ = htonl(param->numIFPs);
    *pdata++ = htonl(param->data_redundancy);
    *pdata++ = htonl(param->t30_redundancy);
    *pdata++ = htonl(param->dir);
    
    return comcerto_contact(CMD_CHANNEL_T38CFG, sizeof(*pdata) * 9);
}


comcerto_channel_t38en

static int comcerto_channel_t38en(int ch_no, int enable)
{
    unsigned int *pstat = (unsigned int*)BUF_TO_PARAM();
    
    *pstat++ = htonl(ch_no);
    *pstat++ = enable;
    
    return comcerto_contact(CMD_CHANNEL_T38EN, sizeof(*pstat) * 2);
}


comcerto_contact

static int comcerto_contact(uint32_t cmd, int len)
{
#if 0
    struct timeval start, stop;
    int diff;
    
    gettimeofday(&start);
#endif
    com_cmd = cmd;
    com_buf_len = comcerto_init_head(cmd, com_buf, len);
    comcerto_lock_wait();
#if 0
    gettimeofday(&stop);
    diff = stop.tv_sec - start.tv_sec;
    diff *= 1000000;
    diff += stop.tv_usec - start.tv_usec;
    printf("time diff %dus\n", diff);
#endif
    
    return com_ret;
}


comcerto_init_head

static int comcerto_init_head(int cmd, void *buf, int len)
{
    struct head *head = (struct head *)buf;
    
    head->magic = htonl(CMD_MAGIC);
    head->version = htonl(CMD_VERSION);
    head->cmd = htonl(cmd);
    head->seq = htonl(cmd_seq++);
    head->len = htonl(len);
    
    return len + sizeof(*head);
}


comcerto_lock_wait

static void comcerto_lock_wait(void)
{
    write(comcerto_pipe[1], "w", 1);
    sem_wait(&sem_notify);
}


comcerto_lock_init

static int comcerto_lock_init(void)
{
    if(pipe(comcerto_pipe)){
        return -1;
    }
    sem_init(&sem_notify, 0, 0);
    
    return 0;    
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: