1 | |
---|
2 | #include "pti.h" |
---|
3 | #include "pti_main.h" |
---|
4 | #include "pti_session.h" |
---|
5 | |
---|
6 | static u32 St20ToTcRamAddress(u32 SomeSt20Address, STPTI_TCParameters_t *TC_Params_p) |
---|
7 | { |
---|
8 | return ((u32)((u8 *)SomeSt20Address - (u8 *)TC_Params_p->TC_DataStart + (u8 *)TC_DSRAM_BASE)); |
---|
9 | } |
---|
10 | |
---|
11 | void pti_session_set_source(int index, int tsmerger_tag) |
---|
12 | { |
---|
13 | TCSessionInfo_t *TCSessionInfo_p = &((TCSessionInfo_t *)tc_params.TC_SessionDataStart)[index]; |
---|
14 | if (tsmerger_tag != STPTI_STREAM_ID_NONE) |
---|
15 | { |
---|
16 | // check the usage of the given stream ID |
---|
17 | // there must be no other session using the same TS input stream |
---|
18 | // otherwise the setting would disturb data arrival for all sessions |
---|
19 | int i; |
---|
20 | for (i = 0; i < tc_params.TC_NumberOfSessions; i++) |
---|
21 | { |
---|
22 | TCSessionInfo_p = &((TCSessionInfo_t *)tc_params.TC_SessionDataStart)[i]; |
---|
23 | if (((readw(&TCSessionInfo_p->SessionTSmergerTag) & |
---|
24 | ~SESSION_USE_MERGER_FOR_STC) == tsmerger_tag) && (i != index)) |
---|
25 | { |
---|
26 | // source already in use |
---|
27 | printk("%s(%d,%x): ERROR STREAM ALREADY IN USE (%d)\n", __func__, index, tsmerger_tag, i); |
---|
28 | return; |
---|
29 | } |
---|
30 | } |
---|
31 | } |
---|
32 | TCSessionInfo_p = &((TCSessionInfo_t *)tc_params.TC_SessionDataStart)[index]; |
---|
33 | STSYS_WriteTCReg16LE(&TCSessionInfo_p->SessionTSmergerTag, |
---|
34 | tsmerger_tag | SESSION_USE_MERGER_FOR_STC); |
---|
35 | } |
---|
36 | |
---|
37 | /* ************************************** |
---|
38 | * Init Session and return session number |
---|
39 | */ |
---|
40 | int pti_session_init(int tsmerger_tag, int slotOffset, int numberSlots) |
---|
41 | { |
---|
42 | STPTI_TCParameters_t *TC_Params_p = &tc_params; |
---|
43 | TCSessionInfo_t *TCSessionInfo_p; |
---|
44 | u16 SlotsToAllocate; |
---|
45 | u16 BytesToAllocate; |
---|
46 | int session; |
---|
47 | //u8 numfilters; |
---|
48 | //int numblocks, filtermode, filtersperblock=SF_NUM_FILTERS_PER_BLOCK; |
---|
49 | // ****************************************** |
---|
50 | //stptiHAL_PeekNextFreeSession(FullHandle_t DeviceHandle) |
---|
51 | for (session = 0; session < TC_Params_p->TC_NumberOfSessions; session++) |
---|
52 | { |
---|
53 | TCSessionInfo_p = &((TCSessionInfo_t *)TC_Params_p->TC_SessionDataStart)[session]; |
---|
54 | if (readw((void *)&TCSessionInfo_p->SessionTSmergerTag) == SESSION_NOT_ALLOCATED) |
---|
55 | { |
---|
56 | printk("Free session: %d\n", session); |
---|
57 | break; |
---|
58 | } |
---|
59 | } |
---|
60 | if (session == TC_Params_p->TC_NumberOfSessions) |
---|
61 | { |
---|
62 | printk("No free session !!!!!!!!!!!!!!!!\n"); |
---|
63 | return -1; |
---|
64 | } |
---|
65 | else |
---|
66 | { |
---|
67 | printk("Using session %d\n", session); |
---|
68 | } |
---|
69 | // ****************************************************** |
---|
70 | //stptiHAL_GetNextFreeSession(FullHandle_t DeviceHandle) |
---|
71 | TCSessionInfo_p = &((TCSessionInfo_t *)TC_Params_p->TC_SessionDataStart)[session]; |
---|
72 | pti_session_set_source(session, tsmerger_tag); |
---|
73 | // ******************************************************************** |
---|
74 | //stptiHelper_TCInit_SessionInfoModeFlags( FullHandle_t DeviceHandle ) |
---|
75 | /* Set DiscardSynchByte bit in the global data structure if STPTI has been initialised with this option */ |
---|
76 | /* See DDTS GNBvd08680 PJW */ |
---|
77 | // if ( (Device_p->TCCodes == STPTI_SUPPORTED_TCCODES_SUPPORTS_DVB) |
---|
78 | /* DVB has a 1 byte header (the sync byte) */ |
---|
79 | STSYS_SetTCMask16LE((void *)&TCSessionInfo_p->SessionModeFlags, (TC_GLOBAL_DATA_DISCARD_SYNC_BYTE_SET)); |
---|
80 | STSYS_WriteTCReg16LE((void *)&TCSessionInfo_p->SessionDiscardParams, 1); |
---|
81 | // ******************************************************** |
---|
82 | //stptiHelper_SlotList_Alloc( FullHandle_t DeviceHandle ) |
---|
83 | SlotsToAllocate = numberSlots; |
---|
84 | BytesToAllocate = SlotsToAllocate * 2; |
---|
85 | STSYS_WriteTCReg16LE((void *)&TCSessionInfo_p->SessionPIDFilterStartAddr, St20ToTcRamAddress((u32)TC_Params_p->TC_LookupTableStart + slotOffset * 2, TC_Params_p)); |
---|
86 | STSYS_WriteTCReg16LE((void *)&TCSessionInfo_p->SessionPIDFilterLength, SlotsToAllocate); |
---|
87 | // ***************************************************************** |
---|
88 | //TcCam_FilterAllocateSession( FullHandle_t DeviceHandle ) |
---|
89 | // case STPTI_FILTER_OPERATING_MODE_NONE: |
---|
90 | /* invalid filter mode i.e. all bits set - TC_SESSION_INFO_FILTER_TYPE_FIELD */ |
---|
91 | STSYS_WriteTCReg16LE((void *)&TCSessionInfo_p->SessionSectionParams, |
---|
92 | TC_SESSION_INFO_FILTER_TYPE_FIELD); |
---|
93 | STSYS_SetTCMask16LE((void *)&TCSessionInfo_p->SessionSectionParams, TC_SESSION_DVB_PACKET_FORMAT); |
---|
94 | STSYS_SetTCMask16LE((void *)&TCSessionInfo_p->SessionSectionParams, TC_SESSION_INFO_FORCECRCSTATE | TC_SESSION_INFO_DISCARDONCRCERROR); |
---|
95 | /* nothing allocated yet, so nothing enabled from our FilterList_p[n] */ |
---|
96 | writel(0, (void *)&TCSessionInfo_p->SectionEnables_0_31); |
---|
97 | writel(0, (void *)&TCSessionInfo_p->SectionEnables_32_63); |
---|
98 | #if defined(SECURE_LITE2) |
---|
99 | writel(0, (void *)&TCSessionInfo_p->SectionEnables_64_95); |
---|
100 | writel(0, (void *)&TCSessionInfo_p->SectionEnables_96_127); |
---|
101 | #endif |
---|
102 | /* --- setup TC RAM CAM configuration --- */ |
---|
103 | //STSYS_WriteTCReg16LE((void*)&TCSessionInfo_p->SessionCAMConfig, CAM_CFG_64_FILTERS ); |
---|
104 | /* --- setup TC RAM CAM base address --- */ |
---|
105 | /* Note: SessionCAMFilterStartAddr is at bit position 7:1 (7 bits) */ |
---|
106 | /* point to just past start of reserved area (0x304) */ |
---|
107 | //fixme: dies wird nur beim ersten mal gesetzt (siehe if abfrage im original, |
---|
108 | //ansonsten wird was anderes gemacht!) |
---|
109 | //STSYS_WriteTCReg16LE((void*)&TCSessionInfo_p->SessionCAMFilterStartAddr, (0xC1 << 1) ); /* 0x182 */ |
---|
110 | return session; |
---|
111 | } |
---|