Exemple #1
0
ssize_t rmparser_write(struct file *file,
                       struct stream_buf_s *vbuf,
                       struct stream_buf_s *abuf,
                       const char __user *buf, size_t count)
{
    s32 r;
    stream_port_t *port = (stream_port_t *)file->private_data;
    size_t towrite=count;
    if ((stbuf_space(vbuf) < count) ||
        (stbuf_space(abuf) < count)) {
        if (file->f_flags & O_NONBLOCK) {
            towrite=min(stbuf_space(vbuf), stbuf_space(abuf));
	     if(towrite<1024)/*? can write small?*/
	         return -EAGAIN;
        }else{
	        if ((port->flag & PORT_FLAG_VID)
	            && (stbuf_space(vbuf) < count)) {
	            r = stbuf_wait_space(vbuf, count);
	            if (r < 0) {
	                return r;
	            }
	        }
	        if ((port->flag & PORT_FLAG_AID)
	            && (stbuf_space(abuf) < count)) {
	            r = stbuf_wait_space(abuf, count);
	            if (r < 0) {
	                return r;
	            }
	        }
        }
    }
    towrite=min(towrite,count);
    return _rmparser_write(buf, towrite);
}
ssize_t esparser_write(struct file *file,
                       struct stream_buf_s *stbuf,
                       const char __user *buf, size_t count)
{
    s32 r;
    u32 len = count;
    if (buf == NULL || count == 0) {
        return -EINVAL;
    }

    if (stbuf_space(stbuf) < count) {
        if (file->f_flags & O_NONBLOCK) {
            return -EAGAIN;
        }

        len = min(stbuf_size(stbuf) / 8, len);

        if (stbuf_space(stbuf) < len) {
            r = stbuf_wait_space(stbuf, len);
            if (r < 0) {
                return r;
            }
        }
    }
    mutex_lock(&esparser_mutex);
    r = _esparser_write(buf, len, stbuf->type);
    mutex_unlock(&esparser_mutex);

    return r;
}
ssize_t esparser_write(struct file *file,
                       struct stream_buf_s *stbuf,
                       const char __user *buf, size_t count)
{
    s32 r;
    u32 len = count;
    if (buf == NULL || count == 0) {
        return -EINVAL;
    }

    if (stbuf->type!=BUF_TYPE_SUBTITLE && /*subtitle have no level to check,*/
		stbuf_space(stbuf) < count) {
        if (file->f_flags & O_NONBLOCK) {
		len = stbuf_space(stbuf) ;	
		if(len<256)//<1k.do eagain,
			return -EAGAIN;
        }else{
	        len = min(stbuf_canusesize(stbuf) / 8, len);

	        if (stbuf_space(stbuf) < len) {
	            r = stbuf_wait_space(stbuf, len);
	            if (r < 0) {
	                return r;
	            }
	        }
	}
    }
    len = min(len, count);
    mutex_lock(&esparser_mutex);
    r = _esparser_write(buf, len, stbuf->type);
    mutex_unlock(&esparser_mutex);

    return r;
}
Exemple #4
0
ssize_t tsdemux_write(struct file *file,
                      struct stream_buf_s *vbuf,
                      struct stream_buf_s *abuf,
                      const char __user *buf, size_t count)
{
    s32 r;
    stream_port_t *port = (stream_port_t *)file->private_data;
    size_t wait_size, write_size;

    if ((stbuf_space(vbuf) < count) ||
        (stbuf_space(abuf) < count)) {
        if (file->f_flags & O_NONBLOCK) {
	      write_size=min(stbuf_space(vbuf), stbuf_space(abuf));
	      if(write_size<=188)/*have 188 bytes,write now., */
			return -EAGAIN;
        }else{
	        wait_size = min(stbuf_canusesize(vbuf) / 8, stbuf_canusesize(abuf) / 4);
	        if ((port->flag & PORT_FLAG_VID)
	            && (stbuf_space(vbuf) < wait_size)) {
	            r = stbuf_wait_space(vbuf, wait_size);

	            if (r < 0) {
			//printk("write no space--- no space,%d--%d,r-%d\n",stbuf_space(vbuf),stbuf_space(abuf),r);
	                return r;
	            }
	        }

	        if ((port->flag & PORT_FLAG_AID)
	            && (stbuf_space(abuf) < wait_size)) {
	            r = stbuf_wait_space(abuf, wait_size);

	            if (r < 0) {
			//printk("write no stbuf_wait_space--- no space,%d--%d,r-%d\n",stbuf_space(vbuf),stbuf_space(abuf),r);
	                return r;
	            }
	        }
        }
    }
	vbuf->last_write_jiffies64=jiffies_64;
	abuf->last_write_jiffies64=jiffies_64;
	write_size=limited_delay_check(file,vbuf,abuf,buf,count);
    if (write_size > 0) {
        return _tsdemux_write(buf, write_size);
    } else {
        return -EAGAIN;
    }
}
Exemple #5
0
ssize_t drm_write(struct file *file,
                  struct stream_buf_s *stbuf,
                  const char __user *buf, size_t count)

