Ejemplo n.º 1
0
  int hu_aap_usb_send (byte * buf, int len, int tmo) {                 // Send USB data: chan,flags,len,type,...
    if (iaap_state != hu_STATE_STARTED && iaap_state != hu_STATE_STARTIN) {   // Need to send when starting
      loge ("CHECK: iaap_state: %d (%s)", iaap_state, state_get (iaap_state));
      return (-1);
    }
    if (ena_log_verbo && ena_log_send) {
#ifndef NDEBUG
      if (buf [1] | 0x08 == 0)                                          // If not encrypted (which was dumped in hu_aap_enc_send()
        hu_aad_dmp ("US: ", 1, & buf [4], len - 4);
#endif
    }
    int ret = hu_usb_send (buf, len, tmo);
    if (ret < 0 || ret != len) {
      loge ("Error hu_usb_send() error so stop USB & AAP  ret: %d  len: %d", ret, len);
      hu_aap_stop (); 
      return (-1);
    }  
    if (ena_log_verbo && ena_log_send)
      logd ("OK hu_usb_send() ret: %d  len: %d", ret, len);
    return (ret);
  }
Ejemplo n.º 2
0
int rpc_send(struct rpc *r, const void *buf, size_t len)
{
    int ret, head_size;
    struct rpc_packet *pkt = &r->send_pkt;

    update_rpc_timestamp(pkt);
    pkt->header.payload_len = len;
    pkt->payload = (void *)buf;
    head_size = sizeof(rpc_header_t);
    ret = skt_send(r->fd, (void *)&pkt->header, head_size);
    if (ret != head_size) {
        loge("skt_send failed!\n");
        return -1;
    }
    ret = skt_send(r->fd, pkt->payload, pkt->header.payload_len);
    if (ret != pkt->header.payload_len) {
        loge("skt_send failed!\n");
        return -1;
    }
    return (head_size + ret);
}
Ejemplo n.º 3
0
void _error(const char * file, int line, const char * str, ...){
  char buffer[1000];  
  va_list arglist;
  va_start (arglist, str);
  vsprintf(buffer,str,arglist);
  va_end(arglist);
  bool noncritical = false;
  for(u32 i = 0; i < array_count(allowed_errors);i++)
    if(strstr(buffer, allowed_errors[i]) != NULL)
      noncritical = true;
  if(!noncritical)
    faulty = true;
  
  loge("** ERROR at %s:%i **\n",file,line);
  if(noncritical && !break_on_errors) return; //skip noncritical errors
  loge("%s", buffer);
  printf("\n");
  printf("** **\n");
  if(break_on_errors)
    raise(SIGINT);
}
Ejemplo n.º 4
0
int rpc_recv(struct rpc *r, void *buf, size_t len)
{
    int ret, rlen;
    struct rpc_packet *pkt = &r->recv_pkt;
    int head_size = sizeof(rpc_header_t);
    memset(pkt, 0, sizeof(rpc_packet_t));
    pkt->payload = buf;

    ret = skt_recv(r->fd, (void *)&pkt->header, head_size);
    if (ret == 0) {
        loge("peer connect closed\n");
        return -1;
    } else if (ret != head_size) {
        loge("skt_recv failed, head_size = %d, ret = %d\n", head_size, ret);
        return -1;
    }
    if (r->send_pkt.header.uuid_dst != pkt->header.uuid_dst) {
        loge("uuid_dst is diff from recved packet.header.uuid_dst!\n");
    }
    if (len < pkt->header.payload_len) {
        loge("skt_recv pkt.header.len = %d\n", pkt->header.payload_len);
    }
    rlen = min(len, pkt->header.payload_len);
    ret = skt_recv(r->fd, buf, rlen);
    if (ret == 0) {
        loge("peer connect closed\n");
        return -1;
    } else if (ret != rlen) {
        loge("skt_recv failed: rlen=%d, ret=%d\n", rlen, ret);
        return -1;
    }
    return ret;
}
Ejemplo n.º 5
0
static int hifi_dsp_async_cmd(unsigned long arg)
{
	int ret = OK;
	struct misc_io_async_param param;
	void *para_krn_in = NULL;
	unsigned int para_krn_size_in = 0;
	HIFI_CHN_CMD *cmd_para = NULL;

	IN_FUNCTION;

	if (copy_from_user(&param,(void*) arg, sizeof(struct misc_io_async_param))) {
		loge("copy_from_user fail.\n");
		ret = ERROR;
		goto END;
	}

	/*获取arg入参*/
	ret = hifi_dsp_get_input_param(param.para_size_in, param.para_in,
								   &para_krn_size_in, &para_krn_in);
	if (OK != ret) {
		loge("get ret=%d\n", ret);
		goto END;
	}
	/* add cmd id and sn  */
	cmd_para = (HIFI_CHN_CMD *)(para_krn_in+para_krn_size_in-SIZE_CMD_ID);
	cmd_para->cmd_type = HIFI_CHN_SYNC_CMD;
	cmd_para->sn = ACPU_TO_HIFI_ASYNC_CMD;

	/*邮箱发送至HIFI, 异步*/
	ret = hifi_misc_async_write(para_krn_in, para_krn_size_in);
	if (OK != ret) {
		loge("async_write ret=%d\n", ret);
		goto END;
	}

END:
	hifi_dsp_get_input_param_free(&para_krn_in);
	OUT_FUNCTION;
	return ret;
}
Ejemplo n.º 6
0
/*
**********************************************************************
*                             SbmReturnStream
*
*Description: Return one undecoded frame to sbm module.
*
*Arguments  : pSbm          Created by SbmCreate function;
*             pDataInfo     the stream info need to be returned.
*
*Return     : result;
*               = 0;    succeeded;
*               = -1;   failed.
*               
*Summary    : After returned, the stream data's sequence is the same as before.
*
**********************************************************************
*/
int SbmReturnStream(Sbm *pSbm, VideoStreamDataInfo *pDataInfo)
{
    int nReadPos;
        
    if(pSbm == NULL || pDataInfo == NULL)
    {
        loge("input error.");
        return -1;
    }

    if(lock(pSbm) != 0)
    {
        return -1;
    }

    if(pSbm->frameFifo.nValidFrameNum == 0)
    {
        loge("nValidFrameNum == 0.");
        unlock(pSbm);
        return -1;
    }
    nReadPos = pSbm->frameFifo.nReadPos;
    nReadPos--;
    if(nReadPos < 0)
    {
        nReadPos = pSbm->frameFifo.nMaxFrameNum - 1;
    }
    pSbm->frameFifo.nUnReadFrameNum++;
    if(pDataInfo != &pSbm->frameFifo.pFrames[nReadPos])
    {
        loge("wrong frame sequence.");
        abort();
    }
    
    pSbm->frameFifo.pFrames[nReadPos] = *pDataInfo;
    pSbm->frameFifo.nReadPos  = nReadPos;

    unlock(pSbm);
    return 0;
}
Ejemplo n.º 7
0
  static int server_thread_start () {
    pthread_attr_t thread_attr;
    struct sched_param param;
    int policy, result;

    logd ("server_thread_start thread_state: %d", thread_state);

    if (thread_state == 1) {
      logd ("server_thread_start & thread_state = running");
      return (BT_HC_STATUS_SUCCESS);
    }

    if (thread_state == 2) {
      logd ("server_thread_start & thread_state = not needed and running");
      return (BT_HC_STATUS_SUCCESS);
    }

    thread_state = 1;                                                   // Thread started
    pthread_mutex_init (& server_thread.mutex, NULL);
    pthread_cond_init  (& server_thread.cond, NULL);
    pthread_attr_init  (& thread_attr);

    if (pthread_create (& server_thread.server_thread, & thread_attr, bt_server_thread, NULL) != 0) {
      loge ("server_thread_start pthread_create failed");
      thread_state = 0;
      return (BT_HC_STATUS_FAIL);
    }

    if (pthread_getschedparam (server_thread.server_thread, & policy, & param) == 0) {
      policy = SCHED_NORMAL;
      //param.sched_priority = BTHC_MAIN_THREAD_PRIORITY;
      errno = 0;
      result = pthread_setschedparam (server_thread.server_thread, policy, & param);
      if (result != 0) {
        loge ("server_thread_start pthread_setschedparam failed errno: %d (%s) (%s)", errno, strerror (errno), strerror (result));  // ????
      }
    }
    logd ("server_thread_start done");
    return (BT_HC_STATUS_SUCCESS);
  }
