Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 8137
b: refs/heads/master
c: 94b7410
h: refs/heads/master
i:
  8135: c08517a
v: v3
  • Loading branch information
Manu Abraham authored and Linus Torvalds committed Sep 9, 2005
1 parent a1ddec8 commit df46c94
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 96 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f612c5793449ac653b2f4531696d8e74e771e3d3
refs/heads/master: 94b7410c8a2d23fad5937b326a0a9e8c5a876e2d
115 changes: 20 additions & 95 deletions trunk/drivers/media/dvb/bt8xx/dst_ca.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,6 @@ static int ca_get_slot_info(struct dst_state *state, struct ca_slot_info *p_ca_s
}




static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, void *arg)
{
u8 i = 0;
Expand Down Expand Up @@ -298,17 +296,26 @@ static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message,
static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u32 length)
{
if (state->dst_hw_cap & DST_TYPE_HAS_SESSION) {
hw_buffer->msg[2] = p_ca_message->msg[1]; /* MSB */
hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */
}
else {
hw_buffer->msg[2] = p_ca_message->msg[1]; /* MSB */
hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */
} else {
if (length > 247) {
dprintk("%s: Message too long ! *** Bailing Out *** !\n", __FUNCTION__);
return -1;
}

hw_buffer->msg[0] = (length & 0xff) + 7;
hw_buffer->msg[1] = 0x40;
hw_buffer->msg[2] = 0x03;
hw_buffer->msg[3] = 0x00;
hw_buffer->msg[4] = 0x03;
hw_buffer->msg[5] = length & 0xff;
hw_buffer->msg[6] = 0x00;
/*
* Need to compute length for EN50221 section 8.3.2, for the time being
* assuming 8.3.2 is not applicable
*/
memcpy(&hw_buffer->msg[7], &p_ca_message->msg[4], length);
}
return 0;
}
Expand Down Expand Up @@ -348,15 +355,6 @@ u32 asn_1_decode(u8 *asn_1_array)
return length;
}

static int init_buffer(u8 *buffer, u32 length)
{
u32 i;
for (i = 0; i < length; i++)
buffer[i] = 0;

return 0;
}

static int debug_string(u8 *msg, u32 length, u32 offset)
{
u32 i;
Expand All @@ -369,95 +367,22 @@ static int debug_string(u8 *msg, u32 length, u32 offset)
return 0;
}

static int copy_string(u8 *destination, u8 *source, u32 dest_offset, u32 source_offset, u32 length)
{
u32 i;
dprintk("%s: Copying [", __FUNCTION__);
for (i = 0; i < length; i++) {
destination[i + dest_offset] = source[i + source_offset];
dprintk(" %02x", source[i + source_offset]);
}
dprintk("]\n");

return i;
}

static int modify_4_bits(u8 *message, u32 pos)
{
message[pos] &= 0x0f;

return 0;
}



static int ca_set_pmt(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u8 reply, u8 query)
{
u32 length = 0, count = 0;
u8 asn_1_words, program_header_length;
u16 program_info_length = 0, es_info_length = 0;
u32 hw_offset = 0, buf_offset = 0, i;
u8 dst_tag_length;
u32 length = 0;
u8 tag_length = 8;

length = asn_1_decode(&p_ca_message->msg[3]);
dprintk("%s: CA Message length=[%d]\n", __FUNCTION__, length);
dprintk("%s: ASN.1 ", __FUNCTION__);
debug_string(&p_ca_message->msg[4], length, 0); // length does not include tag and length
debug_string(&p_ca_message->msg[4], length, 0); /* length is excluding tag & length */

init_buffer(hw_buffer->msg, length);
memset(hw_buffer->msg, '\0', length);
handle_dst_tag(state, p_ca_message, hw_buffer, length);
put_checksum(hw_buffer->msg, hw_buffer->msg[0]);

hw_offset = 7;
asn_1_words = 1; // just a hack to test, should compute this one
buf_offset = 3;
program_header_length = 6;
dst_tag_length = 7;

// debug_twinhan_ca_params(state, p_ca_message, hw_buffer, reply, query, length, hw_offset, buf_offset);
// dprintk("%s: Program Header(BUF)", __FUNCTION__);
// debug_string(&p_ca_message->msg[4], program_header_length, 0);
// dprintk("%s: Copying Program header\n", __FUNCTION__);
copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, (buf_offset + asn_1_words), program_header_length);
buf_offset += program_header_length, hw_offset += program_header_length;
modify_4_bits(hw_buffer->msg, (hw_offset - 2));
if (state->type_flags & DST_TYPE_HAS_INC_COUNT) { // workaround
dprintk("%s: Probably an ASIC bug !!!\n", __FUNCTION__);
debug_string(hw_buffer->msg, (hw_offset + program_header_length), 0);
hw_buffer->msg[hw_offset - 1] += 1;
}

// dprintk("%s: Program Header(HW), Count=[%d]", __FUNCTION__, count);
// debug_string(hw_buffer->msg, hw_offset, 0);

program_info_length = ((program_info_length | (p_ca_message->msg[buf_offset - 1] & 0x0f)) << 8) | p_ca_message->msg[buf_offset];
dprintk("%s: Program info length=[%02x]\n", __FUNCTION__, program_info_length);
if (program_info_length) {
count = copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, (buf_offset + 1), (program_info_length + 1) ); // copy next elem, not current
buf_offset += count, hw_offset += count;
// dprintk("%s: Program level ", __FUNCTION__);
// debug_string(hw_buffer->msg, hw_offset, 0);
}

buf_offset += 1;// hw_offset += 1;
for (i = buf_offset; i < length; i++) {
// dprintk("%s: Stream Header ", __FUNCTION__);
count = copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, buf_offset, 5);
modify_4_bits(hw_buffer->msg, (hw_offset + 3));

hw_offset += 5, buf_offset += 5, i += 4;
// debug_string(hw_buffer->msg, hw_offset, (hw_offset - 5));
es_info_length = ((es_info_length | (p_ca_message->msg[buf_offset - 1] & 0x0f)) << 8) | p_ca_message->msg[buf_offset];
dprintk("%s: ES info length=[%02x]\n", __FUNCTION__, es_info_length);
if (es_info_length) {
// copy descriptors @ STREAM level
dprintk("%s: Descriptors @ STREAM level...!!! \n", __FUNCTION__);
}

}
hw_buffer->msg[length + dst_tag_length] = dst_check_sum(hw_buffer->msg, (length + dst_tag_length));
// dprintk("%s: Total length=[%d], Checksum=[%02x]\n", __FUNCTION__, (length + dst_tag_length), hw_buffer->msg[length + dst_tag_length]);
debug_string(hw_buffer->msg, (length + dst_tag_length + 1), 0); // dst tags also
write_to_8820(state, hw_buffer, (length + dst_tag_length + 1), reply); // checksum
debug_string(hw_buffer->msg, (length + tag_length), 0); /* tags too */
write_to_8820(state, hw_buffer, (length + tag_length), reply);

return 0;
}
Expand Down

0 comments on commit df46c94

Please sign in to comment.