Background technology
Along with the development of electronic technology, the application of the electric terminals such as mobile phone and panel computer is increasingly extensive.The hardware device kind that is applied to mobile terminal is also more and more, and the driver corresponding with hardware device is also more and more important.
Device driver (Device Driver) is a kind of operating system and mutual program of hardware of allowing, it is the software of a kind of on-line operation on various hardware devices, this program creation hardware and hardware, or the interface of hardware and software communication, pass through just driver, various hardware devices could normally move, and reach set target.
Please refer to Fig. 1, Fig. 1 is the collocation method of prior art driver, comprising: step S101, electric terminal os starting; Step S102, articulates file system; Step S103, booting script, according to different electronic equipment hardware, inserts corresponding hardware drive program to system kernel space.
Because the driver of prior art designs respectively for each hardware often, that is to say, for different hardware, need different drivings.In prior art, for the writing of hardware drive program, conventionally need to first understand the parameter of hardware device, then write code flow and realize the drive software for this model hardware device, after the steps such as debugging compiling, download to terminal device.Due to the driver of writing in the manner described above for hardware device there is unicity, in the time that hardware device changes, owing to having made corresponding modification on hardware, driver also needs to modify.
The pattern that above-mentioned driver designs respectively for each hardware device, has brought problems.First, Driver Development personnel need to understand principle of work and the relevant parameter of hardware device, and most of drivers operate in core schema, the mistake of drive software often causes serious unstable of system, and to Driver Development, personnel have proposed high requirement; Secondly, owing to writing respectively, debug and the step such as compiling for the driver of each hardware device, cause the construction cycle of these drivings long, also need to safeguard the different driving program corresponding with it for different hardware devices; In addition, if the parameter of hardware device changes, need to revise the configuration data driving, also need to compile driver code and even entirely compile whole engineering, lose time.
The U.S. Patent application that more prior aries can also be US6757070B1 with reference to publication number, it discloses a kind of general printed driver.
Summary of the invention
The problem that the present invention solves is that prior art is low for the efficiency of each hardware device difference design driven program, and cost is high.
For addressing the above problem, technical solution of the present invention provides a kind of collocation method of driver, comprising: in the time that needs start certain equipment, in electric terminal, the device drives code corresponding with this equipment obtains corresponding configuration item data from electric terminal.
Optionally, described configuration item data and current device model match.
Optionally, described configuration item data are to be loaded into internal memory from the quick promoter region of electric terminal.
Optionally, described device drives code obtains corresponding configuration item data and carries out according to facility information and configuration item mark from electric terminal.
Optionally, the collocation method of described driver also comprises, the configuration item data to text formatting in development platform are edited, and the Platform Type in configuration item data and current device model and the described electric terminal of described text formatting is matched; The configuration item data of described text formatting are resolved, generate binary format configuration item data; Described binary format configuration item data are stored into the quick promoter region of electric terminal.
Optionally, the configuration item data of described text formatting are resolved, when generating binary format configuration item data, generate and resolve daily record and debugging file.
Optionally, described parsing log packet is contained in the information that reports an error producing while resolving the configuration item data of described text formatting, described in the information of reporting an error comprise that disappearance warning and form warn.
Optionally, described debugging file is for showing the content of described binary format configuration item data.
Optionally, described device drives code can be used for the equipment of the same type of distinct device model.
Optionally, described configuration item data can be used for dissimilar platform.
Optionally, described equipment is display screen, and described configuration item data comprise display resolution, display screen interface pattern, display screen display direction, mode bus and highway width.
Optionally, described equipment is camera, and described configuration item data comprise the size of output image, the form of output image, pattern, viewfinder mode and the color effect of output image.
Optionally, described equipment is touch pad, described configuration item data comprise maximum touch count, virtual key coordinate, button size and down trigger mode.
Compared with prior art, technical solution of the present invention has the following advantages:
In the collocation method of the driver of technical solution of the present invention, the configuration item data of device drives code and equipment are separated, and layout type data and current device model match, and device drives code can be used for the equipment of different models.In the time that needs start certain equipment, in electric terminal, the device drives code corresponding with this equipment obtains corresponding configuration item data from electric terminal, forms the driver that is applicable to current device, drives this equipment.Because device drives code and configuration item data are separated, configuration item data can flexible configuration, in the time that certain unit type of electric terminal changes, Driver Development personnel only need to revise configuration item data according to current device, just can complete and drive exploitation, without the variation because of unit type, recompilate code or entirely compile whole engineering, for the development of driver has brought facility.
Further, because configuration item data have comprised the parameter information of concrete model device, irrelevant with the Platform Type of electric terminal, therefore described configuration item data can cross-platformly be used, and have reduced the development amount that drives developer.
Embodiment
From background technology, prior art is for the hardware device design driven program respectively of each model, and efficiency is low, and cost is high.
For this problem, embodiment of the present invention provides a kind of collocation method of driver, in the time that needs start certain equipment, in electric terminal, the device drives code corresponding with this equipment obtains corresponding configuration item data from electric terminal, formation is applicable to the driver of current device, drives this equipment.Because device drives code and configuration item data are separated, configuration item data can flexible configuration, in the time that certain unit type of electric terminal changes, Driver Development personnel only need to revise configuration item data according to current device, just can complete and drive exploitation, without the variation because of unit type, recompilate code or entirely compile whole engineering, for the development of driver has brought facility.
Below in conjunction with accompanying drawing, the collocation method of embodiment of the present invention driver is described in detail, so that above-mentioned object and advantage of the present invention will be clearer.
Please refer to Fig. 2, Fig. 2 is the schematic flow sheet of the collocation method of the driver of the embodiment of the present invention.The collocation method of described driver comprises:
Step S201, according to the configuration item data of current device model Edit Text form.
In electric terminal, conventional equipment comprises universal input/output device, display screen, camera, touch pad, gravity sensor, optical sensor and back light apparatus etc.Described electric terminal can be mobile phone, panel computer and handheld device etc.Due to the development of electronic technology, the hardware device that is applied to electric terminal is more and more, and equipment of the same type also has different models, and the equipment for different model in prior art need to be write different drivers, and cost is high.In the present embodiment, first unified by the driver of the equipment of of the same type, different model is integrated, assemble a universal driver of supporting different model equipment.The driving code in described universal driver and configuration item data are separated, described driving code and device type match again, and described driving code can be used for the driving of the equipment of different model of the same type; Described configuration item data are corresponding with the equipment of concrete model, by editing described configuration item data, just can realize flexibly the driver deployment of the equipment of the same type of various models.
Concrete, by extracting the configuration item data in universal driver, generate the configuration item data file of text formatting, in development platform, the configuration item data of described text formatting are edited, described development platform can be PC or server terminal.Described edits and refers to the configuration item data of text formatting in development platform, for the current device in current electric terminal, the parameter of configuration item data is carried out to assignment, makes described configuration item data corresponding with the hardware parameter of current device.Concrete configuration item data are provided by the supplier of current device or by obtaining after the hardware parameter analysis to current device.
In the present embodiment, the configuration item data of described text formatting comprise facility information (Section), configuration item mark (Key) and configuration item numerical value (Value).The form of the configuration item data of the concrete text formatting of explanation as an example of display screen (LCD) example below:
Wherein use " [] " to carry out indication equipment information, for example " [lcd0] " expression current device is display screen; Use "=" to connect configuration item mark and configuration item numerical value, for example " lcd_width=480 " represents that the width resolution of current device display screen is 480, and the support of described configuration item numerical value is many-valued, separates with comma, described configuration item Data support line feed, separates with branch; Represent to annotate by " # ", each configuration item is described.In the time that described equipment is display screen, described configuration item data comprise the information such as display resolution, display screen interface pattern, display screen display direction, mode bus and highway width.
Described equipment can also be camera, and described configuration item data comprise the size of output image, the information such as form, pattern, viewfinder mode and the color effect of output image of output image.Described equipment can be also touch pad, described configuration item data comprise maximum touch count, virtual key coordinate, button size and down trigger mode etc.
Because described configuration item data and the hardware of concrete equipment form and parameter correlation, irrelevant with the Platform Type of electric terminal, therefore equipment supplier provides the hardware of concrete equipment to form and parameter, the configuration item data that drive developer to write out the text formatting corresponding with concrete equipment, described configuration item data can cross-platformly be used, without again writing configuration item data for different platform, greatly reduce the workload that drives developer.
It should be noted that, in described device drives code, include facility information and configuration item mark, and corresponding with facility information and configuration item mark in the configuration item data of described text formatting.By the configuration item data at text formatting described in development platform editor, configuration item data and the current device model of described text formatting are matched, in subsequent step, described text formatting configuration item data are resolved and generate binary format configuration item data.Described device drives code obtains described binary format configuration item data by facility information and configuration item mark, forms driver, drives current device.
Step S202, resolves the configuration item data of text formatting, generates binary format configuration item data.
On the bright platform of exploitation, adopt the configuration item data of text formatting to be conducive to Driver Development personnel for current device model editor configuration item data, but what in electric terminal, adopt is binary format data, therefore need the configuration item data of text formatting to resolve, generate binary format configuration item data.
Concrete, the configuration item data of described text formatting are resolved, comprise the configuration item data of described text formatting are converted to binary format configuration item data, generate simultaneously and resolve daily record and debugging file.The follow-up electric terminal that stores into of described binary format configuration item data, is used to form the driver that is applicable to current device.
Described parsing log packet is contained in the information that reports an error producing while resolving the configuration item data of described text formatting, described in the information of reporting an error comprise that disappearance warning (Missing Warning) and form warn (Format Warning).In resolving, the facility information comprising in the configuration item data of text formatting and configuration item mark are checked, if described configuration item mark does not have corresponding configuration item numerical value, produce disappearance warning, alert device information and configuration item identify the corresponding undefined assignment of configuration item data; If contain format error in the configuration data of text formatting, for example between configuration item mark and configuration item numerical value, lack junction symbol "=", or facility information and configuration item are designated redundant term, facility information and configuration item and are designated void item, produce form warning, in the configuration item data of prompting text formatting, have form problem.
Described debugging file is used for showing the content of the binary format configuration item data of the configuration item data generation of resolving described text formatting.Described debugging file is text formatting, facilitates Driver Development personnel by reading described debugging file, debugging binary format configuration item data.
In electric terminal, conventionally include multiple equipment, each equipment all has the configuration item data of corresponding text formatting, and the parsing of the configuration item data to multiple text formattings can be managed by master control file is set.Below by the form of bright master control file for instance:
Wherein enumerate the configuration item data file of the text formatting corresponding with facility information, be specially universal input/output device, back light apparatus, display screen, touch-screen, camera and gravity sensor equipment.Resolve in the configuration item data to text formatting, generate in the process of binary format configuration item data, analytical tool only need be selected the master control file of electric terminal, the configuration item data file of the text formatting of quoting according to master control file, just can resolve the configuration item data of the text formatting of each equipment of electric terminal.In addition, in the time that current electric terminal does not have certain equipment, only need before facility information, add " # " number comments out corresponding row, just can not resolve the configuration item data file of the text formatting of this row.Therefore can be for the equipment configuring condition of current electric terminal by master control file, convenient interpolation and sweep equipment information,
Step S203, stores binary format configuration item data into the quick promoter region (Fastboot district) of electric terminal.
By flashburn tools, the scale-of-two configuration item data programming obtaining after above-mentioned parsing text formatting is arrived to the nonvolatile storage of electric terminal.In the present embodiment, the programming of described scale-of-two configuration item data is entered to quick promoter region, described quick promoter region is present in nonvolatile memory, described nonvolatile memory can be Nandflash(Nand flash memory), Norflash(Nor flash memory), the embedded storer of EMMC(), SD card or hard disk etc., can obliterated data in the time of power down.Therefore, for current electric terminal, the programming of described binary format configuration item data is entered behind quick promoter region, without repeating programming.In the time that electric terminal starts, can automatically load binary format configuration item data from quick promoter region to region of memory, drive code to form the driver that is applicable to current device with cooperating equipment, carry out driving arrangement.
Step S204, is loaded into internal memory by described binary format configuration item data.
In the time that electric terminal starts, electric terminal is loaded into binary format configuration item data the appointed area of internal memory, after common described binary format configuration item data place region of memory is positioned at kernel (Kernel) program region.Described kernel program refers to that comprising one realizes micro-kernel minimal features and comparatively speaking less, its management equipment driver, message, thread and virtual memory etc.Other functions are by modularization, by using inter-process communication mechanisms to communicate by letter with kernel program.Therefore,, before loading described binary format configuration item data, need to first load kernel program.
It should be noted that, in the time that described equipment is camera, the configuration item data corresponding with camera are not loaded into region of memory after electric terminal starts, but start camera program user, while using camera, the binary configuration item data corresponding with camera apparatus are loaded into internal memory.
Step S205, device drives code obtains corresponding configuration item data according to facility information and configuration item mark.
In device drives code, define the data structure corresponding with configuration item data, below the described data structure corresponding with configuration item data of explanation as an example of touch pad (TP:Touch Panel) example:
Wherein, data structure struct udc_tp_cfg has described attribute and the coordinate calculating parameter etc. of touch pad.Data structure structtp_param has described the parameter of touch pad.
Device drives code obtains the configuration information about touch pad in binary format configuration item data by calling interface function from internal memory, then device drives code uses the configuration information Update Table structure " struct udc_tp_cfg " that gets and the content of " struct tp_param ", formation is applicable to the driver of current touch pad, drives touch panel device.
Described device drives code obtains corresponding configuration item data from electric terminal to carry out according to facility information and configuration item mark.Concrete, in the time of electric terminal initialization or kernel loads, load described device drives code, described device drives code can be searched facility information and the equipment item mark in binary format configuration item data by calling interface function, then obtains with described equipment item and identifies corresponding configuration item numerical value.Obtain after corresponding configuration item data according to facility information and configuration item mark at device drives code, then complete the registration of driver and the realization of application programming interfaces (API) according to obtained configuration item data.
In the present embodiment, by driver of the same type, different model equipment is integrated and is formed after reunification universal driver, and then by described universal driver with concrete device-dependent configuration item data separating after forming device drive code, therefore described device drives code has versatility, be applicable to the equipment of the same type of distinct device model, in the time that certain unit type of electric terminal changes, Driver Development personnel only need to revise configuration item data according to current device, just can complete and drive exploitation.
Therefore, adopt the device drives collocation method in the present embodiment, layout type data and current device model match, and device drives code can be used for the equipment of different models.In the time that needs start certain equipment, in electric terminal, the device drives code corresponding with this equipment obtains corresponding configuration item data from electric terminal, forms the driver that is applicable to current device, drives this equipment.Owing to driving code and configuration item data to be separated, configuration item data can flexible configuration, in the time that certain unit type of electric terminal changes, Driver Development personnel only need to revise configuration item data according to current device, just can complete and drive exploitation, without the variation because of unit type, recompilate code or entirely compile whole engineering, for the development of driver has brought facility.
Further, because configuration item data have comprised the parameter information of concrete model device, irrelevant with the Platform Type of electric terminal, therefore described configuration item data can cross-platformly be used, and have reduced the development amount that drives developer.
Although the present invention with preferred embodiment openly as above; but it is not for limiting the present invention; any those skilled in the art without departing from the spirit and scope of the present invention; can utilize method and the technology of above-mentioned announcement to make possible variation and modification to technical solution of the present invention; therefore; every content that does not depart from technical solution of the present invention; any simple modification, equivalent variations and the modification above embodiment done according to technical spirit of the present invention, all belong to the protection domain of technical solution of the present invention.