Ejemplo n.º 8
0
static int hisi_6421_spk_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
	struct hisi_6421_spk_platform_data *pdata = NULL;
	int ret = 0;

	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
	if (NULL == pdata){
		dev_err(dev, "cannot allocate hisi 6421 spk platform data\n");
		return -ENOMEM;
	}

	pdata->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (NULL == pdata->res) {
		dev_err(dev, "platform_get_resource err\n");
		return -ENOENT;
	}

	pdata->reg_base_addr = devm_ioremap(dev, pdata->res->start,
					    resource_size(pdata->res));
	if (NULL == pdata->reg_base_addr) {
		dev_err(dev, "cannot map register memory\n");
		return -ENOMEM;
	}

	pdata->regu_ldo8.supply = "hisi-6421-spk-ldo8";
	ret = devm_regulator_bulk_get(dev, 1, &(pdata->regu_ldo8));
	if (0 != ret) {
		dev_err(dev, "couldn't get regulators(ldo8) %d\n", ret);
		return -ENOENT;
	}

	pdata->regu_boost5v.supply = "hisi-6421-spk-boost5v";
	ret = devm_regulator_bulk_get(dev, 1, &(pdata->regu_boost5v));
	if (0 != ret) {
		dev_err(dev, "couldn't get regulators(boost5v) %d\n", ret);
		return -ENOENT;
	}
	mutex_init(&pdata->io_mutex);

	pdata->miscdev.minor = MISC_DYNAMIC_MINOR;
	pdata->miscdev.name = "hisi_6421_spk";
	pdata->miscdev.fops = &hisi_6421_spk_misc_fops;

	ret = misc_register(&pdata->miscdev);
	if (ret)
		loge("%s : hisi 6421 spk_device register failed", __FUNCTION__);

	g_pdata = pdata;

	return ret;
}
Ejemplo n.º 9
0
Archivo: rpcd.c Proyecto: gozfree/src
int process_msg(struct rpc *r, struct iobuf *buf)
{
    int ret;
    msg_handler_t msg_handler;
    struct rpc_header *h = &r->packet.header;
    int msg_id = rpc_packet_parse(r);

    if (find_msg_handler(msg_id, &msg_handler) == 0) {
        msg_handler.cb(r, buf->addr, buf->len);
    } else {
        loge("no callback for this MSG ID in process_msg\n");
        char *valfd = (char *)dict_get(_rpcd->dict_uuid2fd, h->uuid_dst, NULL);
        if (!valfd) {
            loge("dict_get failed: key=%s\n", h->uuid_dst);
            return -1;
        }
        int dst_fd = strtol(valfd, NULL, 16);
        r->fd = dst_fd;
        ret = rpc_send(r, buf->addr, buf->len);
    }
    return ret;
}
Ejemplo n.º 10
0
static void *test2(void *arg)
{
    int i;
    log_init(LOG_STDERR, NULL);
    for (i = 0; i < 1; i++) {
        loge("%s:%s:%d: debug msg\n", __FILE__, __func__, __LINE__);
        logw("%s:%s:%d: debug msg\n", __FILE__, __func__, __LINE__);
        logi("%s:%s:%d: debug msg\n", __FILE__, __func__, __LINE__);
        logd("%s:%s:%d: debug msg\n", __FILE__, __func__, __LINE__);
        logv("%s:%s:%d: debug msg\n", __FILE__, __func__, __LINE__);
    }
    return NULL;
}
Ejemplo n.º 11
0
static void test(void)
{
    int i;
    log_init(LOG_STDERR, NULL);
    for (i = 0; i < 100; i++) {
        loge("%s:%s:%d: debug msg\n", __FILE__, __func__, __LINE__);
        logw("%s:%s:%d: debug msg\n", __FILE__, __func__, __LINE__);
        logi("%s:%s:%d: debug msg\n", __FILE__, __func__, __LINE__);
        logd("%s:%s:%d: debug msg\n", __FILE__, __func__, __LINE__);
        logv("%s:%s:%d: debug msg\n", __FILE__, __func__, __LINE__);
    }
    log_deinit();
}
Ejemplo n.º 12
0
static void test_no_init(void)
{
    int i;
    char tmp[32] = "abcd";
    for (i = 0; i < 10; i++) {
        loge("test rsyslog\n");
        logw("debug msg %d, %s\n", i, tmp);
        logd("debug msg %d, %s\n", i, tmp);
        logi("debug msg %d, %s\n", i, tmp);
        logv("debug msg %d, %s\n", i, tmp);
    }
    log_deinit();
}
Ejemplo n.º 13
0
static void hifi_create_procfs(void)
{
#ifdef ENABLE_HIFI_DEBUG
	hifi_debug_dir = proc_mkdir(HIFIDEBUG_PATH, NULL);
	if (hifi_debug_dir == NULL) {
		loge("Unable to create /proc/hifidebug directory\n");
		return ;
	}
	create_hifidebug_proc_file();

	return ;
#endif
}
Ejemplo n.º 14
0
  int HUServer::hu_aap_tra_send (int retry, byte * buf, int len, int tmo) {                  // Send Transport data: chan,flags,len,type,...
                                                                        // Need to send when starting
    if (iaap_state != hu_STATE_STARTED && iaap_state != hu_STATE_STARTIN) {
      loge ("CHECK: iaap_state: %d (%s)", iaap_state, state_get (iaap_state));
      return (-1);
    }


    int ret = transport->Write(buf, len, tmo);
    if (ret < 0 || ret != len) {
      if (retry == 0) {
        loge ("Error ihu_tra_send() error so stop Transport & AAP  ret: %d  len: %d", ret, len);
		    hu_aap_stop ();

	     }
      return (-1);
    }

    if (ena_log_verbo && ena_log_aap_send)
      logd ("OK ihu_tra_send() ret: %d  len: %d", ret, len);
    return (ret);
  }