{
    s32 r;
    u32 len ;
    u32 realcount,totalcount;
    u32 re_count = count;
    u32 havewritebytes =0;
    u32 leftcount = 0;

    drminfo_t tmpmm;
    drminfo_t *drm=&tmpmm;
    u32 res=0;
    int isphybuf=0;

    if (buf == NULL || count == 0) {
        return -EINVAL;
    }
	
    res = copy_from_user(drm, buf, sizeof(drminfo_t));
    if (res) {
        printk("drm kmalloc failed res[%d]\n",res);	
        return -EFAULT;
    }

    if (drm->drm_flag == TYPE_DRMINFO && (drm->drm_hasesdata == 0)) {
        realcount = drm->drm_pktsize;  //buf only has drminfo not have esdata;
        buf = (char *)drm->drm_phy;
        isphybuf =1;
        //DRM_PRNT("drm_get_rawdata onlydrminfo drm->drm_hasesdata[0x%x] stbuf->type %d buf[0x%x]\n",drm->drm_hasesdata,stbuf->type,buf);
    } else if (drm->drm_hasesdata == 1) {//buf is drminfo+es;
        realcount = drm->drm_pktsize;
        buf = buf + sizeof(drminfo_t);
        isphybuf =0;
        //DRM_PRNT("drm_get_rawdata drminfo+es drm->drm_hasesdata[0x%x] stbuf->type %d\n",drm->drm_hasesdata,stbuf->type);	
    } else {//buf is hwhead;
        realcount = count;
        isphybuf =0;
	//DRM_PRNT("drm_get_rawdata drm->drm_hasesdata[0x%x] len[%d] count[%d] realcout[%d]\n",drm->drm_hasesdata,len,count,realcount);
    }
	
    len = realcount ;
    count = realcount;
    totalcount = realcount;

    while (len > 0) {
        if (stbuf->type!=BUF_TYPE_SUBTITLE && stbuf_space(stbuf) < count) {
            len = min(stbuf_canusesize(stbuf) / 8, len);
            if (stbuf_space(stbuf) < len) {
            r = stbuf_wait_space(stbuf, len);
            if ((r < leftcount) && (leftcount > 0)) { // write part data , not allow return ;
                continue;
            }else if ((r < 0)&&(leftcount==0)){//buf is full;
                    return -EAGAIN;
	            }
            }
    	}
    	len = min(len, count);

    	mutex_lock(&esparser_mutex);

        r = _esparser_write(buf,len,stbuf->type,isphybuf);
        if (r < 0){
            printk("drm_write _esparser_write failed [%d]\n",r);
            return r;
        }
        havewritebytes += r;
        leftcount = totalcount - havewritebytes;
        if (havewritebytes == totalcount){

            mutex_unlock(&esparser_mutex);
            break;//write ok;
        }else if ((len > 0 )&& (havewritebytes < totalcount)){
            DRM_PRNT("writeagain havewritebytes[%d] wantwrite[%d] totalcount[%d] realcount[%d] \n",
                              havewritebytes,len,totalcount,realcount);
            len = len-r;//write again;
            buf=buf+r;
        }else{
            printk("###else havewritebytes[%d] wantwrite[%d] totalcount[%d] realcount[%d]\n",
                havewritebytes,len,totalcount,realcount);
        }
        mutex_unlock(&esparser_mutex);
    }

    return re_count;
}