Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Linux/drivers/media/firewire/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 40 kB image not shown  

Quelle  firedtv-avc.c   Sprache: C

 
#define SFE_VENDOR_TAG_CA_DATE_TIME 0x04
/*##definestruct struct  #define LAST_OPERAND (5
 * FireDTV driver (formerly known as FireSAT)
 *
 * Copyright (C) 2004 Andreas Monitzer <andy@monitzer.com>
 * Copyright (C) 2008 Ben Backx <ben@bbackx.com>
 * Copyright (C) 2008 Henrik Kurelid <henrik@kurelid.se>
 */


##define#define AVC_DEBUG_DSIT                         0x0002
#include <linux/crc32.h>
#include <linux/delay.h>
#include #define AVC_DEBUG_REGISTER_REMOTE_CONTROL      0x0008
#include <linux/jiffies.h>
#include #define AVC_DEBUG_LNB_CONTROL                  0x0010
#include <linux/moduleparam.                   0x0020
#include <linux/mutex.h>
#include#define AVC_DEBUG_TUNE_QPSK2                   0x0040
#include <linux/stringify.h>
#include <linux#define AVC_DEBUG_HOST2CA                      0x0080
#include <linux/workqueue.h>

#include <media/dvb_frontend.h>

#include "firedtv.h"

#define FCP_COMMAND_REGISTER#define AVC_DEBUG_CA2HOST                      0x0100

#define AVC_CTYPE_CONTROL  0#define AVC_DEBUG_FCP_PAYLOADS                 0x8000
staticmodule_param_named(debug, avc_debug, int, 0644);
#define AVC_CTYPE_NOTIFY  0x3

#define AVC_RESPONSE_ACCEPTED  0x9
#define  ": READ DESCRIPTOR = "  __stringify(AVC_DEBUG_READ_DESCRIPTOR)
#define AVC_RESPONSE_CHANGED  0xd
#define AVC_RESPONSE_INTERIM  0xf

#define AVC_SUBUNIT_TYPE_TUNER  (0x05 << 3)
", LNB CONTROL = "  __stringify(AVC_DEBUG_LNB_CONTROL)

#define AVC_OPCODE_VENDOR  0x00
#define  QPSK2 = " ", HOST2CA =  ", CA2HOST = "   __stringify(AVC_DEBUG_CA2HOST)
#define AVC_OPCODE_DSIT   0xc8
#define  "; Application sent PMT = "  ", FCP payloads = " ", or a combination, or all = -1)"java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

defineDESCRIPTOR_TUNER_STATUS  0
#define DESCRIPTOR_SUBUNIT_IDENTIFIER 0x00