Ejemplo n.º 15
0
/**
* @brief   get current is time, and convert to string
*
* @author hankejia
* @date 2012-07-05
* @param NONE
* @return T_pSTR
* @retval if return NULL failed, otherwise the time is string
*/
T_pSTR GetCurTimeStr()
{
	char * pstrTime= NULL;

	struct tm *tnow = GetCurTime();
	if ( NULL == tnow ) {
		loge( "getCurTimeStr::GetCurTime error!\n" );
		return (T_pSTR)NULL;
	}

	pstrTime = (char *)malloc( MAX_TIME_STRING );
	if ( NULL == pstrTime ) {
		loge( "getCurTimeStr::Out of memory!\n" );
		return (T_pSTR)NULL;
	}

	memset( pstrTime, 0, MAX_TIME_STRING );
	sprintf( pstrTime, "%4d,%02d,%02d-%02d_%02d_%02d", 1900 + tnow->tm_year, tnow->tm_mon + 1,
			 tnow->tm_mday, tnow->tm_hour, tnow->tm_min, tnow->tm_sec );

	return pstrTime;
}
Ejemplo n.º 16
0
void ipmmui_buffer_deinit()
{
#if 0
	static FILE *mapfile;
	char filename[FILENAME_LEN];
	int i;
	for (i = 0; i < MAXBUFS; i++) {
		snprintf(filename, sizeof(filename), MAPPATH, i+1, MAPFILE);
		mapfile = fopen(filename, "w");
		if (!mapfile) {
			loge("Cannot open %s for write\n", filename);
			fclose(mapfile);
			continue;
		}
		if (fprintf(mapfile, "0,0") <= 0) {
			loge("Cannot write to %s\n", filename);
		}
		fclose(mapfile);
	}
	bufcount = 0;
#endif
}
Ejemplo n.º 17
0
int process_msg2(struct rpc *r, struct iobuf *buf)
{
    msg_handler_t msg_handler;

    int msg_id = rpc_packet_parse(r);
//    logi("msg_id = %x\n", msg_id);
    if (find_msg_handler(msg_id, &msg_handler) == 0 ) {
        msg_handler.cb(r, buf->addr, buf->len);
    } else {
        loge("no callback for this MSG ID in process_msg\n");
    }
    return 0;
}
Ejemplo n.º 18
0
static irqreturn_t hi3620_intr_handle_digital(int irq, void *dev_id)
{
    struct snd_pcm *pcm = dev_id;
    struct snd_pcm_substream *substream;
    unsigned int irs = hi3620_reg_read(ASP_IRSR);
    irqreturn_t ret = IRQ_NONE;
    unsigned int irs_valid = hi3620_reg_read(ASP_IER) & irs;

    /* clean unexpected interrupt*/
    if (irs != irs_valid) {
        loge("clean unexpected interrupt irs:%x valid:%x\n", irs, irs_valid);
        irs = irs & (~irs_valid);
        hi3620_reg_write(irs, ASP_ICR);
        irs = irs_valid;
        ret = IRQ_HANDLED;
    }

    /* BUSERROR INTERRUPT */
    if (ASP_BUS_ERROR & irs) {
        loge("asp bus error\n");
        hi3620_reg_write(ASP_BUS_ERROR, ASP_ICR);
        ret = IRQ_HANDLED;
    }

    /* PLAYBACK INTERRUPT */
    if ((TX2_DMAS  | TX3_DMAS)& irs) {
        substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
        if (substream) {
            ret = hi3620_intr_handle_digital_pb(substream);
        } else {
            loge("%s : PLAYBACK is NULL\n",__FUNCTION__);
            hi3620_reg_write((TX2_DMAS  | TX3_DMAS) & irs, ASP_ICR);
            ret = IRQ_HANDLED;
        }
    }

    return ret;
}
Ejemplo n.º 19
0
int register_msg_proc(msg_handler_t *handler)
{
    int i;
    int msg_id_registered  = 0;
    int msg_slot = -1;
    uint32_t msg_id;

    if (!handler) {
        loge("Cannot register null msg proc \n");
        return -1;
    }

    msg_id = handler->msg_id;

    for (i=0; i < message_map_registered; i++) {
        if (message_map[i].msg_id == msg_id) {
            loge("overwrite existing msg proc for msg_id %d \n", msg_id);
            msg_id_registered = 1;
            msg_slot = i;
            break;
        }
    }

    if ((!msg_id_registered)) {
        if ((message_map_registered == MAX_MESSAGES_IN_MAP)) {
            loge("too many msg proc registered \n");
            return -1;
        }
        //increase the count
        msg_slot = message_map_registered;
        message_map_registered++;
    }

    //if the handler registered is NULL, then just fill NULL handler
    message_map[msg_slot] = *handler;

    return 0;
}
Ejemplo n.º 20
0
static int _mq_accept(struct ipc *ipc)
{//for server
    struct mq_ctx *ctx = ipc->ctx;
    ctx->parent = ipc;
    struct mq_attr attr;
    attr.mq_flags = 0;
    attr.mq_maxmsg = MQ_MAXMSG;
    attr.mq_msgsize = MQ_MSGSIZE;
    attr.mq_curmsgs = 0;

    sem_wait(&ctx->sem);

    ctx->mq_wr = mq_open(ctx->mq_wr_name, O_WRONLY, S_IRWXU | S_IRWXG, &attr);
    if (ctx->mq_wr < 0) {
        loge("mq_open %s failed: %d:%s\n", ctx->mq_wr_name, errno, strerror(errno));
        return -1;
    }
    if (0 > _mq_send(ipc, ctx->mq_wr_name, strlen(ctx->mq_wr_name))) {
        loge("_mq_send failed!\n");
        return -1;
    }
    return 0;
}
Ejemplo n.º 21
0
/**
* @brief   get current is time
*
* @author hankejia
* @date 2012-07-05
* @param NONE
* @return struct tm *
* @retval if return NULL failed, otherwise the current time
*/
struct tm * GetCurTime()
{
	time_t now = { 0 };
	now = time(0);
//	char * pstrTime= NULL;

