Institutionen För Datavetenskap Department of Computer and Information Science
Total Page:16
File Type:pdf, Size:1020Kb
Institutionen för datavetenskap Department of Computer and Information Science Final thesis Simulation of Set-top box Components on an X86 Architecture by Implementing a Hardware Abstraction Layer by Faruk Emre Sahin Muhammad Salman Khan LITH-IDA-EX—10/050--SE 2010-12-25 Linköpings universitet Linköpings universitet SE-581 83 Linköping, Sweden 581 83 Linköping Linköping University Department of Computer and Information Science Final Thesis Simulation of Set-top box Components on an X86 Architecture by Implementing a Hardware Abstraction Layer by Faruk Emre Sahin Muhammad Salman Khan LITH-IDA-EX—10/050—SE 2010-12-25 Supervisors: Fredrik Hallenberg, Tomas Taleus R&D at Motorola (Linköping) Examiner: Prof. Dr. Christoph Kessler Dept. Of Computer and Information Science at Linköpings universitet Abstract The KreaTV Application Development Kit (ADK) product of Motorola en- ables application developers to create high level applications and browser plugins for the IPSTB system. As a result, customers will reduce develop- ment time, cost and supplier dependency. The main goal of this thesis was to port this platform to a standard Linux PC to make it easy to trace the bugs and debug the code. This work has been done by implementing a hardware abstraction layer(HAL)for Linux Operating System. HAL encapsulates the hardware dependent code and HAL APIs provide an abstraction of underlying architecture to the oper- ating system and to application software. So, the embedded platform can be emulated on a standard Linux PC by implementing a HAL for it. We have successfully built the basic building blocks of HAL with some performance degradation. We are able to start up the application platform, use graphics mixing features and play a video via filtering the data from the transport stream and decoding it. But there is still a lot of work to do to build the whole HAL for all the platform to be run smoothly as they do on a set-top box hardware. Keywords : Simulation, Hardware Abstraction Layer iii iv Acknowledgements We are thankful to our supervisors, Fredrik Hallenberg and Tomas Taleus, whose concern, guidance and support from the initial to the final stage of the thesis enabled us to perform a successful work. We also want to thank to our examiner Christoph Kessler for his helps and advices throughout the thesis. v Preface This thesis has been performed at Motorola, Kreatel Communications AB by Faruk Emre Sahin and Muhammad Salman Khan. This company pro- vides a platform called KreaTV for fast high level application development and integration on different STBs to its clients offering reduced develop- ment time, cost and supplier dependency. Faruk mainly worked on graphics mixing fixtures while Salman worked on multiplexer and video decoding part. Accordingly, chapter 1, section 2.2, 3.1, 3.3, 4.1, 4.2, 5.1-5.4 and 6.1 have been written by Faruk and reviewed by Salman. Section 2.3, 5.5-5.8, 6.2 are written by Salman and reviewed by Faruk. Section 2.1,3.2 4.3, 4.4 and chapter 7 are co-authored by both Faruk and Salman. vi Contents 1 Introduction 1 1.1 Background . 1 1.2 Problem . 2 1.3 Method of Thesis Work . 3 1.3.1 Philosophy . 3 1.3.2 Work Process . 3 1.4 Reading Instructions . 4 2 Background 5 2.1 Inter Process Communication . 5 2.2 Graphics Handling . 7 2.2.1 Pixel . 7 2.2.2 Blitting . 7 2.2.3 Alpha Blending . 8 2.2.4 Color Keying . 8 2.2.5 Clipping . 8 2.3 MPEG.............................. 9 vii CONTENTS viii 2.3.1 Transport Stream . 9 2.3.2 TS Packet fields . 10 SYNC Byte . 10 Transport Priority (TPR), Payload Unit Start (PUS), Error Indicator (EI) . 11 Packet Identifier (PID) . 11 2.3.3 Scrambling Control (SCR) . 11 2.3.4 Adaption Field (AF) . 11 2.3.5 Continuity Check Index (CC) . 12 2.3.6 Program Specific Information (PSI) . 12 Program Association Table (PAT) . 13 Program Map Table (PMT) . 14 3 System Architecture 15 3.1 General Architecture . 15 3.2 Hardware Abstraction Layer Overview . 16 3.2.1 Hardware Abstraction Interface . 17 3.2.2 Resources . 17 3.3 Inter-Process Communication . 20 4 Problem Analysis 22 4.1 Problem . 22 4.1.1 Debugging in Embedded Systems . 22 4.2 Solution . 23 4.3 Requirements . 24 4.3.1 Restrictions . 24 CONTENTS ix 4.3.2 Hardware Abstraction Interface . 25 4.3.3 Graphics Memory Resource . 25 4.3.4 Graphics Layer Resource . 25 4.3.5 Graphics Blitter Resource . 25 4.3.6 Demuxer Resource . 26 4.3.7 Media Decoder Resource . 26 4.3.8 Video Layer Resource . 26 4.4 Review of Related Work . 27 5 Design and Implementation 29 5.1 Graphics Handling . 29 5.1.1 Library Choice . 30 DirectFB . 31 SDL........................... 31 Comparison of SDL and DirectFB . 32 5.2 PC-HAL Memory Resource . 33 5.2.1 Unix Mmap function . 33 5.3 PC-HAL Graphics Layer Resource . 35 5.3.1 Update Screen . 35 5.4 PC-HAL Graphics Blitter Resource . 36 5.5 PC-HAL Stream Input Resource . 37 5.6 The PC-HAL Demuxer Resource . 38 5.6.1 Connect Input Interface . 39 5.6.2 Get Format Interface . 40 5.6.3 Set Format Interface . 41 5.6.4 Create Output Interface . 41 CONTENTS x 5.6.5 Destroy Output Interface . 42 5.6.6 Open Output Pipe Interface . 42 5.6.7 Close Output Interface . 44 5.6.8 Add Packet Filter Interface . 44 5.6.9 Remove Packet Filter Interface . 45 5.7 The PC-HAL Media Decoder Resource . 46 5.7.1 Interface Description . 47 Decoder States . 47 5.7.2 Reset Interface . 48 5.7.3 Halt Interface . 49 5.7.4 Run Interface . 49 5.7.5 Set Format Interface . 50 5.8 Testing of PC-HAL Resources . 51 6 Results and Evaluation 53 6.1 Graphics Mixing . 53 6.2 PC-HAL Demuxer Performance . 54 6.2.1 Testing with Same Buffer Size . 55 6.2.2 Testing with different Buffer Sizes . 55 7 Conclusion and Future Work 58 Glossary 60 Acronyms 63 Bibliography 65 Chapter 1 Introduction 1.1 Background A set-top box which is often abbreviated as STB is a small computer with limited number of resources connected to a digital television. It differs from conventional personal computers due to limited computation power, small memory, and dedicated I/O resources. The input of STB is a source of signal and STB turns the signal into an understandable content which at the end is displayed on TV or another display device. The STB handles different types of inputs such as inputs from satellite and digital streams from the IP based network. A typical digital set-top box contains one or more microprocessors to run the operating system, possibly Linux or Windows, and to parse the MPEG transport stream. A set-top box also includes Random Access Memory (RAM), an MPEG decoder chip, and more chips for audio decoding and processing. The contents of a set-top box depend on the Digital Television (DTV) standard used. The term set-top box basically describes the platform device connected to TV set as its output and broadband network connection as input. The STB accepts commands from the end user often with a remote device and 1 Introduction 2 transmits these commands to the network operator through some sort of return path. Most set-top boxes deployed today have return path capabil- ity for two-way communication. The typical applications related to STB include digital video channel broadcasting, video on demand, web browsing and similar other common applications. This thesis has been performed at Motorola, Kreatel Communications AB. This company provides a platform called KreaTV for fast high level appli- cation development and integration on different STBs to its clients offering reduced development time, cost and supplier dependency. 1.2 Problem The KreaTV platform is currently running on dedicated hardware. This hardware consists of multiple resources to accomplish the necessary tasks related to IPTV applications. These hardware resources are designed specif- ically to handle the business requirements of the IPTV users. Therefore, they have less capabilities and consume less power in comparison to a stan- dard Personal Computer (PC). From the user perspective, the IPSTB hard- ware is good enough to satisfy video broadcasting, web browsing and sim- ilar requirements. However, from the developers and testers perspective, developing and testing the system on an embedded machine can be quite tedious. In the past, the IPSTB has been restricted by low broadband connections and high cost of infrastructure to transport the IPTV traffic to consumer home. But nowadays, IPTV is growing at a very fast pace as high speed broadband connection is available to millions of households worldwide and it is expected to continue growing in the near future. Due to the increasing demands and expectations from the consumer market, IPSTB software and hardware is growing to satisfy the user requirements. The Hybrid Set- top boxes allow traditional TV broadcast such as terrestrial, satellite or cable TV providers to be brought together with the video delivered over the Internet. Therefore, vendors are providing some other applications such as browsers with their set-top boxes to attract consumers with all- Introduction 3 in-one pattern. With the increasing number of applications on IPSTB such as Internet browsers and multimedia applications, the complexity of set-top boxes increases. The software quality becomes the challenge for the software engineers as many bugs are introduced with the increasing complexity of the software.