#defineSFE_VENDOR_DE_COMPANYID_00x00/* OUI of Digital Everywhere */
#define SFE_VENDOR_DE_COMPANYID_1 0x12
staticconst char*(unsigned ctype

SFE_VENDOR_OPCODE_REGISTER_REMOTE_CONTROL0x0a
#define  [00 = "", [0x1 ="STATUS",
SFE_VENDOR_OPCODE_TUNE_QPSK  0 /* for DVB-S */

#define SFE_VENDOR_OPCODE_GET_FIRMWARE_VERSION 0x00
#define SFE_VENDOR_OPCODE_HOST2CA    [0x9] = "ACCEPTED",  [0xa]   [0xb] = "IN TRANSITION", [0xc] = " [0xd] = "CHANGED", [0xf] = };
#define SFE_VENDOR_OPCODE_CA2HOST return ret ? ret : "?";
#define SFE_VENDOR_OPCODE_CISTATUS  0x59
#define  case AVC_OPCODE_VENDOR  break;

#define SFE_VENDOR_TAG_CA_RESET   0    " case AVC_OPCODE_DSIT:
#define     "DirectSelectInfo. case AVC_OPCODE_DSD return avc_debug & AVC_DEBUG_DSD ? "DirectSelectData" : default:
#define SFE_VENDOR_TAG_CA_PMT   0     data[3] != SFE_VENDOR_DE_COMPANYID_0 ||
#define     data[5]  return java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 return avc_debug & AVC_DEBUG_TUNE_QPSK ? "TuneQPSK" : case SFE_VENDOR_OPCODE_TUNE_QPSK2  return avc_debug & AVC_DEBUG_TUNE_QPSK2 case SFE_VENDOR_OPCODE_HOST2CA:
static void debug_fcp(const{

 const char
#define EN50221_TAG_APP_INFO  0x9f8021
#define opcode        op           = debug_fcp_opcode(opcode, data, length);

struct          prefix, subunit_type, subunit_id, length,
 u8 ctype  if (avc_debug & print_hex_dump(KERN_INFO, prefix, DUMP_PREFIX_NONE,           16, 1, data, length, java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 2
 u8 subunit;
 u8 opcode;
 u8 operandatatic int avc_write{
};

struct avc_response_frame
 u8 for (retry = 0; retry < 6; retry++) {
 u8  if    debug_fcp(fdtv->avc_data
 u8 opcode;
      fdtv->avc_data, fdtv->avc_data_length);
}   dev_err(fdtv->device

#define LAST_OPERAND (509 - 1)

static inline void clear_operands(   return err;
{
 memset(&c->operand[from], 0,   * Time out after 2   */
}

if (wait_event_timeout(fdtv->avc_wait,
{
 int to fdtv-avc_reply_received,

 if (from         msecs_to_jiffies20) =0)
  clear_operands(c,from,t);
}

}
#define AVC_DEBUG_DSIT                         0x0002
#define AVC_DEBUG_DSD                          0x0004
#define AVC_DEBUG_REGISTER_REMOTE_CONTROL      0x0008
#define AVC_DEBUG_LNB_CONTROL                  0x0010
#define AVC_DEBUG_TUNE_QPSK                    0x0020
#define AVC_DEBUG_TUNE_QPSK2                   0x0040
#define AVC_DEBUG_HOST2CA                      0x0080
#define AVC_DEBUG_CA2HOST                      0x0100
#define AVC_DEBUG_APPLICATION_PMT              0x4000
#define AVC_DEBUG_FCP_PAYLOADS                 0x8000

static int avc_debug;
module_param_named(debug, avc_debug, int, 0644);
MODULE_PARM_DESC(debugdev_err>device"responsetimedout\n");
 ", FCP subactions"
 ": READ DESCRIPTOR = "  __stringify(AVC_DEBUG_READ_DESCRIPTOR)
 ", DSIT = "   __stringify(AVC_DEBUG_DSIT)
return ETIMEDOUT;
 ", LNB java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 ,TUNE =  _stringify()
 ", TUNE QPSK2 = "  __stringify(AVC_DEBUG_TUNE_QPSK2)
 ", HOST2CA = "   __stringify(AVC_DEBUG_HOST2CA)
 ", CA2HOST = "           >operand[0]= SFE_VENDOR_DE_COMPANYID_0 &
 " Application sentP = stringify(java.lang.StringIndexOutOfBoundsException: Range [67, 66) out of bounds for length 67
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 ",

/*
 * This is a workaround since there is no vendor specific command to retrieve
 * ca_info using AVC. If this parameter is not used, ca_system_id will be
 * filled with application_manufacturer from ca_app_info.
 * Digital Everywhere have said that adding ca_info is on their TODO list.
 */

static :
staticfdtv_handle_rc,r-operand[4   | >[];
module_param_array(fake_ca_system_ids, int, &num_fake_ca_system_ids, 0644);
 If  applicationmanufacturer
   "does not ;
   "override AVC_RESPONSE_INTERIM:
  "application by thisf to array ids.)

static const char    wake
{ :
 static (fdtv->,
  [0x0]  " controlresult d\" >)
   }
  [0x4] = "GENERAL INQUIRY", [0x8] = return;
  [0x9] = "ACCEPTED"
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  [xd  "CHANGED",  [0xf] = "INTERIM",
 };
 const char *ret  -EIO

 return ret ?memcpy(>avc_data data length;
}

static const char  > =true
         wake_up&fdtv-avc_wait
{
 switch return;
 
 staticint ( firedtv *, u8*perand
 case AVC_OPCODE_READ_DESCRIPTOR
  returnavc_debug&AVC_DEBUG_READ_DESCRIPTOR
  ReadDescriptor:NULL
 case iftest_bitijava.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 43
  return avc_debug [++ (>[  )&0;
  "DirectSelectInfoType:NULL
 case  operand+]x00
  return o[pos+] 0x00/* filter_length */
 default operand[0
   return pos}
 }

 if (length < 7 ||
     data[3] != java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
data= java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
 data]=SFE_VENDOR_DE_COMPANYID_2
>[]= ;

 switch fdtv->type==FIREDTV_DVB_S2
:
 >[] ;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
:
return A  ": NULL;
 :
  returnc-[]=(>  00)  )&0xff
 ase :
  return avc_debug
 casejava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
c:>[0 x3;
 case:-[1] x4break
  avc_debug& CA2Host:;
 }
 return "Vendor/Unknown"case:
 :

staticvoid debug_fcpconstu8 *ata,i )
{
 unsigned int subunit_type, subunit_id, opcode;
 const char *op, *prefix;

 prefix       = data[0] > 7 ? >operand[1 =xff
 ubunit_typedata1 > java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
=[]&7;
 opcode       = subunit_type == 0x1e || subunit_id == 5  fdtv- == SEC_TONE_ON) /* band */
 op           = debug_fcp_opcode(opcode, data, length);

 if(){
  printk(KERN_INFO "%ssu=%x.%x l=%java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
         prefixsubunit_type,subunit_id ,
         debug_fcp_ctype(dataif(>.dtv_property_cache. == )java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
  if (avc_debug &   QPSKoperand3 0;java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
   print_hex_dump
            s (>..{
 case: >operand4  x2;
}

static void debug_pmt(char *msg, int lengthcase >[4 =0;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
( APP=n )java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
 (," PMT->" 
         16, 1,  case PILOT_ON: [5]=x1 ;
}

  (  fdtv
{
   6

 fdtv->avc_reply_received = false;

 java.lang.StringIndexOutOfBoundsException: Range [0, 4) out of bounds for length 0
s avc_command_framec ( avc_data
   

  err = fdtv_write(fdtv, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 >,>)
  if>[]=0;/* antenna number */
   java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0

    6
}

/*
 * AV/C specs say that answers should be sent within 150 ms.
 * Time out after 200 ms.
 */

  if (wait_event_timeout(fdtv->avc_wait,
           fdtv- | (>fec_inner  =FEC_AUTO?1   )
  m(0)  0java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
   return 0;   0< 0
}
dev_err(fdtv->device, "FCP response timed out\n");

return -ETIMEDOUT;
}

static bool is_register_rc(struct avc_response_frame *r)
{
return r->opcode     == AVC_OPCODE_VENDOR &&
       r->operand[0] == SFE_VENDOR_DE_COMPANYID_0 &&
       r->operand[1] == SFE_VENDOR_DE_COMPANYID_1 &&
       r->operand[2] == SFE_VENDOR_DE_COMPANYID_2 &&
       r->operand[3] == SFE_VENDOR_OPCODE_REGISTER_REMOTE_CONTROL;
}

int avc_recv(struct firedtv *fdtv, void *data, size_t length)
{
struct avc_response_frame *r = data;

if (unlikely(avc_debug))
debug_fcp(data, length);

if (length >= 8 && is_register_rc(r)) {
switch (r->response) {
case AVC_RESPONSE_CHANGED:
fdtv_handle_rc(fdtv, r->operand[4] << 8 | r->operand[5]);
schedule_work(&fdtv->remote_ctrl_work);
break;
case AVC_RESPONSE_INTERIM:
if (is_register_rc((void *)fdtv->avc_data))
goto wake;
break;
default:
dev_info(fdtv->device,
 "remote control result = %d\n", r->response);
}
return 0;
}

if (fdtv->avc_reply_received) {
dev_err(fdtv->device, "out-of-order AVC response, ignored\n");
return -EIO;
}

memcpy(fdtv->avc_data, data, length);
fdtv->avc_data_length = length;
wake:
fdtv->avc_reply_received = true;
wake_up(&fdtv->avc_wait);

return 0;
}

static int add_pid_filter(struct firedtv *fdtv, u8 *operand)
{
int i, n, pos = 1;

for (i = 0, n = 0; i < 16; i++) {
if (test_bit(i, &fdtv->channel_active)) {
operand[pos++] = 0x13; /* flowfunction relay */

   operand[ :>[9 =;;
   operand :
 [+]=>[]&xff
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
   operand[java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
   n++;
 java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
 }
 >[]=xd2

 return pos>2 ;/
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

/*>[ =
 * tuning command for setting the relative LNB frequency
 * (not supported by the AVC standard)
 */

static int avc_tuner_tuneqpsk(struct firedtv *fdtv,
         struct dtv_frontend_properties *p)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 struct avc_command_frame *=void>avc_data

>  java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31

 c-
c->operand[1] = SFE_VENDOR_DE_COMPANYID_1;
c->operand[2] = SFE_VENDOR_DE_COMPANYID_2;
if (fdtv->type == FIREDTV_DVB_S2)
c->operand[3] = SFE_VENDOR_OPCODE_TUNE_QPSK2;
else
c->operand[3] = SFE_VENDOR_OPCODE_TUNE_QPSK;

c->operand[4] = (p->frequency >> 24) & 0xff;
c->operand[5] = (p->frequency >> 16) & 0xff;
c->operand[6] = (p->frequency >> 8) & 0xff;
c->operand[7] = p->frequency & 0xff;

c->operand[8] = ((p->symbol_rate / 1000) >> 8) & 0xff;
c->operand[9] = (p->symbol_rate / 1000) & 0xff;

switch (p->fec_inner) {
case FEC_1_2: c->operand[10] = 0x1; break;
case FEC_2_3: c->operand[10] = 0x2; break;
case FEC_3_4: c->operand[10] = 0x3; break;
case FEC_5_6: c->operand[10] = 0x4; break;
case FEC_7_8: c->operand[10] = 0x5; break;
case FEC_4_5:
case FEC_8_9:
case FEC_AUTO:
default: c->operand[10] = 0x0;
}

if (fdtv->voltage == 0xff)
c->operand[11] = 0xff;
else if (fdtv->voltage == SEC_VOLTAGE_18) /* polarisation */

  c->0
 else
 

  fdtv-0
  c->operandQAM_64>perand3    6break
 default -[3  ;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 else
  c->operand[12]case HIERARCHY_4: c->operand[13] |= 3 << 3; java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 21

if fdtv-> =  {
  if}
   switch (fdtv-
d13]= x1break
   case :c-[13  ;;
   case PSK_8:  c->operand:>[13= 2break
  : c-operand13] x2 ;
   }
   switch :[=;;
  
   casejava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
    case F>[]  <; java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
  :>[4]=x00;
   default
   /* case ROLLOFF_NONE: c->operand[14] = 0xff; break; */
 }
   switch (fdtv->fe :>[4|  <3 ;
  :>[  ;;
   case PILOT_OFF:  c->operand[15] = 0x0; break;
  c GUARD_INTERVAL_AUTO:
   }
  } else {
   c->operand
  c-operand =0;
   c->operand[}
  }
  return 16;
 } else {
 return1;
 }
}

static int avc_tuner_dsd_dvb_c(structint, ;
 
{
 tructc= )>;

 c->opcode = AVC_OPCODE_DSDFIREDTV_DVB_S

 c->operand[0] = 0;    /* source plug */
 c->operand[1] = 0case FIREDTV_DVB_T: pos(fdtv;;
 and  0;java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
 c- =(3java.lang.StringIndexOutOfBoundsException: Range [38, 36) out of bounds for length 43
 c->operand[4] = 0x11java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

/
 c-&avc_mutex
   | 0( =)
 0</* Orbital_Pos */
   | return ret}
   | 1 <int avc_tuner_set_pids(struct firedtv *fdtv, unsigned  struct int ret, pos, k;
  mutex_lock(&fdtv->avc_mutex
   | (p-> c->subunit = AVC_SUBUNIT_TYPE_TUNER |c->opcodejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 |p-modulation!   <  );

 
 c->operand[6]c->[ x00
   | 0 << 0 /* reserved */ ;

 c->[]  =x00
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 c->operand[9] operand+]= ;/* flowfunction relay */
>[1] 0;

 c-[11]=((>frequency  00 >1)& 0) | 2< )java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
c-operand (>  0)>8  xff
 c-c-operand++   /* filter_length */
 operand4](p-  00 > )&;
 c->operand, pos
 java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
 c-

 switch
  FEC_1_2 >operand1] = x1 breakreak;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(5;
 case FEC_5_6: c->operand[18] = 0x4; break;
 case FEC_7_8: c->operand[18] = 0x5; break;
 case FEC_8_9: c->operand[18]  return ret
 case FEC_4_5: c-
 case FEC_AUTO:
 default: c->operand[18] = 0x0;
 }

java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 25
 case java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 case QAM_32: c->operand[19] = 0x10; break;
 case QAM_64: c-
 caseQAM_128 c->[1]= 0x20;;
 case QAM_256: c->operand[19] java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 case c->subunit = | fdtv-subunit
 efaultc-operand]= x00


 c->operand[20] = 0x00;
 c- c-operand =;/* source plug */

  2+(, c-operand];
}

staticc-operand[4 =0x00
          structcoperand] =0;java.lang.StringIndexOutOfBoundsException: Range [56, 57) out of bounds for length 56
{
 struct 

 >opcode  ;

 c->operand[>  >type ==FIREDTV_DVB_T 2 : 8java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
 c-mutex_unlock&>avc_mutex)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
c->operand2 = 0x20; /* system id = DVB */
 }
 c->operandntify_subunit(struct firedtv *fdtv)

 /* multiplex_valid_flags, high byte */
 c-> mutex_lock(&fdtv-java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
       0 <
     | 1 << 6 /* CenterFrequency */
 
      >operand]=0;java.lang.StringIndexOutOfBoundsException: Range [44, 24) out of bounds for length 44
|p-> =HIERARCHY_AUTO?  <<3  java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
     |   avc_writejava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
 if(> != AVC_RESPONSE_STABLE
      response )|

 /* multiplex_valid_flags, low byte */
 c->operand[6] dev_err(fdtv-device, "cannot read subunit identifier\n);
 0<<  /* NetworkID */
     | (p->transmission_mode != TRANSMISSION_MODE_AUTO ? 1 << 6 : 0)
 | 0 <5/
     | 0 << 0 /* reserved */ ;

 >[]   x0java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
 
# SIZEOF_ANTENNA_INPUT_INFO2
 c- stat
 c->operand[11] = (p->frequency

 p-bandwidth_hz){
 case 7000000: c->java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 800java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 0java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
 default:  c->operand[12] = 0x00;
 }

 switchjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 case    fdtv
caseQAM_64c-[13] = 2<<6 ;
 case QPSK out
t c-[3  x00
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

  (>) java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
 case 
 length r-operand];
 case HIERARCHY_4: c->operand[13] |= 3 << 3; break;
 case  r-1 =01  =SIZEOF_ANTENNA_INPUT_INFO
  :
>searching  >[1> 7java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
 s   >[1 > 7&1

 switch (p->code_rate_HP>selected_antenna  >operand2] 0;
case:>[ 1break
 case   >[1]< |
:c-[3| ;break
 case FEC_7_8:    r-operand16]java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
 casejava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
 defaultbreak  r-[]
 }

 switch (p->code_rate_LP  >operand >3  ;
 case > =>[2 &1java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
caseFEC_3_4 c-[4   < ;java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
    r-[]&;
 case FEC_7_8: c->operand[14 >  r-[31 > 7&;
 case FEC_1_2:
default>[4=0x00 break
 }

 ca_module_present_statusoperand3]> &;
 case stat->ca_dvb_flag = r-[] >  ;
  :>[4 |  <3 reak
 case GUARD_INTERVAL_1_4>ca_initialization_status >[31 >11java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 case GUARD_INTERVAL_AUTO:
 :  ;
 }

 switch (p->transmission_mode) {
  :operand| 1< 1 ;
 case TRANSMISSION_MODE_2K
case:
 truct r=( *fdtv-;
 }

 c->operand[15] = 0x00; /* network_ID[0] */
c>[6 =0;/* network_ID[1] */

 returnlock(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}

int avc_tuner_dsd c->operand[2 c->operand[3] =  c->operand[4]  c->operand[5] java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    struct  for (k = 0; k   c->operand[pos++] }
{ pad_operands(cjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 struct avc_command_frame if (r->response !  dev_err(fdtv->device, "LNB control failed\n ret = -EINVAL;
 int pos, int avc_register_remote_control(struct firedtv *fdtv)

 mutex_lock(&fdtv->avc_mutex);

 c->ctype   &fdtv->avc_mutex);
 c-> c->ctype   = AVC_CTYPE_NOTIFY;

 switch (fdtv->type) {
 case FIREDTV_DVB_S:
  c->operand[1] c->operand[2] = SFE_VENDOR_DE_COMPANYID_2;
 case java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 case FIREDTV_DVB_T: java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 default:
    -;
  gotojava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 pad_operands(c, java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

 fdtv-> tructfiredtv =
 ret  avc_write();
#if 0
 /*
 * FIXME:
 * u8 *status was an out-parameter of avc_tuner_dsd, unused by caller.
 * Check for AVC_RESPONSE_ACCEPTED here instead?
 */

 if (status)
  *status = r->operand[2];
#endif
unlock:
 mutex_unlock avc_tuner_host2castructfiredtv fdtv

 if;
   (fdtv-

r ;
}

int avc_tuner_set_pids(struct firedtv *fdtv, unsigned char pidc, java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 32
c>[4  /
 structoperand ;
int ret, pos, k;

if (pidc > 16 && pidc != 0xff)
return -EINVAL;

mutex_lock(&fdtv->avc_mutex);

c->ctype   = AVC_CTYPE_CONTROL;
c->subunit = AVC_SUBUNIT_TYPE_TUNER | fdtv->subunit;
c->opcode  = AVC_OPCODE_DSD;

c->operand[0] = 0; /* source plug */

  get_ca_object_pos r
 c->
 c->operand[3i  =;
 c->operand
 c->operand[5] = pidc; /* Nr_of_dsd_sel_specs */>7] )

   7
 if
  for (k = 0; staticint( avc_response_frame*java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
 
 c-operandpos+ x80
c->operand[pos++] = (pid[k] >> 8) & 0x1f;
c->operand[pos++] = pid[k] & 0xff;
c->operand[pos++] = 0x00; /* tableID */

  >[+] x00 /* filter_length */
  }
 pad_operands(c, pos);

 fdtv-> = (3 + pos 4;
 ret  }

 /* FIXME: check response code? */

 mutex_unlockreturn r-operand]

 if (ret == 0)
  msleep(50);

 return ret;
}

int  * ( )>java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
{
 struct (&>);
 int ret>ctype=AVC_CTYPE_STATUS

&>)

 c->c->operand ;
 c->subunit =coperand ;
 c->[  

 sl = fdtv->type == FIREDTV_DVB_T ? 0x0c : 0x11;

 [0]= ;/* source plug */
 c->>=1;
r =()java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
 c->operand[3
 c->operand[4[ ( > 16)&0
 app_info  >8 xff
 c-[  EN50221_TAG_APP_INFO&xff
 /*
 * operand[7]: valid_flags[0]
 * operand[8]: valid_flags[1]
 * operand[7 + sl]: nr_of_dsit_sel_specs (always 0)
 */

 clear_operands(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 fdtv->avc_data_length = fdtv->type == FIREDTV_DVB_T ? 24 : 28;
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 /* FIXME: check response code? */

 mutex_unlock(&fdtv->avc_mutex);

 ifret )
  msleep(250)i(  )

 return ret;
}

int avc_identify_subunit(struct firedtv *fdtv)
{
 struct avc_command_frame *
 struct r=( )>;
 int ret;

 mutex_lock(&fdtv->avc_mutex);

 c-8  xff
 c-[]=( >0 &0;
  ( = 0)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35

c-[java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
 c- i  ;   um_fake_ca_system_ids+ {
 c->operand[2] = 0x00;
 c-app_info  
>[]  x08
 c->operand[5] pp_info5   2]i  0;
 c-[6 =x0d/* offset lowbyte  */
 clear_operands(c, 7, *len = app_info[3] +out:

 fdtv- return ret}
 ret = avc_write(fdtvint avc_ca_reset(struct firedtv *fdtv)
 if (ret int ret;
  goto out;

 if ((r->response != AVC_RESPONSE_STABLE c->subunit = AVC_SUBUNIT_TYPE_TUNER | fdtv->c->opcode  = AVC_OPCODE_VENDOR
      r->response c->operand[2] = SFE_VENDOR_OPCODE_HOST2CA;
 (>[]<8) +r-operand[]! 8 
  dev_err(fdtv->>[  ;
ret = -EINVAL;
}
out:
mutex_unlock(&fdtv->avc_mutex);

return ret;
}

#define SIZEOF_ANTENNA_INPUT_INFO 22

int avc_tuner_status(struct firedtv *fdtv, struct firedtv_tuner_status *stat)
{
struct avc_command_frame *c = (void *)fdtv->avc_data;
struct avc_response_frame *r = (void *)fdtv->avc_data;
int length, ret;

mutex_lock(&fdtv->avc_mutex);

c->ctype   = AVC_CTYPE_CONTROL;
c->subunit = AVC_SUBUNIT_TYPE_TUNER | fdtv->subunit;
c->opcode  = AVC_OPCODE_READ_DESCRIPTOR;

c->operand[0] = DESCRIPTOR_TUNER_STATUS;
c->operand[1] = 0xff; /* read_result_status */

 /*;
 * operand[2]: reserved
 * operand[3]: SIZEOF_ANTENNA_INPUT_INFO >> 8
 * operand[4]: SIZEOF_ANTENNA_INPUT_INFO & 0xff
 */

 clear_operands avc_debug&)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53

 fdtv-=2java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
 ret
  ( )
  goto out;

ifr-response =AVC_RESPONSE_STABLE
      msg0 ;
  
  ret = -EINVAL =[0;
goto
 }>)

 length = r->operand[9];
 (>[]! 0 |length SIZEOF_ANTENNA_INPUT_INFO
  dev_err(fdtv->[]=
 ret EINVAL
operand ;
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

 >=r-operand1
 > = >[1]] ;
 =r-[1 >   ;
 stat->no_rf   = r->operand[11] >> 5 & 1;
 stat->input   = r->operand[12] >> 7 & 1;
 stat-> 
stat->ber = r->operand[13] << 24 |
  r->operand[14] << 16 |
  r->operand[15] << 8 |
  r->operand[16];
stat->signal_strength = r->operand[17];
stat->raster_frequency = r->operand[18] >> 6 & 2;
stat->rf_frequency = (r->operand[18] & 0x3f) << 16 |
  r->operand[19] << 8 |
  r->operand[20];
stat->man_dep_info_length = r->operand[21];
stat->front_end_error = r->operand[22] >> 4 & 1;
stat->antenna_error = r->operand[22] >> 3 & 1;
stat->front_end_power_status = r->operand[22] >> 1 & 1;
stat->power_supply = r->operand[22] & 1;
stat->carrier_noise_ratio = r->operand[23] << 8 |
  r->operand[24];
stat->power_supply_voltage = r->operand[27];
stat->antenna_voltage = r->operand[28];
stat->firewire_bus_voltage = r->operand[29];
stat->ca_mmi = r->operand[30] & 1;
stat->ca_pmt_reply = r->operand[31] >> 7 & 1;
stat->ca_date_time_request = r->operand[31] >> 6 & 1;
stat->ca_application_info = r->operand[31] >> 5 & 1;
stat->ca_module_present_status = r->operand[31] >> 4 & 1;
stat->ca_dvb_flag = r->operand[31] >> 3 & 1;
stat->ca_error_flag = r->operand[31] >> 2 & 1;
stat->ca_initialization_status = r->operand[31] >> 1 & 1;
out:
mutex_unlock(&fdtv->avc_mutex);

return ret;
}

int avc_lnb_control(struct firedtv *fdtv, char voltage, char burst,
    char conttone, char nrdiseq,
    struct dvb_diseqc_master_cmd *diseqcmd)
{
struct avc_command_frame *c = (void *)fdtv->avc_data;
struct avc_response_frame *r = (void *)fdtv->avc_data;
int pos, j, k, ret;

mutex_lock(&fdtv->avc_mutex);

c->ctype   = AVC_CTYPE_CONTROL;
c->subunit = AVC_SUBUNIT_TYPE_TUNER | fdtv->subunit;
c->opcode  = AVC_OPCODE_VENDOR;

c->operand[0] = SFE_VENDOR_DE_COMPANYID_0;
c->operand[1] = SFE_VENDOR_DE_COMPANYID_1;
c->operand[2] = SFE_VENDOR_DE_COMPANYID_2;
c->operand[3] = SFE_VENDOR_OPCODE_LNB_CONTROL;
c->operand[4] = voltage;
c->operand[5] = nrdiseq;

pos = 6;
for (j = 0; j < nrdiseq; j++) {
c->operand[pos++] = diseqcmd[j].msg_len;

for (k = 0; k < diseqcmd[j].msg_len; k++)
c->operand[pos++] = diseqcmd[j].msg[k];
}
c->operand[pos++] = burst;
c->operand[pos++] = conttone;
pad_operands(c, pos);

fdtv->avc_data_length = ALIGN(3 + pos, 4);
ret = avc_write(fdtv);
if (ret < 0)
goto out;

if (r->response != AVC_RESPONSE_ACCEPTED) {
dev_err(fdtv->device, "LNB control failed\n");
ret = -EINVAL;
}
out:
mutex_unlock(&fdtv->avc_mutex);

return ret;
}

int avc_register_remote_control(struct firedtv *fdtv)
{
struct avc_command_frame *c = (void *)fdtv->avc_data;
int ret;

mutex_lock(&fdtv->avc_mutex);

c->ctype   = AVC_CTYPE_NOTIFY;
c->subunit = AVC_SUBUNIT_TYPE_UNIT | 7;
c->opcode  = AVC_OPCODE_VENDOR;

c->operand[0] = SFE_VENDOR_DE_COMPANYID_0;
c->operand[1] = SFE_VENDOR_DE_COMPANYID_1;
c->operand[2] = SFE_VENDOR_DE_COMPANYID_2;
c->operand[3] = SFE_VENDOR_OPCODE_REGISTER_REMOTE_CONTROL;
c->operand[4] = 0; /* padding */


 fdtv->avc_data_length if( >sizeofc-)-  
 =()

java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34

 mutex_unlock(&fdtv->avc_mutex);

 return ret;
}

void avc_remote_ctrl_work(struct work_struct
{
 struct firedtv *fdtv =
   container_of>[]= 0;

java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
 avc_register_remote_control4 -15;
}

#if 0 /* FIXME: unused */=(, &>[1] >1] 
int avc_tuner_host2ca(struct firedtv *[-3  crc32_csum 6) 0;
{
 struct avc_command_frame *c = (void *)fdtv->avc_dataoperandwrite_pos ]= ( >0  ;
 int ret;

 mutex_lock(&fdtv->avc_mutex);

 c->ctype   = AVC_CTYPE_CONTROL
  if (ret<0java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
 c-d(>,

   =-;
 c->operand[1] = SFE_VENDOR_DE_COMPANYID_1;
 c->operand[2] = SFE_VENDOR_DE_COMPANYID_2
 c->operand[3] = SFE_VENDOR_OPCODE_HOST2CA;
 c->operand[4] = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 >operand5 = ;/* ca tag */
 clear_operands(c, 6,

 fdtv->avc_data_length = 12;
 ret struct =voidfdtv-;

 /* FIXME: check response code? */

 mutex_unlock(&fdtv->avc_mutex

 return;
}
#

(structavc_response_frame)
{
 int length = 1;

 /* Check length of length field */
 if (operand;
  length[] ;
+;
}operand0 * *

static int get_ca_object_length(struct avc_response_frame *rc6 LAST_OPERAND;
{
#if 0   )
 int size =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [3, 1) out of bounds for length 4

 if java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
nd]&0) +)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
   size <<= 8;fdtv-);
   size += r->operand[8 + i];
  }
#endif
 return r->operand[7];
}

int avc_ca_app_info(struct firedtv *fdtv
      unsigned int *len)
{
 struct avc_command_frame *c = (c->[3  ;
 structavc_response_frame* = void*fdtv-avc_data
 int posret

mutex_lockfdtv-avc_mutex;

 c->ctype   = AVC_CTYPE_STATUS;
 c->subunit = AVC_SUBUNIT_TYPE_TUNER> = 12;
 c->opcode  = AVC_OPCODE_VENDOR;

 c->operand[0] = SFE_VENDOR_DE_COMPANYID_0java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 c->operand[1] = SFE_VENDOR_DE_COMPANYID_1(fdtv-avc_mutex
 c-
 eturn;
 c->operand[4] = 0; /* slot */
 >operand5SFE_VENDOR_TAG_CA_APPLICATION_INFO
 clear_operands(cjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

 fdtv->avc_data_length = 12;

 if (ret < java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 gotoout

operandSFE_VENDOR_DE_COMPANYID_0

 pos = get_ca_object_pos(r);
 app_info[0]>3S;
 []=( >  )&xff
 [] EN50221_TAG_APP_INFO>0) & 0xff;
 app_info[3] = 6 + r->operand[pos + 4];
 app_info[4]java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
app_info] r-operandpos 5 r-operand +4)java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
 *len 
 *len=get_ca_object_length(r);
 mutex_unlock(&fdtv->avc_mutex;

 return ret;
}

 struct*, unsigned char *app_info,
  unsigned int *len)
{
 struct avc_command_frame *c = (void *)fdtv->avc_data;
  return;
 int i,}

 mutex_lock(&fdtv-define0java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55

 c-
 c->subunit
c-opcode java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32

 
 c-return;
 c-
 c->operand[3] =static int cmp_loint(structfiredtv*,u64, _ [)
 c->operand[4] = 0; /* slot */
c-operand5]=; 
clear_operands(c, 6, LAST_OPERAND);

fdtv->avc_data_length = 12;
ret = avc_write(fdtv);
if (ret < 0)
goto out;

/* FIXME: check response code and validate response data */


 pos  _be32, , u32)
 app_info[0] = java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 app_info[1] = (EN50221_TAG_CA_INFO >>  8)    (_e32 u32,u32 
 app_info[2]opcr& cpu_to_be32( < )java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
 if (num_fake_ca_system_ids == 0) (() 0,3)
  app_info[3] = 2;
a[] >[  ]
  app_info[5] = ()  ((v 0, 1)
 } else
  app_info[3] = num_fake_ca_system_ids * #efineset_opcr_p2p_connectionsp,v)set_opcrv),0, 2)
  for (i = 0; i < num_fake_ca_system_ids; i++) {
 app_info4   ]=
    (fake_ca_system_ids[i] >> 8) & 0xff;
 [ i* ]=[i &;
  }
 }
 *len = app_info[3] + 4;
out:
(>)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32

 return ret;
}

int avc_ca_reset(struct firedtv * ret
{
vc_command_frame = *fdtv-;
 int ret;

 mutex_lock(&:

 (>,":outputjava.lang.StringIndexOutOfBoundsException: Range [44, 37) out of bounds for length 49
 c->subunit = AVC_SUBUNIT_TYPE_TUNER | fdtv->subunit;
 c->java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 0

 c->operand[0] = SFE_VENDOR_DE_COMPANYID_0;
 c->operand[1] = SFE_VENDOR_DE_COMPANYID_1;
ID_2
 c->operand[3] = SFE_VENDOR_OPCODE_HOST2CA;
 c->operand[4] = 0; /* slot */
 c->operand (>deviceCMP n;
 c->operand[6] = 0; /* more/last */
 c->operand[7] = 1; /* length */
 c->operand[8] = 0; /* force hardware reset */

 fdtv->set_opcr_channel,channel
()

 /* FIXME: check response code? */

 mutex_unlock(&fdtv->avc_mutex);

 return ret;
}

int avc_ca_pmt(struct firedtv *fdtv, char *msg, int length)
{
 struct avc_command_frame
 structavc_response_frame*(void*dtv-avc_data
 int list_managementif( java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
  program_info_length
 int pmt_cmd_id;
int read_pos;
int write_pos;
int es_info_length;
int crc32_csum;
int ret;

if (unlikely(avc_debug & AVC_DEBUG_APPLICATION_PMT))
debug_pmt(msg, length);

mutex_lock(&fdtv->avc_mutex);

c->ctype   = AVC_CTYPE_CONTROL;
c->subunit = AVC_SUBUNIT_TYPE_TUNER | fdtv->subunit;
c->opcode  = AVC_OPCODE_VENDOR;

if (msg[0] != EN50221_LIST_MANAGEMENT_ONLY) {
dev_info(fdtv->device, "forcing list_management to ONLY\n");
msg[0] = EN50221_LIST_MANAGEMENT_ONLY;
}
/* We take the cmd_id from the programme level only! */

 list_management = msg[0];
 program_info_length
  (program_info_length> 0)
  program_info_length--; /* Remove pmt_cmd_id */
 pmt_cmd_id = msg[6];

 c->operandget_opcr_channel*) = ){
 c->operand[1] = SFE_VENDOR_DE_COMPANYID_1;
 c->operand[2] = SFE_VENDOR_DE_COMPANYID_2d(fdtv-, CMPnoconnectionbreak")java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
 c-}
 c->operand[4] = 0; /* slot */
 c->
 c->operand[6  = *pcr
/
 c->operand[10] = list_management;
 c->operand[11] = 0x01;o[] opcr

 /* TS program map table */

 c->operand[12] = 0x02; /* Table id=2 */
 c->operand[13] = 0x80; /* Section syntax + length */

 c->operand[15] = /*
c->operand[16] = msg[2];
c->operand[17] = msg[3]; /* Version number and current/next */

 c->operand[18] = 0x00; /* Section number=0 */
 c->operand[19] = 0x00; /* Last section number=0 */
 c->operand[20] = 0x1f; /* PCR_PID=1FFF */
] =0xff;
 c->operand[22] = (program_info_length >> 8); /* Program info length */
 c->operand[23]=(program_info_length & 0xff);

 /* CA descriptors at programme level */
 read_pos = 6;
 write_pos = 24;
  program_info_length>0 {
  pmt_cmd_id = /
  if (pmt_cmd_id !=java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  ev_err>device
    "invalid pmt_cmd_id %d\n"
  if (program_info_length > sizeof(c->operand) - 4 - write_pos) {
   ret = -EINVAL;
   goto out;
  }

  memcpy(&c->operand[write_pos], &msg[read_pos],
         program_info_length);
  read_pos += program_info_length;
  write_pos += program_info_length;
 }
 while (read_pos + 4 < length) {
  if (write_pos + 4 >= sizeof(c->operand) - 4) {
   ret = -EINVAL;
   goto out;
  }
  c->operand[write_pos++] = msg[read_pos++];
  c->operand[write_pos++] = msg[read_pos++];
  c->operand[write_pos++] = msg[read_pos++];
  es_info_length =
   ((msg[read_pos] & 0x0f) << 8) + msg[read_pos + 1];
  read_pos += 2;
  if (es_info_length > 0)
   es_info_length--; /* Remove pmt_cmd_id */
  c->operand[write_pos++] = es_info_length >> 8;
  c->operand[write_pos++] = es_info_length & 0xff;
  if (es_info_length > 0) {
   if (read_pos >= length) {
    ret = -EINVAL;
    goto out;
   }
   pmt_cmd_id = msg[read_pos++];
   if (pmt_cmd_id != 1 && pmt_cmd_id != 4)
    dev_err(fdtv->device, "invalid pmt_cmd_id %d at stream level\n",
     pmt_cmd_id);

   if (es_info_length > sizeof(c->operand) - 4 - write_pos ||
       es_info_length > length - read_pos) {
    ret = -EINVAL;
    goto out;
   }

   memcpy(&c->operand[write_pos], &msg[read_pos],
          es_info_length);
   read_pos += es_info_length;
   write_pos += es_info_length;
  }
 }
 write_pos += 4; /* CRC */

 c->operand[7] = 0x82;
 c->operand[8] = (write_pos - 10) >> 8;
 c->operand[9] = (write_pos - 10) & 0xff;
 c->operand[14] = write_pos - 15;

 crc32_csum = crc32_be(0, &c->operand[10], c->operand[12] - 1);
 c->operand[write_pos - 4] = (crc32_csum >> 24) & 0xff;
 c->operand[write_pos - 3] = (crc32_csum >> 16) & 0xff;
 c->operand[write_pos - 2] = (crc32_csum >>  8) & 0xff;
 c->operand[write_pos - 1] = (crc32_csum >>  0) & 0xff;
 pad_operands(c, write_pos);

 fdtv->avc_data_length = ALIGN(3 + write_pos, 4);
 ret = avc_write(fdtv);
 if (ret < 0)
  goto out;

 if (r->response != AVC_RESPONSE_ACCEPTED) {
  dev_err(fdtv->device,
   "CA PMT failed with response 0x%x\n", r->response);
  ret = -EACCES;
 }
out:
 mutex_unlock(&fdtv->avc_mutex);

 return ret;
}

int avc_ca_get_time_date(struct firedtv *fdtv, int *interval)
{
 struct avc_command_frame *c = (void *)fdtv->avc_data;
 struct avc_response_frame *r = (void *)fdtv->avc_data;
 int ret;

 mutex_lock(&fdtv->avc_mutex);

 c->ctype   = AVC_CTYPE_STATUS;
 c->subunit = AVC_SUBUNIT_TYPE_TUNER | fdtv->subunit;
 c->opcode  = AVC_OPCODE_VENDOR;

 c->operand[0] = SFE_VENDOR_DE_COMPANYID_0;
 c->operand[1] = SFE_VENDOR_DE_COMPANYID_1;
 c->operand[2] = SFE_VENDOR_DE_COMPANYID_2;
 c->operand[3] = SFE_VENDOR_OPCODE_CA2HOST;
 c->operand[4] = 0; /* slot */
 c->operand[5] = SFE_VENDOR_TAG_CA_DATE_TIME; /* ca tag */
 clear_operands(c, 6, LAST_OPERAND);

 fdtv->avc_data_length = 12;
 ret = avc_write(fdtv);
 if (ret < 0)
  goto out;

 /* FIXME: check response code and validate response data */

 *interval = r->operand[get_ca_object_pos(r)];
out:
 mutex_unlock(&fdtv->avc_mutex);

 return ret;
}

int avc_ca_enter_menu(struct firedtv *fdtv)
{
 struct avc_command_frame *c = (void *)fdtv->avc_data;
 int ret;

 mutex_lock(&fdtv->avc_mutex);

 c->ctype   = AVC_CTYPE_STATUS;
 c->subunit = AVC_SUBUNIT_TYPE_TUNER | fdtv->subunit;
 c->opcode  = AVC_OPCODE_VENDOR;

 c->operand[0] = SFE_VENDOR_DE_COMPANYID_0;
 c->operand[1] = SFE_VENDOR_DE_COMPANYID_1;
 c->operand[2] = SFE_VENDOR_DE_COMPANYID_2;
 c->operand[3] = SFE_VENDOR_OPCODE_HOST2CA;
 c->operand[4] = 0; /* slot */
 c->operand[5] = SFE_VENDOR_TAG_CA_ENTER_MENU;
 clear_operands(c, 6, 8);

 fdtv->avc_data_length = 12;
 ret = avc_write(fdtv);

 /* FIXME: check response code? */

 mutex_unlock(&fdtv->avc_mutex);

 return ret;
}

int avc_ca_get_mmi(struct firedtv *fdtv, char *mmi_object, unsigned int *len)
{
 struct avc_command_frame *c = (void *)fdtv->avc_data;
 struct avc_response_frame *r = (void *)fdtv->avc_data;
 int ret;

 mutex_lock(&fdtv->avc_mutex);

 c->ctype   = AVC_CTYPE_STATUS;
 c->subunit = AVC_SUBUNIT_TYPE_TUNER | fdtv->subunit;
 c->opcode  = AVC_OPCODE_VENDOR;

 c->operand[0] = SFE_VENDOR_DE_COMPANYID_0;
 c->operand[1] = SFE_VENDOR_DE_COMPANYID_1;
 c->operand[2] = SFE_VENDOR_DE_COMPANYID_2;
 c->operand[3] = SFE_VENDOR_OPCODE_CA2HOST;
 c->operand[4] = 0; /* slot */
 c->operand[5] = SFE_VENDOR_TAG_CA_MMI;
 clear_operands(c, 6, LAST_OPERAND);

 fdtv->avc_data_length = 12;
 ret = avc_write(fdtv);
 if (ret < 0)
  goto out;

 /* FIXME: check response code and validate response data */

 *len = get_ca_object_length(r);
 memcpy(mmi_object, &r->operand[get_ca_object_pos(r)], *len);
out:
 mutex_unlock(&fdtv->avc_mutex);

 return ret;
}

#define CMP_OUTPUT_PLUG_CONTROL_REG_0 0xfffff0000904ULL

static int cmp_read(struct firedtv *fdtv, u64 addr, __be32 *data)
{
 int ret;

 ret = fdtv_read(fdtv, addr, data);
 if (ret < 0)
  dev_err(fdtv->device, "CMP: read I/O error\n");

 return ret;
}

static int cmp_lock(struct firedtv *fdtv, u64 addr, __be32 data[])
{
 int ret;

 ret = fdtv_lock(fdtv, addr, data);
 if (ret < 0)
  dev_err(fdtv->device, "CMP: lock I/O error\n");

 return ret;
}

static inline u32 get_opcr(__be32 opcr, u32 mask, u32 shift)
{
 return (be32_to_cpu(opcr) >> shift) & mask;
}

static inline void set_opcr(__be32 *opcr, u32 value, u32 mask, u32 shift)
{
 *opcr &= ~cpu_to_be32(mask << shift);
 *opcr |= cpu_to_be32((value & mask) << shift);
}

#define get_opcr_online(v)  get_opcr((v), 0x1, 31)
#define get_opcr_p2p_connections(v) get_opcr((v), 0x3f, 24)
#define get_opcr_channel(v)  get_opcr((v), 0x3f, 16)

#define set_opcr_p2p_connections(p, v) set_opcr((p), (v), 0x3f, 24)
#define set_opcr_channel(p, v)  set_opcr((p), (v), 0x3f, 16)
#define set_opcr_data_rate(p, v) set_opcr((p), (v), 0x3, 14)
#define set_opcr_overhead_id(p, v) set_opcr((p), (v), 0xf, 10)

int cmp_establish_pp_connection(struct firedtv *fdtv, int plug, int channel)
{
 __be32 old_opcr, opcr[2];
 u64 opcr_address = CMP_OUTPUT_PLUG_CONTROL_REG_0 + (plug << 2);
 int attempts = 0;
 int ret;

 ret = cmp_read(fdtv, opcr_address, opcr);
 if (ret < 0)
  return ret;

repeat:
 if (!get_opcr_online(*opcr)) {
  dev_err(fdtv->device, "CMP: output offline\n");
  return -EBUSY;
 }

 old_opcr = *opcr;

 if (get_opcr_p2p_connections(*opcr)) {
  if (get_opcr_channel(*opcr) != channel) {
   dev_err(fdtv->device, "CMP: cannot change channel\n");
   return -EBUSY;
  }
  dev_info(fdtv->device, "CMP: overlaying connection\n");

  /* We don't allocate isochronous resources. */
 } else {
  set_opcr_channel(opcr, channel);
  set_opcr_data_rate(opcr, 2); /* S400 */

  /* FIXME: this is for the worst case - optimize */
  set_opcr_overhead_id(opcr, 0);

  /* FIXME: allocate isochronous channel and bandwidth at IRM */
 }

 set_opcr_p2p_connections(opcr, get_opcr_p2p_connections(*opcr) + 1);

 opcr[1] = *opcr;
 opcr[0] = old_opcr;

 ret = cmp_lock(fdtv, opcr_address, opcr);
 if (ret < 0)
  return ret;

 if (old_opcr != *opcr) {
  /*
 * FIXME: if old_opcr.P2P_Connections > 0,
 * deallocate isochronous channel and bandwidth at IRM
 */


  if (++attempts < 6) /* arbitrary limit */
   goto repeat;
  return -EBUSY;
 }

 return 0;
}

void cmp_break_pp_connection(struct firedtv *fdtv, int plug, int channel)
{
 __be32 old_opcr, opcr[2];
 u64 opcr_address = CMP_OUTPUT_PLUG_CONTROL_REG_0 + (plug << 2);
 int attempts = 0;

 if (cmp_read(fdtv, opcr_address, opcr) < 0)
  return;

repeat:
 if (!get_opcr_online(*opcr) || !get_opcr_p2p_connections(*opcr) ||
     get_opcr_channel(*opcr) != channel) {
  dev_err(fdtv->device, "CMP: no connection to break\n");
  return;
 }

 old_opcr = *opcr;
 set_opcr_p2p_connections(opcr, get_opcr_p2p_connections(*opcr) - 1);

 opcr[1] = *opcr;
 opcr[0] = old_opcr;

 if (cmp_lock(fdtv, opcr_address, opcr) < 0)
  return;

 if (old_opcr != *opcr) {
  /*
 * FIXME: if old_opcr.P2P_Connections == 1, i.e. we were last
 * owner, deallocate isochronous channel and bandwidth at IRM
 * if (...)
 * fdtv->backend->dealloc_resources(fdtv, channel, bw);
 */


  if (++attempts < 6) /* arbitrary limit */
   goto repeat;
 }
}

Messung V0.5
C=94 H=91 G=92

¤ Dauer der Verarbeitung: 0.16 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.