	struct tm *tnow = localtime(&now);
	if ( NULL == tnow ) {
		loge( "GetCurTime::get local time error!\n" );
		return NULL;
	}

	return tnow;
}
Ejemplo n.º 22
0
Archivo: rpcd.c Proyecto: gozfree/src
void on_connect(int fd, void *arg)
{
    int afd;
    uint32_t ip;
    uint16_t port;
    struct rpcd *rpcd = (struct rpcd *)arg;

    afd = skt_accept(fd, &ip, &port);
    if (afd == -1) {
        loge("skt_accept failed: %d\n", errno);
        return;
    }
    rpc_connect_create(rpcd, afd, ip, port);
}
Ejemplo n.º 23
0
 IHUAnyThreadInterface::HUThreadCommand* HUServer::hu_pop_command()
 {
   IHUAnyThreadInterface::HUThreadCommand* ptr = nullptr;
   int ret = read(command_read_fd, &ptr, sizeof(ptr));
   if (ret < 0)
   {
     loge("hu_pop_command error %d", ret);
   }
   else if (ret == sizeof(ptr))
   {
     return ptr;
   }
   return nullptr;
 }
Ejemplo n.º 24
0
  int iusb_control_transfer (libusb_device_handle * usb_hndl, uint8_t req_type, uint8_t req_val, uint16_t val, uint16_t idx, byte * buf, uint16_t len, unsigned int tmo) {

    //if (ena_log_verbo)
      logd ("Start usb_hndl: %p  req_type: %d  req_val: %d  val: %d  idx: %d  buf: %p  len: %d  tmo: %d", usb_hndl, req_type, req_val, val, idx, buf, len, tmo);

    int usb_err = libusb_control_transfer (usb_hndl, req_type, req_val, val, idx, buf, len, tmo);
    if (usb_err < 0) {
      loge ("Error usb_err: %d (%s)  usb_hndl: %p  req_type: %d  req_val: %d  val: %d  idx: %d  buf: %p  len: %d  tmo: %d", usb_err, iusb_error_get (usb_err), usb_hndl, req_type, req_val, val, idx, buf, len, tmo);
      return (-1);
    }
    //if (ena_log_verbo)
      logd ("Done usb_err: %d  usb_hndl: %p  req_type: %d  req_val: %d  val: %d  idx: %d  buf: %p  len: %d  tmo: %d", usb_err, usb_hndl, req_type, req_val, val, idx, buf, len, tmo);
    return (0);
  }
