Ejemplo n.º 1
0
int Tuner_ReadRegister(struct gx1001_state *state, unsigned char *buffer,unsigned char bDatalength)
{
    INT32U nRetCode = AM_SUCCESS;
    struct i2c_msg msg;

    if(buffer == 0 || bDatalength == 0)
    {
        AM_TRACE("dtc70700 read register parameter error !!\n");
        return 0;
    }

    //nRetCode = AM_I2C_WriteRead(tuner_i2chandle, buffer, 0, bDatalength);
    memset(&msg, 0, sizeof(msg));
    msg.addr = (state->config.tuner_addr);
    msg.flags |=  I2C_M_RD;  //write  I2C_M_RD=0x01
    msg.len = bDatalength;
    msg.buf = buffer;

    nRetCode = i2c_transfer(state->i2c, &msg, 1);

    //nRetCode = AM_I2C_WriteRead(I2C_TUNER_ADDRESS, buffer, 0, bDatalength);
    if(nRetCode != 1)
    {
        AM_TRACE("gx1001_writeregister reg  failure!\n");
        return 0;
    }
    return 1;   //success
}
Ejemplo n.º 2
0
int atsc_convert_code_from_utf16_to_utf8(char *in_code,int in_len,char *out_code,int *out_len)
{
    iconv_t handle;
    char **pin=&in_code;
    char **pout=&out_code;

	if (!in_code || !out_code || !out_len || in_len <= 0 || *out_len <= 0)
		return AM_FAILURE;

	memset(out_code,0,*out_len);

    handle=iconv_open("utf-8","utf-16");

    if (handle == (iconv_t)-1)
    {
    	AM_TRACE("convert_code_to_utf8 iconv_open err");
    	return -1;
    }

    if(iconv(handle,pin,(size_t *)&in_len,pout,(size_t *)out_len) == (size_t)-1)
    {
        AM_TRACE("convert_code_to_utf8 iconv err: %s, in_len %d, out_len %d", strerror(errno), in_len, *out_len);
        iconv_close(handle);
        return -1;
    }

    return iconv_close(handle);
}
Ejemplo n.º 3
0
int Tuner_Writeregister(struct gx1001_state *state, unsigned char* buffer,unsigned char bDataLength)
{
    INT32U nRetCode = AM_SUCCESS;
    struct i2c_msg msg;

    if(buffer == 0 || bDataLength == 0)
    {
        AM_TRACE("dtc70700 write register parameter error !!\n");
        return 0;
    }

    memset(&msg, 0, sizeof(msg));
    msg.addr = (state->config.tuner_addr);
    msg.flags &=  ~I2C_M_RD;  //write  I2C_M_RD=0x01
    msg.len = bDataLength;
    msg.buf = buffer;
    //pr_dbg("gx1001 write dev addr %d,buf[0]=%d\r\n",msg.addr,buffer[0]);
    nRetCode = i2c_transfer(state->i2c, &msg, 1);

    //nRetCode = AM_I2C_Write(I2C_TUNER_ADDRESS, buffer, bDataLength);

    if(nRetCode != 1)
    {
        AM_TRACE("gx1001_writeregister reg failure!\n");
        return 0;
    }
    return 1;   //success
}
Ejemplo n.º 4
0
int gx1001_readregister(struct gx1001_state *state, unsigned char regaddr, unsigned char* data, unsigned char length)
{
    INT32U nRetCode = AM_SUCCESS;
    struct i2c_msg msg;

    if(data == 0 || length == 0)
    {
        AM_TRACE("gx1001 read register parameter error !!\n");
        return 0;
    }

    gx1001_set_addr(state, regaddr) ; //set reg address first

    //read real data
    memset(&msg, 0, sizeof(msg));
    msg.addr = (state->config.demod_addr);
    msg.flags |=  I2C_M_RD;  //write  I2C_M_RD=0x01
    msg.len = length;
    msg.buf = data;

    nRetCode = i2c_transfer(state->i2c, &msg, 1);

    if(nRetCode != 1)
    {
        AM_TRACE("gx1001_readregister reg 0x%x failure!\n",regaddr);
        return 0;
    }
    return 1;

}
Ejemplo n.º 5
0
static atsc_service_location_dr_t* atsc_DecodeServiceLocationDr(atsc_descriptor_t * p_descriptor)
{
	atsc_service_location_dr_t * p_decoded;
	int i;

	/* Check the tag */
	if(p_descriptor->i_tag != 0xa1)
	{
		AM_TRACE("dr_service_location decoder,bad tag (0x%x)", p_descriptor->i_tag);
		return NULL;
	}

	/* Don't decode twice */
	if(p_descriptor->p_decoded)
		return p_descriptor->p_decoded;

	/* Allocate memory */
	p_decoded = (atsc_service_location_dr_t*)malloc(sizeof(atsc_service_location_dr_t));
	if(!p_decoded)
	{
		AM_TRACE("dr_service_location decoder,out of memory");
		return NULL;
	}

	/* Decode data and check the length */
	if((p_descriptor->i_length < 3))
	{
		AM_TRACE("dr_service_location decoder,bad length (%d)",
				         p_descriptor->i_length);
		free(p_decoded);
		return NULL;
	}
	
	p_decoded->i_elem_count = p_descriptor->p_data[2];
	if (p_decoded->i_elem_count > (int)AM_ARRAY_SIZE(p_decoded->elem))
		p_decoded->i_elem_count = AM_ARRAY_SIZE(p_decoded->elem);
	p_decoded->i_pcr_pid = ((uint16_t)(p_descriptor->p_data[0] & 0x1f) << 8) | p_descriptor->p_data[1];
	i = 0;
	while( i < p_decoded->i_elem_count) 
	{
		
		p_decoded->elem[i].i_stream_type = p_descriptor->p_data[i*6+3];
		p_decoded->elem[i].i_pid = ((uint16_t)(p_descriptor->p_data[i*6+4] & 0x1f) << 8) | p_descriptor->p_data[i*6+5];
		p_decoded->elem[i].iso_639_code[0] = p_descriptor->p_data[i*6+6];
		p_decoded->elem[i].iso_639_code[1] = p_descriptor->p_data[i*6+7];
		p_decoded->elem[i].iso_639_code[2] = p_descriptor->p_data[i*6+8];
		AM_TRACE("ServiceLocationDesc: stream_type %d, pid %d", p_decoded->elem[i].i_stream_type, p_decoded->elem[i].i_pid);
		i++;
	}
	p_descriptor->p_decoded = (void*)p_decoded;

	return p_decoded;
}
Ejemplo n.º 6
0
INT8U *content_advisory_desc_parse(INT8U *ptrData)
{
#if 0
	INT32U i;
	INT8U rating_region_count;
	INT8U rating_desc_length;
	INT8U rating_dimentions;
//	INT8U rating_region; 
	INT8U *ptr = ptrData;
	INT8U *str;
	
	rating_region_count  = RatingRegionCount(ptr);
	ptr += 3;
	for(i=0; i<rating_region_count; i++)
	{
		ptr++;
		rating_dimentions = *ptr;
		ptr += rating_dimentions * 2;

		rating_desc_length = *ptr;
		// test 
		ptr++;
		str = MemMalloc(rating_desc_length);
		parse_multiple_string(ptr, str);
		ptr += rating_desc_length;
		AM_TRACE("%s\n", str);
	}
#endif
	return NULL;
}
Ejemplo n.º 7
0
void atsc_psip_dump_mgt_info(mgt_section_info_t *info)
{
#ifndef __ROM_
    mgt_section_info_t *tmp = info;
    com_table_info_t *table_info = NULL;
    INT8U i = 0;
    
    if(info)
    {
        AM_TRACE("\r\n============= MGT INFO =============\r\n");

        while(tmp)
        {
            AM_TRACE("version_number: 0x%02x\r\n", tmp->version_number);
            AM_TRACE("tables_defined: %d\r\n", tmp->tables_defined); 
	     AM_TRACE("is_cable: %d\r\n", tmp->is_cable); 	
	     table_info = tmp->com_table_info;
            while(table_info)
            {
                AM_TRACE("table type: 0x%04x table type pid: 0x%04x\r\n", table_info->table_type, table_info->table_type_pid);
				
		  table_info = table_info->p_next;
            }
            
            tmp = tmp->p_next;
        }

        AM_TRACE("\r\n=============== END ================\r\n");
    }
#endif
    return ;
}
Ejemplo n.º 8
0
int gx1001_set_addr(struct gx1001_state *state, unsigned char regaddr)
{
    INT32U nRetCode = AM_SUCCESS;
    INT8U buffer[MAX_REG_VALUE_LEN+1];
    struct i2c_msg msg;

    buffer[0] = regaddr;
    memset(&msg, 0, sizeof(msg));
    msg.addr = (state->config.demod_addr);
    msg.flags &=  ~I2C_M_RD;  //write  I2C_M_RD=0x01
    msg.len = 1;
    msg.buf = buffer;
    //pr_dbg("gx1001 write dev addr %d,buf[0]=%d,msg_len=%d\r\n",msg.addr,buffer[0],msg.len);
    nRetCode = i2c_transfer(state->i2c, &msg, 1);

    if(nRetCode != 1)
    {
        AM_TRACE("gx1001_writeregister reg 0x%x failure,ret %d!\n",regaddr,nRetCode);
        return 0;
    }
    return 1;   //success
}
Ejemplo n.º 9
0
void atsc_psip_dump_vct_info(vct_section_info_t *info)
{
#ifndef __ROM_
	vct_section_info_t *tmp = info;

	INT8U i = 0;

	if(info)
	{
		AM_TRACE("\r\n============= VCT INFO =============\r\n");

		while(tmp)
		{ 
			vct_channel_info_t *chan_info = tmp->vct_chan_info;
			AM_TRACE("transport_stream_id: 0x%04x\r\n", tmp->transport_stream_id);
			AM_TRACE("version_number: 0x%02x\r\n", tmp->version_number);
			AM_TRACE("num_channels_in_section: %d\r\n", tmp->num_channels_in_section); 

			while(chan_info)
			{
				
				AM_TRACE("    %d-%d %s program number:%d source id %d\n", 
					chan_info->major_channel_number,
					chan_info->minor_channel_number,
					chan_info->short_name,
					chan_info->program_number,
					chan_info->source_id);
				
				chan_info = chan_info->p_next;
			}

			tmp = tmp->p_next;
		}

		AM_TRACE("\r\n=============== END ================\r\n");
	}
#endif
    return ;
}
Ejemplo n.º 10
0
INT32S atsc_psip_parse_mgt(INT8U* data, INT32U length, mgt_section_info_t *info)
{
    INT8U *sect_data = data;
    INT32U sect_len = length;
    mgt_section_info_t *sect_info = info;
    mgt_section_header_t *sect_head = NULL;
    mgt_table_info_t *table_info = NULL;
    com_table_info_t *tmp_table_info = NULL;
    INT16U tables_num = 0;
    INT8U *ptr = NULL;

    if(data && length && info)
    {
        while(sect_len > 0)
        {
            sect_head = (mgt_section_header_t*)sect_data;
            
            if(sect_head->table_id != ATSC_PSIP_MGT_TID)
            {
                sect_len -= 3;
                sect_len -= MAKE_SHORT_HL(sect_head->section_length);

                sect_data += 3;
                sect_data += MAKE_SHORT_HL(sect_head->section_length);

                continue;
            }

            if(NULL == sect_info)
            {
                sect_info = new_mgt_section_info();
                if(sect_info == NULL)
                {
                    AM_TRACE("[%s] error out of memory !!\n", __FUNC__);
                    break;
                }
                else
                {
                    add_mgt_section_info(&info, sect_info);
                }
            }
            
            sect_info->version_number = sect_head->version_number;
	     sect_info->tables_defined = MAKE_SHORT_HL(sect_head->tables_defined);

            ptr = &sect_data[MGT_SECTION_HEADER_LEN];
            tables_num = sect_info->tables_defined;
            while(tables_num > 0)
            {
				table_info = (mgt_table_info_t *)ptr;
				tmp_table_info = (com_table_info_t*)AMMem_malloc(sizeof(com_table_info_t));
				if(tmp_table_info)
				{
					tmp_table_info->table_type = MAKE_SHORT_HL(table_info->table_type);
					tmp_table_info->table_type_pid = MAKE_SHORT_HL(table_info->table_type_pid);
					tmp_table_info->table_type_version = table_info->table_type_version;
					tmp_table_info->desc = NULL;
					tmp_table_info->p_next = NULL;
						   

					if ((tmp_table_info->table_type == 0) | (tmp_table_info->table_type == 1))
					{
					sect_info->is_cable = 0;
					}
					else if ((tmp_table_info->table_type == 2) | (tmp_table_info->table_type == 3))
					{
					sect_info->is_cable = 1;
					}
					else 
					{
					// do nothing
					}
					add_mgt_table_info(&sect_info->com_table_info, tmp_table_info);
				}
				else
				{
					AM_TRACE("[%s] error out of memory !!\n", __FUNC__);
					break;
				} 

				ptr += 11 + MAKE_SHORT_HL(table_info->table_type_desc_len);
				tables_num--;
            }

            sect_len -= 3;
            sect_len -= MAKE_SHORT_HL(sect_head->section_length);

            sect_data += 3;
            sect_data += MAKE_SHORT_HL(sect_head->section_length);

            sect_info = sect_info->p_next;
        }

        return 0;
    }

    return -1;
}
Ejemplo n.º 11
0
void atsc_decode_multiple_string_structure(INT8U *buffer_data, atsc_multiple_string_t *out)
{
	unsigned char *p;
	unsigned char number_strings;
	unsigned char i,j,k;
	unsigned long ISO_639_language_code;
	unsigned char number_segments;
	unsigned char compression_type;
	unsigned char mode;
	unsigned char number_bytes;
	unsigned char *tmp_buff;
	int str_bytes, left_bytes;
	unsigned char utf16_buf[2*256]; 

	if (!buffer_data || !out)
		return;
		
	p = buffer_data;
	
	number_strings = p[0];
	if(0 == number_strings)
	{
		return;
	}
	p++;
	memset(out, 0, sizeof(atsc_multiple_string_t));
	
	if (number_strings > (int)AM_ARRAY_SIZE(out->string))
		number_strings = AM_ARRAY_SIZE(out->string);
	out->i_string_count = number_strings;	
	for (i=0; i< number_strings; i++) 
	{
		out->string[i].iso_639_code[0] = p[0];
		out->string[i].iso_639_code[1] = p[1];
		out->string[i].iso_639_code[2] = p[2];
		
		/*AM_TRACE("multiple_string_structure-->lang '%c%c%c'", p[0], p[1], p[2]);*/
		
		number_segments = p[3];
		
		if(0 == number_segments)
		{
			p += 4;
			continue;
		}
		
		p +=4;
		tmp_buff = out->string[i].string;
		for (j=0; j< number_segments; j++) 
		{
			compression_type = p[0];	
			mode = p[1];

			number_bytes = p[2];

			if(0 == number_bytes)
			{
				p += 3;
				continue;
			}
			left_bytes = out->string[i].string+sizeof(out->string[i].string)-tmp_buff; /* left bytes in out->string[i].string */
			if (left_bytes <= 0)
			{
				AM_TRACE("no more space for new segment of this string");
				break;
			}
			p+=3;
			/*AM_TRACE("mode %d, ct %d", mode, compression_type);*/
			if ((mode == 0) && ((compression_type == 1) | (compression_type == 2)))
			{
				/* tmp_buff may overflow here, as we cannot get the out length,
				 * we make the out->string[i].string large enough to avoid this bug 
				 */
				str_bytes = atsc_huffman_to_string(tmp_buff, p, number_bytes, compression_type-1);
				tmp_buff += str_bytes;
			}
			else if ((mode>=0x0 && mode <=0x7) || (mode>=0x9 && mode <=0x10) ||
				(mode>=0x20 && mode <=0x27) || (mode>=0x30 && mode <=0x33) || mode == 0x3F)
			{
				if (mode != 0x3F)
				{
					for (k=0; k<number_bytes; k++)
					{
						utf16_buf[2*k] = mode;
						utf16_buf[2*k+1] = p[k];
					}
				}
				else
				{
					/* UTF16 form now*/
					memcpy(utf16_buf, p, number_bytes);
				}
				/* convert utf16 to utf8 */
				str_bytes = left_bytes;
				atsc_convert_code_from_utf16_to_utf8((char*)utf16_buf, (mode==0x3F)?number_bytes:2*number_bytes, (char*)tmp_buff, &str_bytes);
				tmp_buff += str_bytes;
			}
			else if (mode == 0x3E)
			{
				/* SCSU */
				memcpy(tmp_buff, p, number_bytes);
				tmp_buff += number_bytes;
			}
			else
			{
				AM_TRACE("multiple_string_structure: unsupported mode 0x%x, compression_type %d",
					mode, compression_type);
				tmp_buff += number_bytes;
			}
			p+=number_bytes;
		}
	}	
}
Ejemplo n.º 12
0
static atsc_content_advisory_dr_t* atsc_DecodeContentAdvisoryDr(atsc_descriptor_t * p_descriptor)
{
	atsc_content_advisory_dr_t * p_decoded;
	int i, j;
	uint8_t *ptr;

	/* Check the tag */
	if(p_descriptor->i_tag != 0x87)
	{
		AM_TRACE("dr_content_advisory decoder,bad tag (0x%x)", p_descriptor->i_tag);

		return NULL;
	}

	/* Don't decode twice */
	if(p_descriptor->p_decoded)
		return p_descriptor->p_decoded;

	/* Allocate memory */
	p_decoded = (atsc_content_advisory_dr_t*)malloc(sizeof(atsc_content_advisory_dr_t));
	if(!p_decoded)
	{
		AM_TRACE("dr_content_advisory decoder,out of memory");
		return NULL;
	}

	/* Decode data and check the length */
	if((p_descriptor->i_length < 1))
	{
		AM_TRACE("dr_content_advisory decoder,bad length (%d)",
				         p_descriptor->i_length);
		free(p_decoded);
		return NULL;
	}
	
	p_decoded->i_region_count = p_descriptor->p_data[0] & 0x3f;
	i = 0;
	ptr = p_descriptor->p_data + 1;
	/*AM_TRACE("region count %d", p_decoded->i_region_count);*/
	while( i < p_decoded->i_region_count) 
	{
		/* to this region */
		p_decoded->region[i].i_rating_region = ptr[0];
		p_decoded->region[i].i_dimension_count = ptr[1];
		/*AM_TRACE("dimension count %d", p_decoded->region[i].i_dimension_count);*/
		ptr += 2;
		
		if (p_decoded->region[i].i_dimension_count > (int)AM_ARRAY_SIZE(p_decoded->region[i].dimension))
			p_decoded->region[i].i_dimension_count = AM_ARRAY_SIZE(p_decoded->region[i].dimension);
		/* dimensions */	
		j = 0;
		while (j < p_decoded->region[i].i_dimension_count)
		{
			p_decoded->region[i].dimension[j].i_dimension_j = ptr[0];
			p_decoded->region[i].dimension[j].i_rating_value = ptr[1]&0x0f;
			
			/*AM_TRACE("dimension_j/value: %d/%d",
				p_decoded->region[i].dimension[j].i_dimension_j,
				p_decoded->region[i].dimension[j].i_rating_value);*/
			ptr += 2;
			j++;
		}
		
		/* decode rating description */
		if (ptr[0] > 0)
			atsc_decode_multiple_string_structure(ptr+1, &p_decoded->region[i].rating_description);
		else
			memset(&p_decoded->region[i].rating_description, 0, sizeof(p_decoded->region[i].rating_description));
			
		/*AM_TRACE("ContentAdvisoryDesc: region %d, description(lang0 '%c%c%c':%s)", 
			p_decoded->region[i].i_rating_region,
			p_decoded->region[i].rating_description.string[0].iso_639_code[0],
			p_decoded->region[i].rating_description.string[0].iso_639_code[1],
			p_decoded->region[i].rating_description.string[0].iso_639_code[2],
			p_decoded->region[i].rating_description.string[0].string);*/
		ptr += ptr[0] + 1;
		i++;
	}
	p_descriptor->p_decoded = (void*)p_decoded;

	return p_decoded;
}
Ejemplo n.º 13
0
INT32S atsc_psip_parse_rrt(INT8U* data, INT32U length, rrt_section_info_t *info)
{
	INT8U *sect_data = data;
	INT32U sect_len = length;
	rrt_section_info_t *sect_info = info;
	rrt_section_header_t *sect_head = NULL;
	rrt_dimensions_info_t *tmp_dimensions_info = NULL;
	INT8U dimensions_defined = 0;
	INT8U rating_region_name_len;
	INT8U dimensions_name_len;
	INT8U values_defined, text_len;
	INT8U i;
	INT8U *ptr = NULL;

	if(data && length && info)
	{
		while(sect_len > 0)
		{
			sect_head = (rrt_section_header_t*)sect_data;

			if(sect_head->table_id != ATSC_PSIP_RRT_TID)
			{
				sect_len -= 3;
				sect_len -= MAKE_SHORT_HL(sect_head->section_length);

				sect_data += 3;
				sect_data += MAKE_SHORT_HL(sect_head->section_length);

				continue;
			}

			if(NULL == sect_info)
			{
				sect_info = new_rrt_section_info();
				if(sect_info == NULL)
				{
					AM_TRACE("[%s] error out of memory !!\n", __FUNC__);
					break;
				}
				else
				{
					add_rrt_section_info(&info, sect_info);
				}
			}

			sect_info->rating_region = sect_head->rating_region;
			sect_info->version_number = sect_head->version_number;

			ptr = sect_data + RRT_SECTION_HEADER_LEN;
			rating_region_name_len = *ptr++;
			if (rating_region_name_len > 0)
				atsc_decode_multiple_string_structure(ptr, &sect_info->rating_region_name);

			ptr += rating_region_name_len;
			dimensions_defined = *ptr++;
			sect_info->dimensions_defined = dimensions_defined;
			
			while (dimensions_defined)
			{
				dimensions_name_len = *ptr++;
				tmp_dimensions_info = (rrt_dimensions_info_t *)AMMem_malloc(sizeof(rrt_dimensions_info_t));
				if (tmp_dimensions_info)
				{
					memset(tmp_dimensions_info, 0, sizeof(rrt_dimensions_info_t));
					if (dimensions_name_len > 0)
						atsc_decode_multiple_string_structure(ptr, &tmp_dimensions_info->dimensions_name); //
					ptr += dimensions_name_len;
					tmp_dimensions_info->graduated_scale = ((*ptr)&0x10) >> 4;
					values_defined = (*ptr++) & 0x0F;
					tmp_dimensions_info->values_defined = values_defined;
					for (i = 0; i < values_defined; i++)
					{
						text_len = *ptr++;
						if (text_len > 0)
							atsc_decode_multiple_string_structure(ptr, &tmp_dimensions_info->rating_value[i].abbrev_rating_value_text);
						ptr += text_len;
						
						text_len = *ptr++;
						if (text_len > 0)
							atsc_decode_multiple_string_structure(ptr, &tmp_dimensions_info->rating_value[i].rating_value_text);
						ptr += text_len;
					}
					tmp_dimensions_info->p_next = NULL;

					add_rrt_dimensions_info(&sect_info->dimensions_info, tmp_dimensions_info);
				}
				else
				{
					AM_TRACE("[%s] error out of memory !!\n", __FUNC__);
					break;
				}         
				dimensions_defined--;
			}

			sect_len -= 3;
			sect_len -= MAKE_SHORT_HL(sect_head->section_length);

			sect_data += 3;
			sect_data += MAKE_SHORT_HL(sect_head->section_length);

			sect_info = sect_info->p_next;
		}

		return 0;
	}
Ejemplo n.º 14
0
GX_STATE GX_Get_AllReg(struct gx1001_state *state)
{
    AM_TRACE("GX_CHIP_ID          0x00   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_CHIP_ID                   ));
    AM_TRACE("GX_MAN_PARA         0x10   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_MAN_PARA                  ));
    AM_TRACE("GX_INT_PO1_SEL      0x11   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_INT_PO1_SEL               ));
    AM_TRACE("GX_SYSOK_PO2_SEL    0x12   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_SYSOK_PO2_SEL             ));
    AM_TRACE("GX_STATE_IND        0x13   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_STATE_IND                 ));
    AM_TRACE("GX_TST_SEL          0x14   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_TST_SEL                   ));
    AM_TRACE("GX_I2C_RST          0x15   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_I2C_RST                   ));
    AM_TRACE("GX_MAN_RST          0x16   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_MAN_RST                   ));
    AM_TRACE("GX_BIST             0x18   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_BIST                      ));
    AM_TRACE("GX_MODE_AGC         0x20   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_MODE_AGC                  ));
    AM_TRACE("GX_AGC_PARA         0x21   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_AGC_PARA                  ));
    AM_TRACE("GX_AGC2_THRES       0x22   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_AGC2_THRES                ));
    AM_TRACE("GX_AGC12_RATIO      0x23   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_AGC12_RATIO               ));
    AM_TRACE("GX_AGC_STD          0x24   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_AGC_STD                   ));
    AM_TRACE("GX_SCAN_TIME        0x25   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_SCAN_TIME                 ));
    AM_TRACE("GX_DCO_CENTER_H     0x26   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_DCO_CENTER_H              ));
    AM_TRACE("GX_DCO_CENTER_L     0x27   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_DCO_CENTER_L              ));
    AM_TRACE("GX_BBC_TST_SEL      0x28   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_BBC_TST_SEL               ));
    AM_TRACE("GX_AGC_ERR_MEAN     0x2B   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_AGC_ERR_MEAN              ));
    AM_TRACE("GX_FREQ_OFFSET_H    0x2C   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_FREQ_OFFSET_H             ));
    AM_TRACE("GX_FREQ_OFFSET_L    0x2D   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_FREQ_OFFSET_L             ));
    AM_TRACE("GX_AGC1_CTRL        0x2E   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_AGC1_CTRL                 ));
    AM_TRACE("GX_AGC2_CTRL        0x2F   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_AGC2_CTRL                 ));
    AM_TRACE("GX_FSAMPLE_H        0x40   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_FSAMPLE_H                 ));
    AM_TRACE("GX_FSAMPLE_M        0x41   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_FSAMPLE_M                 ));
    AM_TRACE("GX_FSAMPLE_L        0x42   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_FSAMPLE_L                 ));
    AM_TRACE("GX_SYMB_RATE_H      0x43   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_SYMB_RATE_H               ));
    AM_TRACE("GX_SYMB_RATE_M      0x44   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_SYMB_RATE_M               ));
    AM_TRACE("GX_SYMB_RATE_L      0x45   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_SYMB_RATE_L               ));
    AM_TRACE("GX_TIM_LOOP_CTRL_L  0x46   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_TIM_LOOP_CTRL_L           ));
    AM_TRACE("GX_TIM_LOOP_CTRL_H  0x47   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_TIM_LOOP_CTRL_H           ));
    AM_TRACE("GX_TIM_LOOP_BW      0x48   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_TIM_LOOP_BW               ));
    AM_TRACE("GX_EQU_CTRL         0x50   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_EQU_CTRL                  ));
    AM_TRACE("GX_SUM_ERR_POW_L    0x51   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_SUM_ERR_POW_L             ));
    AM_TRACE("GX_SUM_ERR_POW_H    0x52   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_SUM_ERR_POW_H             ));
    AM_TRACE("GX_EQU_BYPASS       0x53   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_EQU_BYPASS                ));
    AM_TRACE("GX_EQU_TST_SEL      0x54   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_EQU_TST_SEL               ));
    AM_TRACE("GX_EQU_COEF_L       0x55   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_EQU_COEF_L                ));
    AM_TRACE("GX_EQU_COEF_M       0x56   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_EQU_COEF_M                ));
    AM_TRACE("GX_EQU_COEF_H       0x57   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_EQU_COEF_H                ));
    AM_TRACE("GX_EQU_IND          0x58   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_EQU_IND                   ));
    AM_TRACE("GX_RSD_CONFIG       0x80   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_RSD_CONFIG                ));
    AM_TRACE("GX_ERR_SUM_1        0x81   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_ERR_SUM_1                 ));
    AM_TRACE("GX_ERR_SUM_2        0x82   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_ERR_SUM_2                 ));
    AM_TRACE("GX_ERR_SUM_3        0x83   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_ERR_SUM_3                 ));
    AM_TRACE("GX_ERR_SUM_4        0x84   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_ERR_SUM_4                 ));
    AM_TRACE("GX_RSD_DEFAULT      0x85   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_RSD_DEFAULT               ));
    AM_TRACE("GX_OUT_FORMAT       0x90   Value = 0X%02x\n",GX_Read_one_Byte(state, GX_OUT_FORMAT                ));
    return 1;
}
Ejemplo n.º 15
0
int gx1001_writeregister(struct gx1001_state *state, unsigned char regaddr, unsigned char* data, unsigned char length)
{
#if 0
    INT32U nRetCode = AM_SUCCESS;
    INT8U buffer[MAX_REG_VALUE_LEN+1];
    struct i2c_msg msg;


    if(data == 0 || length == 0)
    {
        AM_TRACE("gx1001 write register parameter error !!\n");
        return 0;
    }

    buffer[0] = regaddr;
    memcpy(&buffer[1], data, length);
    length += 1;

    memset(&msg, 0, sizeof(msg));
    msg.addr = state->config.demod_addr;
    msg.flags &=  ~I2C_M_RD;  //write  I2C_M_RD=0x01
    msg.len = length;
    msg.buf = buffer;
    //pr_dbg("gx1001 write dev addr %d,buf[0]=%d\r\n",msg.addr,buffer[0]);
    nRetCode = i2c_transfer(state->i2c, &msg, 1);

    if(nRetCode != 1)
    {
        if(regaddr!=0x10)
            AM_TRACE("gx1001_writeregister reg 0x%x failure!,ret2 %d\n",regaddr,nRetCode);
        return 0;
    }
    return 1;   //success
#endif

    int ret = 0;
    unsigned char regbuf[1];			/*8 bytes reg addr, regbuf 1 byte*/
    struct i2c_msg msg[2];			/*construct 2 msgs, 1 for reg addr, 1 for reg value, send together*/

    regbuf[0] = regaddr & 0xff;

    memset(msg, 0, sizeof(msg));

    /*write reg address*/
    msg[0].addr = (state->config.demod_addr);
    msg[0].flags = 0;
    msg[0].buf = regbuf;
    msg[0].len = 1;

    /*write value*/
    msg[1].addr = (state->config.demod_addr);
    msg[1].flags = I2C_M_NOSTART;	/*i2c_transfer will emit a stop flag, so we should send 2 msg together,
																 * and the second msg's flag=I2C_M_NOSTART, to get the right timing*/
    msg[1].buf = data;
    msg[1].len = length;

    ret = i2c_transfer(state->i2c, msg, 2);

    if(ret<0) {
        AM_TRACE(" %s: writereg error, errno is %d \n", __FUNCTION__, ret);
        return 0;
    }
    else
        return 1;

}
Ejemplo n.º 16
0
INT32S atsc_psip_parse_vct(INT8U* data, INT32U length, vct_section_info_t *info)
{
	INT8U *sect_data = data;
	INT32U sect_len = length;
	vct_section_info_t *sect_info = info;
	vct_section_header_t *sect_head = NULL;
	vct_sect_chan_info_t *vct_sect_chan = NULL;
	vct_channel_info_t *tmp_chan_info = NULL;
	INT8U num_channels_in_section = 0;
	INT8U *ptr = NULL;
	INT16U desc_len;
	INT8U *desc_ptr;
	int chan_name_len;

	if(data && length && info)
	{
		while(sect_len > 0)
		{
			sect_head = (vct_section_header_t*)sect_data;

			if(sect_head->table_id != ATSC_PSIP_TVCT_TID &&
			   sect_head->table_id != ATSC_PSIP_CVCT_TID)
			{
				sect_len -= 3;
				sect_len -= MAKE_SHORT_HL(sect_head->section_length);

				sect_data += 3;
				sect_data += MAKE_SHORT_HL(sect_head->section_length);

				continue;
			}

			if(NULL == sect_info)
			{
				sect_info = new_vct_section_info();
				if(sect_info == NULL)
				{
					AM_TRACE("[%s] error out of memory !!\n", __FUNC__);
					break;
				}
				else
				{
					add_vct_section_info(&info, sect_info);
				}
			}

			sect_info->transport_stream_id = MAKE_SHORT_HL(sect_head->transport_stream_id);
			sect_info->version_number = sect_head->version_number;

			num_channels_in_section = sect_head->num_channels_in_section;
			sect_info->num_channels_in_section= num_channels_in_section;
			ptr = sect_data+VCT_SECTION_HEADER_LEN;
			AM_TRACE("channels in vct %d", num_channels_in_section);
			while (num_channels_in_section)
			{
				vct_sect_chan = (vct_sect_chan_info_t *)ptr;
				tmp_chan_info= (vct_channel_info_t *)AMMem_malloc(sizeof(vct_channel_info_t));
				if (tmp_chan_info)
				{
					memset(tmp_chan_info, 0, sizeof(vct_channel_info_t));
					chan_name_len = sizeof(tmp_chan_info->short_name);
					if(atsc_convert_code_from_utf16_to_utf8((char*)ptr, 14, (char*)tmp_chan_info->short_name, 
                                          &chan_name_len) < 0 ) {
                                               memset(tmp_chan_info->short_name,0 ,chan_name_len);//reset shortname due to hit name  paser error
                                               strcpy(tmp_chan_info->short_name,"No Name");
                                          }

					//short_channel_name_parse(ptr, tmp_chan_info->short_name);
					tmp_chan_info->major_channel_number = MAJOR_CHANNEL_NUM(vct_sect_chan->major_channel_number);
					tmp_chan_info->minor_channel_number = MINOR_CHANNEL_NUM(vct_sect_chan->minor_channel_number);
					tmp_chan_info->program_number = MAKE_SHORT_HL(vct_sect_chan->program_number);
					tmp_chan_info->service_type = vct_sect_chan->service_type;
					tmp_chan_info->source_id = MAKE_SHORT_HL(vct_sect_chan->source_id);
					tmp_chan_info->carrier_frequency = MAKE_WORD_HML(vct_sect_chan->carrier_frequency);
					tmp_chan_info->modulation_mode = vct_sect_chan->modulation_mode;
					tmp_chan_info->access_controlled = vct_sect_chan->access_controlled;
					tmp_chan_info->hidden = vct_sect_chan->hidden;
					tmp_chan_info->hide_guide = vct_sect_chan->hide_guide;
					tmp_chan_info->path_select = vct_sect_chan->path_select;
					tmp_chan_info->out_of_band = vct_sect_chan->out_of_band;
					tmp_chan_info->channel_TSID = MAKE_SHORT_HL(vct_sect_chan->channel_TSID);
					tmp_chan_info->desc = NULL;
					tmp_chan_info->p_next = NULL;

					add_vct_channel_info(&sect_info->vct_chan_info, tmp_chan_info);
					
					desc_len = MAKE_SHORT_HL(vct_sect_chan->descriptors_length);
					desc_ptr = ptr + 32;
					while (desc_len > 0)
					{
						atsc_descriptor_t* p_descriptor = atsc_NewDescriptor(desc_ptr[0], desc_ptr[1], desc_ptr + 2);

						if(p_descriptor)
						{
							if(tmp_chan_info->desc == NULL)
							{
								tmp_chan_info->desc = p_descriptor;
							}
							else
							{
								atsc_descriptor_t* p_last_descriptor = tmp_chan_info->desc;
								while(p_last_descriptor->p_next != NULL)
									p_last_descriptor = p_last_descriptor->p_next;
								p_last_descriptor->p_next = p_descriptor;
							}
						}
						desc_len -= desc_ptr[1] + 2;
						desc_ptr += desc_ptr[1] + 2;
					}
				}
				else
				{
					AM_TRACE("[%s] error out of memory !!\n", __FUNC__);
					break;
				}         
				ptr += 32 + MAKE_SHORT_HL(vct_sect_chan->descriptors_length);
				num_channels_in_section--;
			}

			sect_len -= 3;
			sect_len -= MAKE_SHORT_HL(sect_head->section_length);

			sect_data += 3;
			sect_data += MAKE_SHORT_HL(sect_head->section_length);

			sect_info = sect_info->p_next;
		}

		return 0;
	}

	return -1;
}