Ejemplo n.º 25
0
static int _mq_notify_update(struct mq_ctx *ctx, mq_notify_cb cb)
{
    struct sigevent sv;
    memset(&sv, 0, sizeof(sv));
    sv.sigev_notify = SIGEV_THREAD;
    sv.sigev_notify_function = cb;
    sv.sigev_notify_attributes = NULL;
    sv.sigev_value.sival_ptr = ctx;
    if (mq_notify(ctx->mq_rd, &sv) == -1) {//vagrind
        loge("mq_notify failed %d: %s\n", errno, strerror(errno));
        return -1;
    }
    return 0;
}
/*****************************************************************************
 函 数 名  : hifi_dsp_get_input_param_free
 功能描述  : 释放分配的内核空间
 输入参数  : krn_para_addr,待释放的内核空间地址
 输出参数  : 无
 返 回 值  : OK / ERROR
 调用函数  :
 被调函数  :

 修改历史	   :
  1.日	  期   : 2012年3月26日
	作	  者   : s00212991
	修改内容   : 新生成函数

*****************************************************************************/
static void hifi_dsp_get_input_param_free(void **krn_para_addr)
{
	IN_FUNCTION;

	if (*krn_para_addr != NULL) {
		kfree(*krn_para_addr);
		*krn_para_addr = NULL;
	} else {
		loge("krn_para_addr to free is NULL.\n");
	}

	OUT_FUNCTION;
	return;
}
Ejemplo n.º 27
0
static void test_file_noname(void)
{
    int i;
    log_init(LOG_FILE, NULL);
    log_set_split_size(1*1024*1024);
    for (i = 0; i < 100; i++) {
        loge("debug msg i = %d\n", i);
        logw("debug msg\n");
        logi("debug msg\n");
        logd("debug msg\n");
        logd("debug msg\n");
    }
    log_deinit();
}
Ejemplo n.º 28
0
static create_aw_omx_component omx_core_load_cmp_library(int idx)
{
	create_aw_omx_component fn_ptr = NULL;

	pthread_mutex_lock(&g_mutex_core_info);


	if(core[idx].so_lib_handle == NULL)
	{
		logi("Dynamically Loading the library : %s\n",core[idx].so_lib_name);

		core[idx].so_lib_handle = dlopen(core[idx].so_lib_name, RTLD_NOW);
	}

	if(core[idx].so_lib_handle)
	{
		if(core[idx].fn_ptr == NULL)
		{
			core[idx].fn_ptr = (create_aw_omx_component)dlsym(core[idx].so_lib_handle, "get_omx_component_factory_fn");

			if(core[idx].fn_ptr == NULL)
			{
				loge("Error: Library %s incompatible as QCOM OMX component loader - %s\n", core[idx].so_lib_name, dlerror());
			}
		}
	}
	else
	{
		loge("Error: Couldn't load %s: %s\n",core[idx].so_lib_name,dlerror());
	}

	fn_ptr = core[idx].fn_ptr;

	pthread_mutex_unlock(&g_mutex_core_info);

	return fn_ptr;
}
Ejemplo n.º 29
0
static void *_mq_init(const char *name, enum ipc_role role)
{
    struct mq_attr attr;
    struct mq_ctx *ctx = CALLOC(1, struct mq_ctx);
    if (!ctx) {
        loge("malloc failed!\n");
        return NULL;
    }
    attr.mq_flags = 0;
    attr.mq_maxmsg = MQ_MAXMSG;
    attr.mq_msgsize = MQ_MSGSIZE;
    attr.mq_curmsgs = 0;
    int rflag = O_RDWR | O_EXCL | O_CREAT | O_NONBLOCK;
    mq_unlink(name);
    ctx->mq_rd = mq_open(name, rflag, S_IRWXU | S_IRWXG, &attr);
    if (ctx->mq_rd < 0) {
        loge("mq_open %s failed %d:%s\n", name, errno, strerror(errno));
        return NULL;
    }

    ctx->role = role;
    strncpy(ctx->mq_rd_name, name, sizeof(ctx->mq_rd_name));
    if (-1 == sem_init(&ctx->sem, 0, 0)) {
        loge("sem_init failed %d:%s\n", errno, strerror(errno));
        return NULL;
    }
    _mq_recv_buf = calloc(1, MAX_IPC_MESSAGE_SIZE);
    if (!_mq_recv_buf) {
        loge("malloc failed!\n");
        return NULL;
    }
    if (-1 == _mq_notify_update(ctx, on_connect)) {
        loge("_mq_notify_update failed!\n");
        return NULL;
    }
    return ctx;
}
Ejemplo n.º 30
0
static ssize_t hifi_dsp_debug_level_store(struct file *file, const char __user *buf,
		size_t size, loff_t *data)
{
	ssize_t ret = 0;
	char level_str[MAX_LEVEL_STR_LEN] = {0};
	loff_t pos = 0;

	if (NULL == buf) {
		loge("Input param buf is invalid\n");
		return -EINVAL;
	}

	ret = simple_write_to_buffer(level_str, MAX_LEVEL_STR_LEN - 1 , &pos, buf, size);
	if (ret != size) {
		loge("Input param buf read error, return value: %zd\n", ret);
		return -EINVAL;
	}

	if (!strchr("kdiwe", level_str[0])) {
		loge("Input param buf is error(valid: d,i,w,e): %s.\n", level_str);
		return -EINVAL;
	}
	if (level_str[1] != '\n') {
		loge("Input param buf is error, last char is not \\n .\n");
		return -EINVAL;
	}

	if (strchr("k", level_str[0])) {
		hifi_kill_dsp();
		return size;
	}

	g_om_data.dsp_debug_level = hifi_get_debug_level_num(level_str[0]);
	hifi_set_dsp_debug_level(g_om_data.dsp_debug_level);

	return size;
}