xref: /aosp_15_r20/external/rmi4utils/f54test/f54test.cpp (revision a248dafd7653b99fc45f9d29e5f139b04f2f28bc)
1*a248dafdSChristopher Ferris /*
2*a248dafdSChristopher Ferris  * Copyright (C) 2014 Satoshi Noguchi
3*a248dafdSChristopher Ferris  * Copyright (C) 2014 Synaptics Inc
4*a248dafdSChristopher Ferris  *
5*a248dafdSChristopher Ferris  * Licensed under the Apache License, Version 2.0 (the "License");
6*a248dafdSChristopher Ferris  * you may not use this file except in compliance with the License.
7*a248dafdSChristopher Ferris  * You may obtain a copy of the License at
8*a248dafdSChristopher Ferris  *
9*a248dafdSChristopher Ferris  *      http://www.apache.org/licenses/LICENSE-2.0
10*a248dafdSChristopher Ferris  *
11*a248dafdSChristopher Ferris  * Unless required by applicable law or agreed to in writing, software
12*a248dafdSChristopher Ferris  * distributed under the License is distributed on an "AS IS" BASIS,
13*a248dafdSChristopher Ferris  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*a248dafdSChristopher Ferris  * See the License for the specific language governing permissions and
15*a248dafdSChristopher Ferris  * limitations under the License.
16*a248dafdSChristopher Ferris  */
17*a248dafdSChristopher Ferris 
18*a248dafdSChristopher Ferris #include <alloca.h>
19*a248dafdSChristopher Ferris #include <time.h>
20*a248dafdSChristopher Ferris #include <stdint.h>
21*a248dafdSChristopher Ferris #include <stdio.h>
22*a248dafdSChristopher Ferris #include <unistd.h>
23*a248dafdSChristopher Ferris #include <string.h>
24*a248dafdSChristopher Ferris #include <stdlib.h>
25*a248dafdSChristopher Ferris #include <errno.h>
26*a248dafdSChristopher Ferris #include <math.h>
27*a248dafdSChristopher Ferris 
28*a248dafdSChristopher Ferris #include "testutil.h"
29*a248dafdSChristopher Ferris #include "f54test.h"
30*a248dafdSChristopher Ferris #include "rmidevice.h"
31*a248dafdSChristopher Ferris #include "display.h"
32*a248dafdSChristopher Ferris 
33*a248dafdSChristopher Ferris /* Most recent device status event */
34*a248dafdSChristopher Ferris #define RMI_F01_STATUS_CODE(status)		((status) & 0x0f)
35*a248dafdSChristopher Ferris /* Indicates that flash programming is enabled (bootloader mode). */
36*a248dafdSChristopher Ferris #define RMI_F01_STATUS_BOOTLOADER(status)	(!!((status) & 0x40))
37*a248dafdSChristopher Ferris #define NO_SLEEP_OFF (0 << 2)
38*a248dafdSChristopher Ferris #define NO_SLEEP_ON (1 << 2)
39*a248dafdSChristopher Ferris 
40*a248dafdSChristopher Ferris /*
41*a248dafdSChristopher Ferris  * Sleep mode controls power management on the device and affects all
42*a248dafdSChristopher Ferris  * functions of the device.
43*a248dafdSChristopher Ferris  */
44*a248dafdSChristopher Ferris #define RMI_F01_CTRL0_SLEEP_MODE_MASK	0x03
45*a248dafdSChristopher Ferris 
46*a248dafdSChristopher Ferris #define RMI_SLEEP_MODE_NORMAL		0x00
47*a248dafdSChristopher Ferris #define RMI_SLEEP_MODE_SENSOR_SLEEP	0x01
48*a248dafdSChristopher Ferris #define RMI_SLEEP_MODE_RESERVED0	0x02
49*a248dafdSChristopher Ferris #define RMI_SLEEP_MODE_RESERVED1	0x03
50*a248dafdSChristopher Ferris 
51*a248dafdSChristopher Ferris /*
52*a248dafdSChristopher Ferris  * This bit disables whatever sleep mode may be selected by the sleep_mode
53*a248dafdSChristopher Ferris  * field and forces the device to run at full power without sleeping.
54*a248dafdSChristopher Ferris  */
55*a248dafdSChristopher Ferris #define RMI_F01_CRTL0_NOSLEEP_BIT	(1 << 2)
56*a248dafdSChristopher Ferris 
~F54Test()57*a248dafdSChristopher Ferris F54Test::~F54Test()
58*a248dafdSChristopher Ferris {
59*a248dafdSChristopher Ferris 	if (m_txAssignment != NULL) delete [] m_txAssignment;
60*a248dafdSChristopher Ferris 	if (m_rxAssignment != NULL) delete [] m_rxAssignment;
61*a248dafdSChristopher Ferris }
62*a248dafdSChristopher Ferris 
Prepare(f54_report_types reportType)63*a248dafdSChristopher Ferris int F54Test::Prepare(f54_report_types reportType)
64*a248dafdSChristopher Ferris {
65*a248dafdSChristopher Ferris 	int retval;
66*a248dafdSChristopher Ferris 	unsigned char data;
67*a248dafdSChristopher Ferris 
68*a248dafdSChristopher Ferris 	retval = FindTestFunctions();
69*a248dafdSChristopher Ferris 	if (retval != TEST_SUCCESS)
70*a248dafdSChristopher Ferris 		return retval;
71*a248dafdSChristopher Ferris 
72*a248dafdSChristopher Ferris 	retval = m_device.QueryBasicProperties();
73*a248dafdSChristopher Ferris 	if (retval < 0)
74*a248dafdSChristopher Ferris 		return TEST_FAIL_QUERY_BASIC_PROPERTIES;
75*a248dafdSChristopher Ferris 
76*a248dafdSChristopher Ferris 	retval = ReadF54Queries();
77*a248dafdSChristopher Ferris 	if (retval != TEST_SUCCESS)
78*a248dafdSChristopher Ferris 		return retval;
79*a248dafdSChristopher Ferris 
80*a248dafdSChristopher Ferris 	retval = SetupF54Controls();
81*a248dafdSChristopher Ferris 	if (retval != TEST_SUCCESS)
82*a248dafdSChristopher Ferris 		return retval;
83*a248dafdSChristopher Ferris 
84*a248dafdSChristopher Ferris 	retval = ReadF55Queries();
85*a248dafdSChristopher Ferris 	if (retval != TEST_SUCCESS)
86*a248dafdSChristopher Ferris 		return retval;
87*a248dafdSChristopher Ferris 
88*a248dafdSChristopher Ferris 	retval = SetF54ReportType(reportType);
89*a248dafdSChristopher Ferris 	if (retval != TEST_SUCCESS)
90*a248dafdSChristopher Ferris 		return retval;
91*a248dafdSChristopher Ferris 
92*a248dafdSChristopher Ferris 	retval = SetF54Interrupt();
93*a248dafdSChristopher Ferris 	if (retval != TEST_SUCCESS)
94*a248dafdSChristopher Ferris 		return retval;
95*a248dafdSChristopher Ferris 
96*a248dafdSChristopher Ferris 	retval = DoPreparation();
97*a248dafdSChristopher Ferris 	if (retval != TEST_SUCCESS)
98*a248dafdSChristopher Ferris 		return retval;
99*a248dafdSChristopher Ferris 
100*a248dafdSChristopher Ferris 	data = (unsigned char)m_reportType;
101*a248dafdSChristopher Ferris 	retval = m_device.Write(m_f54.GetDataBase(), &data, 1);
102*a248dafdSChristopher Ferris 	if (retval < 0)
103*a248dafdSChristopher Ferris 		return retval;
104*a248dafdSChristopher Ferris 
105*a248dafdSChristopher Ferris 	return TEST_SUCCESS;
106*a248dafdSChristopher Ferris }
107*a248dafdSChristopher Ferris 
Run()108*a248dafdSChristopher Ferris int F54Test::Run()
109*a248dafdSChristopher Ferris {
110*a248dafdSChristopher Ferris 	int retval;
111*a248dafdSChristopher Ferris 	unsigned char command;
112*a248dafdSChristopher Ferris 
113*a248dafdSChristopher Ferris 	command = (unsigned char)COMMAND_GET_REPORT;
114*a248dafdSChristopher Ferris 	retval = DoF54Command(command);
115*a248dafdSChristopher Ferris 	if (retval != TEST_SUCCESS)
116*a248dafdSChristopher Ferris 		return retval;
117*a248dafdSChristopher Ferris 
118*a248dafdSChristopher Ferris 	retval = ReadF54Report();
119*a248dafdSChristopher Ferris 	if (retval != TEST_SUCCESS)
120*a248dafdSChristopher Ferris 		return retval;
121*a248dafdSChristopher Ferris 
122*a248dafdSChristopher Ferris 	retval = ShowF54Report();
123*a248dafdSChristopher Ferris 	if (retval != TEST_SUCCESS)
124*a248dafdSChristopher Ferris 		return retval;
125*a248dafdSChristopher Ferris 
126*a248dafdSChristopher Ferris 	return TEST_SUCCESS;
127*a248dafdSChristopher Ferris }
128*a248dafdSChristopher Ferris 
SetF54ReportType(f54_report_types report_type)129*a248dafdSChristopher Ferris int F54Test::SetF54ReportType(f54_report_types report_type)
130*a248dafdSChristopher Ferris {
131*a248dafdSChristopher Ferris 	switch (report_type) {
132*a248dafdSChristopher Ferris 	case F54_8BIT_IMAGE:
133*a248dafdSChristopher Ferris 	case F54_16BIT_IMAGE:
134*a248dafdSChristopher Ferris 	case F54_RAW_16BIT_IMAGE:
135*a248dafdSChristopher Ferris 	case F54_HIGH_RESISTANCE:
136*a248dafdSChristopher Ferris 	case F54_TX_TO_TX_SHORTS:
137*a248dafdSChristopher Ferris 	case F54_RX_TO_RX_SHORTS_1:
138*a248dafdSChristopher Ferris 	case F54_TRUE_BASELINE:
139*a248dafdSChristopher Ferris 	case F54_FULL_RAW_CAP_MIN_MAX:
140*a248dafdSChristopher Ferris 	case F54_RX_OPENS_1:
141*a248dafdSChristopher Ferris 	case F54_TX_OPENS:
142*a248dafdSChristopher Ferris 	case F54_TX_TO_GND_SHORTS:
143*a248dafdSChristopher Ferris 	case F54_RX_TO_RX_SHORTS_2:
144*a248dafdSChristopher Ferris 	case F54_RX_OPENS_2:
145*a248dafdSChristopher Ferris 	case F54_FULL_RAW_CAP:
146*a248dafdSChristopher Ferris 	case F54_FULL_RAW_CAP_NO_RX_COUPLING:
147*a248dafdSChristopher Ferris 	case F54_SENSOR_SPEED:
148*a248dafdSChristopher Ferris 	case F54_ADC_RANGE:
149*a248dafdSChristopher Ferris 	case F54_TRX_OPENS:
150*a248dafdSChristopher Ferris 	case F54_TRX_TO_GND_SHORTS:
151*a248dafdSChristopher Ferris 	case F54_TRX_SHORTS:
152*a248dafdSChristopher Ferris 	case F54_ABS_RAW_CAP:
153*a248dafdSChristopher Ferris 	case F54_ABS_DELTA_CAP:
154*a248dafdSChristopher Ferris 	case F54_GUARD_PIN_SHORT:
155*a248dafdSChristopher Ferris 		m_reportType = report_type;
156*a248dafdSChristopher Ferris 		return SetF54ReportSize(report_type);
157*a248dafdSChristopher Ferris 	default:
158*a248dafdSChristopher Ferris 		m_reportType = INVALID_REPORT_TYPE;
159*a248dafdSChristopher Ferris 		m_reportSize = 0;
160*a248dafdSChristopher Ferris 		return TEST_FAIL_INVALID_PARAMETER;
161*a248dafdSChristopher Ferris 	}
162*a248dafdSChristopher Ferris }
163*a248dafdSChristopher Ferris 
SetF54ReportSize(f54_report_types report_type)164*a248dafdSChristopher Ferris int F54Test::SetF54ReportSize(f54_report_types report_type)
165*a248dafdSChristopher Ferris {
166*a248dafdSChristopher Ferris 	int retval;
167*a248dafdSChristopher Ferris 	unsigned char tx = m_txAssigned;
168*a248dafdSChristopher Ferris 	unsigned char rx = m_rxAssigned;
169*a248dafdSChristopher Ferris 	char buf[256];
170*a248dafdSChristopher Ferris 
171*a248dafdSChristopher Ferris 	switch (report_type) {
172*a248dafdSChristopher Ferris 	case F54_8BIT_IMAGE:
173*a248dafdSChristopher Ferris 		m_reportSize = tx * rx;
174*a248dafdSChristopher Ferris 		break;
175*a248dafdSChristopher Ferris 	case F54_16BIT_IMAGE:
176*a248dafdSChristopher Ferris 	case F54_RAW_16BIT_IMAGE:
177*a248dafdSChristopher Ferris 	case F54_TRUE_BASELINE:
178*a248dafdSChristopher Ferris 	case F54_FULL_RAW_CAP:
179*a248dafdSChristopher Ferris 	case F54_FULL_RAW_CAP_NO_RX_COUPLING:
180*a248dafdSChristopher Ferris 	case F54_SENSOR_SPEED:
181*a248dafdSChristopher Ferris 		m_reportSize = 2 * tx * rx;
182*a248dafdSChristopher Ferris 		break;
183*a248dafdSChristopher Ferris 	case F54_HIGH_RESISTANCE:
184*a248dafdSChristopher Ferris 		m_reportSize = HIGH_RESISTANCE_DATA_SIZE;
185*a248dafdSChristopher Ferris 		break;
186*a248dafdSChristopher Ferris 	case F54_TX_TO_TX_SHORTS:
187*a248dafdSChristopher Ferris 	case F54_TX_OPENS:
188*a248dafdSChristopher Ferris 	case F54_TX_TO_GND_SHORTS:
189*a248dafdSChristopher Ferris 		m_reportSize = (tx + 7) / 8;
190*a248dafdSChristopher Ferris 		break;
191*a248dafdSChristopher Ferris 	case F54_RX_TO_RX_SHORTS_1:
192*a248dafdSChristopher Ferris 	case F54_RX_OPENS_1:
193*a248dafdSChristopher Ferris 		if (rx < tx)
194*a248dafdSChristopher Ferris 			m_reportSize = 2 * rx * rx;
195*a248dafdSChristopher Ferris 		else
196*a248dafdSChristopher Ferris 			m_reportSize = 2 * tx * rx;
197*a248dafdSChristopher Ferris 		break;
198*a248dafdSChristopher Ferris 	case F54_FULL_RAW_CAP_MIN_MAX:
199*a248dafdSChristopher Ferris 		m_reportSize = FULL_RAW_CAP_MIN_MAX_DATA_SIZE;
200*a248dafdSChristopher Ferris 		break;
201*a248dafdSChristopher Ferris 	case F54_RX_TO_RX_SHORTS_2:
202*a248dafdSChristopher Ferris 	case F54_RX_OPENS_2:
203*a248dafdSChristopher Ferris 		if (rx <= tx)
204*a248dafdSChristopher Ferris 			m_reportSize = 0;
205*a248dafdSChristopher Ferris 		else
206*a248dafdSChristopher Ferris 			m_reportSize = 2 * rx * (rx - tx);
207*a248dafdSChristopher Ferris 		break;
208*a248dafdSChristopher Ferris 	case F54_ADC_RANGE:
209*a248dafdSChristopher Ferris 		if (m_f54Query.has_signal_clarity) {
210*a248dafdSChristopher Ferris 
211*a248dafdSChristopher Ferris 			retval = m_device.Read(m_f54Control.reg_41.address,
212*a248dafdSChristopher Ferris 					m_f54Control.reg_41.data,
213*a248dafdSChristopher Ferris 					sizeof(m_f54Control.reg_41.data));
214*a248dafdSChristopher Ferris 			if (retval < 0) {
215*a248dafdSChristopher Ferris 				m_reportSize = 0;
216*a248dafdSChristopher Ferris 				break;
217*a248dafdSChristopher Ferris 			}
218*a248dafdSChristopher Ferris 			if (m_f54Control.reg_41.no_signal_clarity) {
219*a248dafdSChristopher Ferris 				if (tx % 4)
220*a248dafdSChristopher Ferris 					tx += 4 - (tx % 4);
221*a248dafdSChristopher Ferris 			}
222*a248dafdSChristopher Ferris 		}
223*a248dafdSChristopher Ferris 		m_reportSize = 2 * tx * rx;
224*a248dafdSChristopher Ferris 		break;
225*a248dafdSChristopher Ferris 	case F54_TRX_OPENS:
226*a248dafdSChristopher Ferris 	case F54_TRX_TO_GND_SHORTS:
227*a248dafdSChristopher Ferris 	case F54_TRX_SHORTS:
228*a248dafdSChristopher Ferris 		m_reportSize = TRX_OPEN_SHORT_DATA_SIZE;
229*a248dafdSChristopher Ferris 		break;
230*a248dafdSChristopher Ferris 	case F54_ABS_RAW_CAP:
231*a248dafdSChristopher Ferris 	case F54_ABS_DELTA_CAP:
232*a248dafdSChristopher Ferris 		m_reportSize = 4 * (tx + rx);
233*a248dafdSChristopher Ferris 		break;
234*a248dafdSChristopher Ferris 	case F54_GUARD_PIN_SHORT:
235*a248dafdSChristopher Ferris 		sprintf(buf, "F54_GUARD_PIN_SHORT\n");
236*a248dafdSChristopher Ferris 		m_display.Output(buf);
237*a248dafdSChristopher Ferris 		m_reportSize = GUARD_PIN_SHORT_DATA_SIZE;
238*a248dafdSChristopher Ferris 		break;
239*a248dafdSChristopher Ferris 	default:
240*a248dafdSChristopher Ferris 		sprintf(buf, "invalid report type\n");
241*a248dafdSChristopher Ferris 		m_display.Output(buf);
242*a248dafdSChristopher Ferris 		m_reportSize = 0;
243*a248dafdSChristopher Ferris 		return TEST_FAIL_INVALID_PARAMETER;
244*a248dafdSChristopher Ferris 	}
245*a248dafdSChristopher Ferris 
246*a248dafdSChristopher Ferris 	return TEST_SUCCESS;
247*a248dafdSChristopher Ferris }
248*a248dafdSChristopher Ferris 
FindTestFunctions()249*a248dafdSChristopher Ferris int F54Test::FindTestFunctions()
250*a248dafdSChristopher Ferris {
251*a248dafdSChristopher Ferris 	if (0 > m_device.ScanPDT(0x00, 10))
252*a248dafdSChristopher Ferris 		return TEST_FAIL_SCAN_PDT;
253*a248dafdSChristopher Ferris 
254*a248dafdSChristopher Ferris 	if (!m_device.GetFunction(m_f01, 0x01))
255*a248dafdSChristopher Ferris 		return TEST_FAIL_NO_FUNCTION_01;
256*a248dafdSChristopher Ferris 
257*a248dafdSChristopher Ferris 	if (!m_device.GetFunction(m_f54, 0x54))
258*a248dafdSChristopher Ferris 		return TEST_FAIL_NO_FUNCTION_54;
259*a248dafdSChristopher Ferris 
260*a248dafdSChristopher Ferris 	if (!m_device.GetFunction(m_f55, 0x55))
261*a248dafdSChristopher Ferris 		return TEST_FAIL_NO_FUNCTION_55;
262*a248dafdSChristopher Ferris 
263*a248dafdSChristopher Ferris 	return TEST_SUCCESS;
264*a248dafdSChristopher Ferris }
265*a248dafdSChristopher Ferris 
ReadF54Queries()266*a248dafdSChristopher Ferris int F54Test::ReadF54Queries()
267*a248dafdSChristopher Ferris {
268*a248dafdSChristopher Ferris 	int retval;
269*a248dafdSChristopher Ferris 	unsigned short query_addr = m_f54.GetQueryBase();
270*a248dafdSChristopher Ferris 	unsigned char offset;
271*a248dafdSChristopher Ferris 
272*a248dafdSChristopher Ferris 	retval = m_device.Read(query_addr,
273*a248dafdSChristopher Ferris 			       m_f54Query.data,
274*a248dafdSChristopher Ferris 			       sizeof(m_f54Query.data));
275*a248dafdSChristopher Ferris 	if (retval < 0)
276*a248dafdSChristopher Ferris 		return retval;
277*a248dafdSChristopher Ferris 
278*a248dafdSChristopher Ferris 	offset = sizeof(m_f54Query.data);
279*a248dafdSChristopher Ferris 
280*a248dafdSChristopher Ferris 	/* query 12 */
281*a248dafdSChristopher Ferris 	if (m_f54Query.has_sense_frequency_control == 0)
282*a248dafdSChristopher Ferris 		offset -= 1;
283*a248dafdSChristopher Ferris 
284*a248dafdSChristopher Ferris 	/* query 13 */
285*a248dafdSChristopher Ferris 	if (m_f54Query.has_query13) {
286*a248dafdSChristopher Ferris 		retval = m_device.Read(query_addr + offset,
287*a248dafdSChristopher Ferris 				m_f54Query_13.data,
288*a248dafdSChristopher Ferris 				sizeof(m_f54Query_13.data));
289*a248dafdSChristopher Ferris 		if (retval < 0)
290*a248dafdSChristopher Ferris 			return retval;
291*a248dafdSChristopher Ferris 		offset += 1;
292*a248dafdSChristopher Ferris 	}
293*a248dafdSChristopher Ferris 
294*a248dafdSChristopher Ferris 	/* query 14 */
295*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query13) && (m_f54Query_13.has_ctrl87))
296*a248dafdSChristopher Ferris 		offset += 1;
297*a248dafdSChristopher Ferris 
298*a248dafdSChristopher Ferris 	/* query 15 */
299*a248dafdSChristopher Ferris 	if (m_f54Query.has_query15) {
300*a248dafdSChristopher Ferris 		retval = m_device.Read(query_addr + offset,
301*a248dafdSChristopher Ferris 				m_f54Query_15.data,
302*a248dafdSChristopher Ferris 				sizeof(m_f54Query_15.data));
303*a248dafdSChristopher Ferris 		if (retval < 0)
304*a248dafdSChristopher Ferris 			return retval;
305*a248dafdSChristopher Ferris 		offset += 1;
306*a248dafdSChristopher Ferris 	}
307*a248dafdSChristopher Ferris 
308*a248dafdSChristopher Ferris 	/* query 16 */
309*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) && (m_f54Query_15.has_query16)) {
310*a248dafdSChristopher Ferris 		retval = m_device.Read(query_addr + offset,
311*a248dafdSChristopher Ferris 				m_f54Query_16.data,
312*a248dafdSChristopher Ferris 				sizeof(m_f54Query_16.data));
313*a248dafdSChristopher Ferris 		if (retval < 0)
314*a248dafdSChristopher Ferris 			return retval;
315*a248dafdSChristopher Ferris 		offset += 1;
316*a248dafdSChristopher Ferris 	}
317*a248dafdSChristopher Ferris 
318*a248dafdSChristopher Ferris 	/* query 17 */
319*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
320*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query16) &&
321*a248dafdSChristopher Ferris 			(m_f54Query_16.has_query17))
322*a248dafdSChristopher Ferris 		offset += 1;
323*a248dafdSChristopher Ferris 
324*a248dafdSChristopher Ferris 	/* query 18 */
325*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
326*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query16) &&
327*a248dafdSChristopher Ferris 			(m_f54Query_16.has_ctrl94_query18))
328*a248dafdSChristopher Ferris 		offset += 1;
329*a248dafdSChristopher Ferris 
330*a248dafdSChristopher Ferris 	/* query 19 */
331*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
332*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query16) &&
333*a248dafdSChristopher Ferris 			(m_f54Query_16.has_ctrl95_query19))
334*a248dafdSChristopher Ferris 		offset += 1;
335*a248dafdSChristopher Ferris 
336*a248dafdSChristopher Ferris 	/* query 20 */
337*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) && (m_f54Query_15.has_query20))
338*a248dafdSChristopher Ferris 		offset += 1;
339*a248dafdSChristopher Ferris 
340*a248dafdSChristopher Ferris 	/* query 21 */
341*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) && (m_f54Query_15.has_query21)) {
342*a248dafdSChristopher Ferris 		retval = m_device.Read(query_addr + offset,
343*a248dafdSChristopher Ferris 				m_f54Query_21.data,
344*a248dafdSChristopher Ferris 				sizeof(m_f54Query_21.data));
345*a248dafdSChristopher Ferris 		if (retval < 0)
346*a248dafdSChristopher Ferris 			return retval;
347*a248dafdSChristopher Ferris 		offset += 1;
348*a248dafdSChristopher Ferris 	}
349*a248dafdSChristopher Ferris 
350*a248dafdSChristopher Ferris 	/* query 22 */
351*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) && (m_f54Query_15.has_query22)) {
352*a248dafdSChristopher Ferris 		retval = m_device.Read(query_addr + offset,
353*a248dafdSChristopher Ferris 				m_f54Query_22.data,
354*a248dafdSChristopher Ferris 				sizeof(m_f54Query_22.data));
355*a248dafdSChristopher Ferris 		if (retval < 0)
356*a248dafdSChristopher Ferris 			return retval;
357*a248dafdSChristopher Ferris 		offset += 1;
358*a248dafdSChristopher Ferris 	}
359*a248dafdSChristopher Ferris 
360*a248dafdSChristopher Ferris 	/* query 23 */
361*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
362*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query22) &&
363*a248dafdSChristopher Ferris 			(m_f54Query_22.has_query23)) {
364*a248dafdSChristopher Ferris 		retval = m_device.Read(query_addr + offset,
365*a248dafdSChristopher Ferris 				m_f54Query_23.data,
366*a248dafdSChristopher Ferris 				sizeof(m_f54Query_23.data));
367*a248dafdSChristopher Ferris 		if (retval < 0)
368*a248dafdSChristopher Ferris 			return retval;
369*a248dafdSChristopher Ferris 		offset += 1;
370*a248dafdSChristopher Ferris 	}
371*a248dafdSChristopher Ferris 
372*a248dafdSChristopher Ferris 	/* query 24 */
373*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
374*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query21) &&
375*a248dafdSChristopher Ferris 			(m_f54Query_21.has_query24_data18))
376*a248dafdSChristopher Ferris 		offset += 1;
377*a248dafdSChristopher Ferris 
378*a248dafdSChristopher Ferris 	/* query 25 */
379*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) && (m_f54Query_15.has_query25)) {
380*a248dafdSChristopher Ferris 		retval = m_device.Read(query_addr + offset,
381*a248dafdSChristopher Ferris 				m_f54Query_25.data,
382*a248dafdSChristopher Ferris 				sizeof(m_f54Query_25.data));
383*a248dafdSChristopher Ferris 		if (retval < 0)
384*a248dafdSChristopher Ferris 			return retval;
385*a248dafdSChristopher Ferris 		offset += 1;
386*a248dafdSChristopher Ferris 	}
387*a248dafdSChristopher Ferris 
388*a248dafdSChristopher Ferris 	/* query 26 */
389*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
390*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query22) &&
391*a248dafdSChristopher Ferris 			(m_f54Query_22.has_ctrl103_query26))
392*a248dafdSChristopher Ferris 		offset += 1;
393*a248dafdSChristopher Ferris 
394*a248dafdSChristopher Ferris 	/* query 27 */
395*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
396*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
397*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27)) {
398*a248dafdSChristopher Ferris 		retval = m_device.Read(query_addr + offset,
399*a248dafdSChristopher Ferris 				m_f54Query_27.data,
400*a248dafdSChristopher Ferris 				sizeof(m_f54Query_27.data));
401*a248dafdSChristopher Ferris 		if (retval < 0)
402*a248dafdSChristopher Ferris 			return retval;
403*a248dafdSChristopher Ferris 		offset += 1;
404*a248dafdSChristopher Ferris 	}
405*a248dafdSChristopher Ferris 
406*a248dafdSChristopher Ferris 	/* query 28 */
407*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
408*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query22) &&
409*a248dafdSChristopher Ferris 			(m_f54Query_22.has_query28))
410*a248dafdSChristopher Ferris 		offset += 1;
411*a248dafdSChristopher Ferris 
412*a248dafdSChristopher Ferris 	/* query 29 */
413*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
414*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
415*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
416*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29)) {
417*a248dafdSChristopher Ferris 		retval = m_device.Read(query_addr + offset,
418*a248dafdSChristopher Ferris 				m_f54Query_29.data,
419*a248dafdSChristopher Ferris 				sizeof(m_f54Query_29.data));
420*a248dafdSChristopher Ferris 		if (retval < 0)
421*a248dafdSChristopher Ferris 			return retval;
422*a248dafdSChristopher Ferris 		offset += 1;
423*a248dafdSChristopher Ferris 	}
424*a248dafdSChristopher Ferris 
425*a248dafdSChristopher Ferris 	/* query 30 */
426*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
427*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
428*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
429*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
430*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30)) {
431*a248dafdSChristopher Ferris 		retval = m_device.Read(query_addr + offset,
432*a248dafdSChristopher Ferris 				m_f54Query_30.data,
433*a248dafdSChristopher Ferris 				sizeof(m_f54Query_30.data));
434*a248dafdSChristopher Ferris 		if (retval < 0)
435*a248dafdSChristopher Ferris 			return retval;
436*a248dafdSChristopher Ferris 		offset += 1;
437*a248dafdSChristopher Ferris 	}
438*a248dafdSChristopher Ferris 
439*a248dafdSChristopher Ferris 	/* query 31 */
440*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
441*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
442*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
443*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
444*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
445*a248dafdSChristopher Ferris 			(m_f54Query_30.has_ctrl122_query31))
446*a248dafdSChristopher Ferris 		offset += 1;
447*a248dafdSChristopher Ferris 
448*a248dafdSChristopher Ferris 	/* query 32 */
449*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
450*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
451*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
452*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
453*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
454*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32)) {
455*a248dafdSChristopher Ferris 		retval = m_device.Read(query_addr + offset,
456*a248dafdSChristopher Ferris 				m_f54Query_32.data,
457*a248dafdSChristopher Ferris 				sizeof(m_f54Query_32.data));
458*a248dafdSChristopher Ferris 		if (retval < 0)
459*a248dafdSChristopher Ferris 			return retval;
460*a248dafdSChristopher Ferris 		offset += 1;
461*a248dafdSChristopher Ferris 	}
462*a248dafdSChristopher Ferris 
463*a248dafdSChristopher Ferris 	/* query 33 */
464*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
465*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
466*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
467*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
468*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
469*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
470*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query33)) {
471*a248dafdSChristopher Ferris 		retval = m_device.Read(query_addr + offset,
472*a248dafdSChristopher Ferris 				m_f54Query_33.data,
473*a248dafdSChristopher Ferris 				sizeof(m_f54Query_33.data));
474*a248dafdSChristopher Ferris 		if (retval < 0)
475*a248dafdSChristopher Ferris 			return retval;
476*a248dafdSChristopher Ferris 		offset += 1;
477*a248dafdSChristopher Ferris 	}
478*a248dafdSChristopher Ferris 
479*a248dafdSChristopher Ferris 	/* query 34 */
480*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
481*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
482*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
483*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
484*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
485*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
486*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query34))
487*a248dafdSChristopher Ferris 		offset += 1;
488*a248dafdSChristopher Ferris 
489*a248dafdSChristopher Ferris 	/* query 35 */
490*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
491*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
492*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
493*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
494*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
495*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
496*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query35)) {
497*a248dafdSChristopher Ferris 		retval = m_device.Read(query_addr + offset,
498*a248dafdSChristopher Ferris 				m_f54Query_35.data,
499*a248dafdSChristopher Ferris 				sizeof(m_f54Query_35.data));
500*a248dafdSChristopher Ferris 		if (retval < 0)
501*a248dafdSChristopher Ferris 			return retval;
502*a248dafdSChristopher Ferris 		offset += 1;
503*a248dafdSChristopher Ferris 	}
504*a248dafdSChristopher Ferris 
505*a248dafdSChristopher Ferris 	/* query 36 */
506*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
507*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
508*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
509*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
510*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
511*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
512*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query33) &&
513*a248dafdSChristopher Ferris 			(m_f54Query_33.has_query36)) {
514*a248dafdSChristopher Ferris 		retval = m_device.Read(query_addr + offset,
515*a248dafdSChristopher Ferris 				m_f54Query_36.data,
516*a248dafdSChristopher Ferris 				sizeof(m_f54Query_36.data));
517*a248dafdSChristopher Ferris 		if (retval < 0)
518*a248dafdSChristopher Ferris 			return retval;
519*a248dafdSChristopher Ferris 		offset += 1;
520*a248dafdSChristopher Ferris 	}
521*a248dafdSChristopher Ferris 
522*a248dafdSChristopher Ferris 	/* query 37 */
523*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
524*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
525*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
526*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
527*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
528*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
529*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query33) &&
530*a248dafdSChristopher Ferris 			(m_f54Query_33.has_query36) &&
531*a248dafdSChristopher Ferris 			(m_f54Query_36.has_query37))
532*a248dafdSChristopher Ferris 		offset += 1;
533*a248dafdSChristopher Ferris 
534*a248dafdSChristopher Ferris 	/* query 38 */
535*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
536*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
537*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
538*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
539*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
540*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
541*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query33) &&
542*a248dafdSChristopher Ferris 			(m_f54Query_33.has_query36) &&
543*a248dafdSChristopher Ferris 			(m_f54Query_36.has_query38)) {
544*a248dafdSChristopher Ferris 		retval = m_device.Read(query_addr + offset,
545*a248dafdSChristopher Ferris 				m_f54Query_38.data,
546*a248dafdSChristopher Ferris 				sizeof(m_f54Query_38.data));
547*a248dafdSChristopher Ferris 		if (retval < 0)
548*a248dafdSChristopher Ferris 			return retval;
549*a248dafdSChristopher Ferris 		offset += 1;
550*a248dafdSChristopher Ferris 	}
551*a248dafdSChristopher Ferris 
552*a248dafdSChristopher Ferris 	/* query 39 */
553*a248dafdSChristopher Ferris 	if (m_f54Query_38.has_query39) {
554*a248dafdSChristopher Ferris 		retval = m_device.Read(query_addr + offset,
555*a248dafdSChristopher Ferris 					m_f54Query_39.data,
556*a248dafdSChristopher Ferris 					sizeof(m_f54Query_39.data));
557*a248dafdSChristopher Ferris 		if (retval < 0)
558*a248dafdSChristopher Ferris 			return retval;
559*a248dafdSChristopher Ferris 		offset += 1;
560*a248dafdSChristopher Ferris 	}
561*a248dafdSChristopher Ferris 
562*a248dafdSChristopher Ferris 	/* query 40 */
563*a248dafdSChristopher Ferris 	if (m_f54Query_39.has_query40) {
564*a248dafdSChristopher Ferris 		retval = m_device.Read(query_addr + offset,
565*a248dafdSChristopher Ferris 				m_f54Query_40.data,
566*a248dafdSChristopher Ferris 				sizeof(m_f54Query_40.data));
567*a248dafdSChristopher Ferris 		if (retval < 0)
568*a248dafdSChristopher Ferris 			return retval;
569*a248dafdSChristopher Ferris 		offset += 1;
570*a248dafdSChristopher Ferris 	}
571*a248dafdSChristopher Ferris 
572*a248dafdSChristopher Ferris 	/* query 41 */
573*a248dafdSChristopher Ferris 	if (m_f54Query_40.has_ctrl163_query41)
574*a248dafdSChristopher Ferris 		offset += 1;
575*a248dafdSChristopher Ferris 
576*a248dafdSChristopher Ferris 	/* query 42 */
577*a248dafdSChristopher Ferris 	if (m_f54Query_40.has_ctrl165_query42)
578*a248dafdSChristopher Ferris 		offset += 1;
579*a248dafdSChristopher Ferris 
580*a248dafdSChristopher Ferris 	/* query 43 */
581*a248dafdSChristopher Ferris 	if (m_f54Query_40.has_query43) {
582*a248dafdSChristopher Ferris 		m_device.Read(query_addr + offset,
583*a248dafdSChristopher Ferris 				m_f54Query_43.data,
584*a248dafdSChristopher Ferris 				sizeof(m_f54Query_43.data));
585*a248dafdSChristopher Ferris 		if (retval < 0)
586*a248dafdSChristopher Ferris 			return retval;
587*a248dafdSChristopher Ferris 		offset += 1;
588*a248dafdSChristopher Ferris 	}
589*a248dafdSChristopher Ferris 
590*a248dafdSChristopher Ferris 	if (m_f54Query_43.has_ctrl172_query44_query45)
591*a248dafdSChristopher Ferris 		offset += 2;
592*a248dafdSChristopher Ferris 
593*a248dafdSChristopher Ferris 	/* query 46 */
594*a248dafdSChristopher Ferris 	if (m_f54Query_43.has_query46) {
595*a248dafdSChristopher Ferris 		m_device.Read(query_addr + offset,
596*a248dafdSChristopher Ferris 				m_f54Query_46.data,
597*a248dafdSChristopher Ferris 				sizeof(m_f54Query_46.data));
598*a248dafdSChristopher Ferris 		if (retval < 0)
599*a248dafdSChristopher Ferris 			return retval;
600*a248dafdSChristopher Ferris 		offset += 1;
601*a248dafdSChristopher Ferris 	}
602*a248dafdSChristopher Ferris 
603*a248dafdSChristopher Ferris 	/* query 47 */
604*a248dafdSChristopher Ferris 	if (m_f54Query_46.has_query47) {
605*a248dafdSChristopher Ferris 		m_device.Read(query_addr + offset,
606*a248dafdSChristopher Ferris 				m_f54Query_47.data,
607*a248dafdSChristopher Ferris 				sizeof(m_f54Query_47.data));
608*a248dafdSChristopher Ferris 		if (retval < 0)
609*a248dafdSChristopher Ferris 			return retval;
610*a248dafdSChristopher Ferris 		offset += 1;
611*a248dafdSChristopher Ferris 	}
612*a248dafdSChristopher Ferris 
613*a248dafdSChristopher Ferris 	/* query 48 reserved */
614*a248dafdSChristopher Ferris 
615*a248dafdSChristopher Ferris 	/* query 49 */
616*a248dafdSChristopher Ferris 	if (m_f54Query_47.has_query49) {
617*a248dafdSChristopher Ferris 		m_device.Read(query_addr + offset,
618*a248dafdSChristopher Ferris 				m_f54Query_49.data,
619*a248dafdSChristopher Ferris 				sizeof(m_f54Query_49.data));
620*a248dafdSChristopher Ferris 		if (retval < 0)
621*a248dafdSChristopher Ferris 			return retval;
622*a248dafdSChristopher Ferris 		offset += 1;
623*a248dafdSChristopher Ferris 	}
624*a248dafdSChristopher Ferris 
625*a248dafdSChristopher Ferris 	/* query 50 */
626*a248dafdSChristopher Ferris 	if (m_f54Query_49.has_query50) {
627*a248dafdSChristopher Ferris 		m_device.Read(query_addr + offset,
628*a248dafdSChristopher Ferris 				m_f54Query_50.data,
629*a248dafdSChristopher Ferris 				sizeof(m_f54Query_50.data));
630*a248dafdSChristopher Ferris 		if (retval < 0)
631*a248dafdSChristopher Ferris 			return retval;
632*a248dafdSChristopher Ferris 		offset += 1;
633*a248dafdSChristopher Ferris 	}
634*a248dafdSChristopher Ferris 
635*a248dafdSChristopher Ferris 	/* query 51 */
636*a248dafdSChristopher Ferris 	if (m_f54Query_50.has_query51) {
637*a248dafdSChristopher Ferris 		m_device.Read(query_addr + offset,
638*a248dafdSChristopher Ferris 				m_f54Query_51.data,
639*a248dafdSChristopher Ferris 				sizeof(m_f54Query_51.data));
640*a248dafdSChristopher Ferris 		if (retval < 0)
641*a248dafdSChristopher Ferris 			return retval;
642*a248dafdSChristopher Ferris 		offset += 1;
643*a248dafdSChristopher Ferris 	}
644*a248dafdSChristopher Ferris 
645*a248dafdSChristopher Ferris 	/* query 53 54 */
646*a248dafdSChristopher Ferris 	if (m_f54Query_51.has_query53_query54_ctrl198)
647*a248dafdSChristopher Ferris 		offset += 2;
648*a248dafdSChristopher Ferris 
649*a248dafdSChristopher Ferris 	/* query 55 */
650*a248dafdSChristopher Ferris 	if (m_f54Query_51.has_query55) {
651*a248dafdSChristopher Ferris 		m_device.Read(query_addr + offset,
652*a248dafdSChristopher Ferris 				m_f54Query_55.data,
653*a248dafdSChristopher Ferris 				sizeof(m_f54Query_55.data));
654*a248dafdSChristopher Ferris 		if (retval < 0)
655*a248dafdSChristopher Ferris 			return retval;
656*a248dafdSChristopher Ferris 		offset += 1;
657*a248dafdSChristopher Ferris 	}
658*a248dafdSChristopher Ferris 
659*a248dafdSChristopher Ferris 	/* query 56 */
660*a248dafdSChristopher Ferris 	if (m_f54Query_55.has_query56)
661*a248dafdSChristopher Ferris 		offset += 1;
662*a248dafdSChristopher Ferris 
663*a248dafdSChristopher Ferris 	/* query 57 */
664*a248dafdSChristopher Ferris 	if (m_f54Query_55.has_query57) {
665*a248dafdSChristopher Ferris 		m_device.Read(query_addr + offset,
666*a248dafdSChristopher Ferris 				m_f54Query_57.data,
667*a248dafdSChristopher Ferris 				sizeof(m_f54Query_57.data));
668*a248dafdSChristopher Ferris 		if (retval < 0)
669*a248dafdSChristopher Ferris 			return retval;
670*a248dafdSChristopher Ferris 		offset += 1;
671*a248dafdSChristopher Ferris 	}
672*a248dafdSChristopher Ferris 
673*a248dafdSChristopher Ferris 	/* query 58 */
674*a248dafdSChristopher Ferris 	if (m_f54Query_57.has_query58) {
675*a248dafdSChristopher Ferris 		m_device.Read(query_addr + offset,
676*a248dafdSChristopher Ferris 				m_f54Query_58.data,
677*a248dafdSChristopher Ferris 				sizeof(m_f54Query_58.data));
678*a248dafdSChristopher Ferris 		if (retval < 0)
679*a248dafdSChristopher Ferris 			return retval;
680*a248dafdSChristopher Ferris 		offset += 1;
681*a248dafdSChristopher Ferris 	}
682*a248dafdSChristopher Ferris 
683*a248dafdSChristopher Ferris 	/* query 59 */
684*a248dafdSChristopher Ferris 	if (m_f54Query_58.has_query59)
685*a248dafdSChristopher Ferris 		offset += 1;
686*a248dafdSChristopher Ferris 
687*a248dafdSChristopher Ferris 	/* query 60 */
688*a248dafdSChristopher Ferris 	if (m_f54Query_58.has_query60)
689*a248dafdSChristopher Ferris 		offset += 1;
690*a248dafdSChristopher Ferris 
691*a248dafdSChristopher Ferris 	/* query 61 */
692*a248dafdSChristopher Ferris 	if (m_f54Query_58.has_query61) {
693*a248dafdSChristopher Ferris 		m_device.Read(query_addr + offset,
694*a248dafdSChristopher Ferris 				m_f54Query_61.data,
695*a248dafdSChristopher Ferris 				sizeof(m_f54Query_61.data));
696*a248dafdSChristopher Ferris 		if (retval < 0)
697*a248dafdSChristopher Ferris 			return retval;
698*a248dafdSChristopher Ferris 		offset += 1;
699*a248dafdSChristopher Ferris 	}
700*a248dafdSChristopher Ferris 
701*a248dafdSChristopher Ferris 	/* query 62 63 */
702*a248dafdSChristopher Ferris 	if (m_f54Query_61.has_ctrl215_query62_query63)
703*a248dafdSChristopher Ferris 		offset += 2;
704*a248dafdSChristopher Ferris 
705*a248dafdSChristopher Ferris 	/* query 64 */
706*a248dafdSChristopher Ferris 	if (m_f54Query_61.has_query64) {
707*a248dafdSChristopher Ferris 		m_device.Read(query_addr + offset,
708*a248dafdSChristopher Ferris 				m_f54Query_64.data,
709*a248dafdSChristopher Ferris 				sizeof(m_f54Query_64.data));
710*a248dafdSChristopher Ferris 		if (retval < 0)
711*a248dafdSChristopher Ferris 			return retval;
712*a248dafdSChristopher Ferris 		offset += 1;
713*a248dafdSChristopher Ferris 	}
714*a248dafdSChristopher Ferris 
715*a248dafdSChristopher Ferris 	/* query 65 */
716*a248dafdSChristopher Ferris 	if (m_f54Query_64.has_query65) {
717*a248dafdSChristopher Ferris 		m_device.Read(query_addr + offset,
718*a248dafdSChristopher Ferris 				m_f54Query_65.data,
719*a248dafdSChristopher Ferris 				sizeof(m_f54Query_65.data));
720*a248dafdSChristopher Ferris 		if (retval < 0)
721*a248dafdSChristopher Ferris 			return retval;
722*a248dafdSChristopher Ferris 		offset += 1;
723*a248dafdSChristopher Ferris 	}
724*a248dafdSChristopher Ferris 
725*a248dafdSChristopher Ferris 	/* query 66 */
726*a248dafdSChristopher Ferris 	if (m_f54Query_65.has_query66_ctrl231)
727*a248dafdSChristopher Ferris 		offset += 1;
728*a248dafdSChristopher Ferris 
729*a248dafdSChristopher Ferris 	/* query 67 */
730*a248dafdSChristopher Ferris 	if (m_f54Query_65.has_query67) {
731*a248dafdSChristopher Ferris 		m_device.Read(query_addr + offset,
732*a248dafdSChristopher Ferris 				m_f54Query_67.data,
733*a248dafdSChristopher Ferris 				sizeof(m_f54Query_67.data));
734*a248dafdSChristopher Ferris 		if (retval < 0)
735*a248dafdSChristopher Ferris 			return retval;
736*a248dafdSChristopher Ferris 		offset += 1;
737*a248dafdSChristopher Ferris 	}
738*a248dafdSChristopher Ferris 
739*a248dafdSChristopher Ferris 	/* query 68 */
740*a248dafdSChristopher Ferris 	if (m_f54Query_67.has_query68) {
741*a248dafdSChristopher Ferris 		m_device.Read(query_addr + offset,
742*a248dafdSChristopher Ferris 				m_f54Query_68.data,
743*a248dafdSChristopher Ferris 				sizeof(m_f54Query_68.data));
744*a248dafdSChristopher Ferris 		if (retval < 0)
745*a248dafdSChristopher Ferris 			return retval;
746*a248dafdSChristopher Ferris 		offset += 1;
747*a248dafdSChristopher Ferris 	}
748*a248dafdSChristopher Ferris 
749*a248dafdSChristopher Ferris 	/* query 69 */
750*a248dafdSChristopher Ferris 	if (m_f54Query_68.has_query69) {
751*a248dafdSChristopher Ferris 		m_device.Read(query_addr + offset,
752*a248dafdSChristopher Ferris 				m_f54Query_69.data,
753*a248dafdSChristopher Ferris 				sizeof(m_f54Query_69.data));
754*a248dafdSChristopher Ferris 		if (retval < 0)
755*a248dafdSChristopher Ferris 			return retval;
756*a248dafdSChristopher Ferris 		offset += 1;
757*a248dafdSChristopher Ferris 	}
758*a248dafdSChristopher Ferris 
759*a248dafdSChristopher Ferris 	return TEST_SUCCESS;;
760*a248dafdSChristopher Ferris }
761*a248dafdSChristopher Ferris 
SetupF54Controls()762*a248dafdSChristopher Ferris int F54Test::SetupF54Controls()
763*a248dafdSChristopher Ferris {
764*a248dafdSChristopher Ferris 	unsigned char length;
765*a248dafdSChristopher Ferris 	unsigned char num_of_sensing_freqs;
766*a248dafdSChristopher Ferris 	unsigned short reg_addr = m_f54.GetControlBase();
767*a248dafdSChristopher Ferris 
768*a248dafdSChristopher Ferris 	num_of_sensing_freqs = m_f54Query.number_of_sensing_frequencies;
769*a248dafdSChristopher Ferris 
770*a248dafdSChristopher Ferris 	/* control 0 */
771*a248dafdSChristopher Ferris 	reg_addr += CONTROL_0_SIZE;
772*a248dafdSChristopher Ferris 
773*a248dafdSChristopher Ferris 	/* control 1 */
774*a248dafdSChristopher Ferris 	if ((m_f54Query.touch_controller_family == 0) ||
775*a248dafdSChristopher Ferris 			(m_f54Query.touch_controller_family == 1))
776*a248dafdSChristopher Ferris 		reg_addr += CONTROL_1_SIZE;
777*a248dafdSChristopher Ferris 
778*a248dafdSChristopher Ferris 	/* control 2 */
779*a248dafdSChristopher Ferris 	reg_addr += CONTROL_2_SIZE;
780*a248dafdSChristopher Ferris 
781*a248dafdSChristopher Ferris 	/* control 3 */
782*a248dafdSChristopher Ferris 	if (m_f54Query.has_pixel_touch_threshold_adjustment == 1)
783*a248dafdSChristopher Ferris 		reg_addr += CONTROL_3_SIZE;
784*a248dafdSChristopher Ferris 
785*a248dafdSChristopher Ferris 	/* controls 4 5 6 */
786*a248dafdSChristopher Ferris 	if ((m_f54Query.touch_controller_family == 0) ||
787*a248dafdSChristopher Ferris 			(m_f54Query.touch_controller_family == 1))
788*a248dafdSChristopher Ferris 		reg_addr += CONTROL_4_6_SIZE;
789*a248dafdSChristopher Ferris 
790*a248dafdSChristopher Ferris 	/* control 7 */
791*a248dafdSChristopher Ferris 	if (m_f54Query.touch_controller_family == 1) {
792*a248dafdSChristopher Ferris 		m_f54Control.reg_7.address = reg_addr;
793*a248dafdSChristopher Ferris 		reg_addr += CONTROL_7_SIZE;
794*a248dafdSChristopher Ferris 	}
795*a248dafdSChristopher Ferris 
796*a248dafdSChristopher Ferris 	/* controls 8 9 */
797*a248dafdSChristopher Ferris 	if ((m_f54Query.touch_controller_family == 0) ||
798*a248dafdSChristopher Ferris 			(m_f54Query.touch_controller_family == 1))
799*a248dafdSChristopher Ferris 		reg_addr += CONTROL_8_9_SIZE;
800*a248dafdSChristopher Ferris 
801*a248dafdSChristopher Ferris 	/* control 10 */
802*a248dafdSChristopher Ferris 	if (m_f54Query.has_interference_metric == 1)
803*a248dafdSChristopher Ferris 		reg_addr += CONTROL_10_SIZE;
804*a248dafdSChristopher Ferris 
805*a248dafdSChristopher Ferris 	/* control 11 */
806*a248dafdSChristopher Ferris 	if (m_f54Query.has_ctrl11 == 1)
807*a248dafdSChristopher Ferris 		reg_addr += CONTROL_11_SIZE;
808*a248dafdSChristopher Ferris 
809*a248dafdSChristopher Ferris 	/* controls 12 13 */
810*a248dafdSChristopher Ferris 	if (m_f54Query.has_relaxation_control == 1)
811*a248dafdSChristopher Ferris 		reg_addr += CONTROL_12_13_SIZE;
812*a248dafdSChristopher Ferris 
813*a248dafdSChristopher Ferris 	/* controls 14 15 16 */
814*a248dafdSChristopher Ferris 	if (m_f54Query.has_sensor_assignment == 1) {
815*a248dafdSChristopher Ferris 		reg_addr += CONTROL_14_SIZE;
816*a248dafdSChristopher Ferris 		reg_addr += CONTROL_15_SIZE * m_f54Query.num_of_rx_electrodes;
817*a248dafdSChristopher Ferris 		reg_addr += CONTROL_16_SIZE * m_f54Query.num_of_tx_electrodes;
818*a248dafdSChristopher Ferris 	}
819*a248dafdSChristopher Ferris 
820*a248dafdSChristopher Ferris 	/* controls 17 18 19 */
821*a248dafdSChristopher Ferris 	if (m_f54Query.has_sense_frequency_control == 1) {
822*a248dafdSChristopher Ferris 		reg_addr += CONTROL_17_SIZE * num_of_sensing_freqs;
823*a248dafdSChristopher Ferris 		reg_addr += CONTROL_18_SIZE * num_of_sensing_freqs;
824*a248dafdSChristopher Ferris 		reg_addr += CONTROL_19_SIZE * num_of_sensing_freqs;
825*a248dafdSChristopher Ferris 	}
826*a248dafdSChristopher Ferris 
827*a248dafdSChristopher Ferris 	/* control 20 */
828*a248dafdSChristopher Ferris 	reg_addr += CONTROL_20_SIZE;
829*a248dafdSChristopher Ferris 
830*a248dafdSChristopher Ferris 	/* control 21 */
831*a248dafdSChristopher Ferris 	if (m_f54Query.has_sense_frequency_control == 1)
832*a248dafdSChristopher Ferris 		reg_addr += CONTROL_21_SIZE;
833*a248dafdSChristopher Ferris 
834*a248dafdSChristopher Ferris 	/* controls 22 23 24 25 26 */
835*a248dafdSChristopher Ferris 	if (m_f54Query.has_firmware_noise_mitigation == 1)
836*a248dafdSChristopher Ferris 		reg_addr += CONTROL_22_26_SIZE;
837*a248dafdSChristopher Ferris 
838*a248dafdSChristopher Ferris 	/* control 27 */
839*a248dafdSChristopher Ferris 	if (m_f54Query.has_iir_filter == 1)
840*a248dafdSChristopher Ferris 		reg_addr += CONTROL_27_SIZE;
841*a248dafdSChristopher Ferris 
842*a248dafdSChristopher Ferris 	/* control 28 */
843*a248dafdSChristopher Ferris 	if (m_f54Query.has_firmware_noise_mitigation == 1)
844*a248dafdSChristopher Ferris 		reg_addr += CONTROL_28_SIZE;
845*a248dafdSChristopher Ferris 
846*a248dafdSChristopher Ferris 	/* control 29 */
847*a248dafdSChristopher Ferris 	if (m_f54Query.has_cmn_removal == 1)
848*a248dafdSChristopher Ferris 		reg_addr += CONTROL_29_SIZE;
849*a248dafdSChristopher Ferris 
850*a248dafdSChristopher Ferris 	/* control 30 */
851*a248dafdSChristopher Ferris 	if (m_f54Query.has_cmn_maximum == 1)
852*a248dafdSChristopher Ferris 		reg_addr += CONTROL_30_SIZE;
853*a248dafdSChristopher Ferris 
854*a248dafdSChristopher Ferris 	/* control 31 */
855*a248dafdSChristopher Ferris 	if (m_f54Query.has_touch_hysteresis == 1)
856*a248dafdSChristopher Ferris 		reg_addr += CONTROL_31_SIZE;
857*a248dafdSChristopher Ferris 
858*a248dafdSChristopher Ferris 	/* controls 32 33 34 35 */
859*a248dafdSChristopher Ferris 	if (m_f54Query.has_edge_compensation == 1)
860*a248dafdSChristopher Ferris 		reg_addr += CONTROL_32_35_SIZE;
861*a248dafdSChristopher Ferris 
862*a248dafdSChristopher Ferris 	/* control 36 */
863*a248dafdSChristopher Ferris 	if ((m_f54Query.curve_compensation_mode == 1) ||
864*a248dafdSChristopher Ferris 			(m_f54Query.curve_compensation_mode == 2)) {
865*a248dafdSChristopher Ferris 		if (m_f54Query.curve_compensation_mode == 1) {
866*a248dafdSChristopher Ferris 			length = std::max(m_f54Query.num_of_rx_electrodes,
867*a248dafdSChristopher Ferris 					m_f54Query.num_of_tx_electrodes);
868*a248dafdSChristopher Ferris 		} else if (m_f54Query.curve_compensation_mode == 2) {
869*a248dafdSChristopher Ferris 			length = m_f54Query.num_of_rx_electrodes;
870*a248dafdSChristopher Ferris 		}
871*a248dafdSChristopher Ferris 		reg_addr += CONTROL_36_SIZE * length;
872*a248dafdSChristopher Ferris 	}
873*a248dafdSChristopher Ferris 
874*a248dafdSChristopher Ferris 	/* control 37 */
875*a248dafdSChristopher Ferris 	if (m_f54Query.curve_compensation_mode == 2)
876*a248dafdSChristopher Ferris 		reg_addr += CONTROL_37_SIZE * m_f54Query.num_of_tx_electrodes;
877*a248dafdSChristopher Ferris 
878*a248dafdSChristopher Ferris 	/* controls 38 39 40 */
879*a248dafdSChristopher Ferris 	if (m_f54Query.has_per_frequency_noise_control == 1) {
880*a248dafdSChristopher Ferris 		reg_addr += CONTROL_38_SIZE * num_of_sensing_freqs;
881*a248dafdSChristopher Ferris 		reg_addr += CONTROL_39_SIZE * num_of_sensing_freqs;
882*a248dafdSChristopher Ferris 		reg_addr += CONTROL_40_SIZE * num_of_sensing_freqs;
883*a248dafdSChristopher Ferris 	}
884*a248dafdSChristopher Ferris 
885*a248dafdSChristopher Ferris 	/* control 41 */
886*a248dafdSChristopher Ferris 	if (m_f54Query.has_signal_clarity == 1) {
887*a248dafdSChristopher Ferris 		m_f54Control.reg_41.address = reg_addr;
888*a248dafdSChristopher Ferris 		reg_addr += CONTROL_41_SIZE;
889*a248dafdSChristopher Ferris 	}
890*a248dafdSChristopher Ferris 
891*a248dafdSChristopher Ferris 	/* control 42 */
892*a248dafdSChristopher Ferris 	if (m_f54Query.has_variance_metric == 1)
893*a248dafdSChristopher Ferris 		reg_addr += CONTROL_42_SIZE;
894*a248dafdSChristopher Ferris 
895*a248dafdSChristopher Ferris 	/* controls 43 44 45 46 47 48 49 50 51 52 53 54 */
896*a248dafdSChristopher Ferris 	if (m_f54Query.has_multi_metric_state_machine == 1)
897*a248dafdSChristopher Ferris 		reg_addr += CONTROL_43_54_SIZE;
898*a248dafdSChristopher Ferris 
899*a248dafdSChristopher Ferris 	/* controls 55 56 */
900*a248dafdSChristopher Ferris 	if (m_f54Query.has_0d_relaxation_control == 1)
901*a248dafdSChristopher Ferris 		reg_addr += CONTROL_55_56_SIZE;
902*a248dafdSChristopher Ferris 
903*a248dafdSChristopher Ferris 	/* control 57 */
904*a248dafdSChristopher Ferris 	if (m_f54Query.has_0d_acquisition_control == 1) {
905*a248dafdSChristopher Ferris 		m_f54Control.reg_57.address = reg_addr;
906*a248dafdSChristopher Ferris 		reg_addr += CONTROL_57_SIZE;
907*a248dafdSChristopher Ferris 	}
908*a248dafdSChristopher Ferris 
909*a248dafdSChristopher Ferris 	/* control 58 */
910*a248dafdSChristopher Ferris 	if (m_f54Query.has_0d_acquisition_control == 1)
911*a248dafdSChristopher Ferris 		reg_addr += CONTROL_58_SIZE;
912*a248dafdSChristopher Ferris 
913*a248dafdSChristopher Ferris 	/* control 59 */
914*a248dafdSChristopher Ferris 	if (m_f54Query.has_h_blank == 1)
915*a248dafdSChristopher Ferris 		reg_addr += CONTROL_59_SIZE;
916*a248dafdSChristopher Ferris 
917*a248dafdSChristopher Ferris 	/* controls 60 61 62 */
918*a248dafdSChristopher Ferris 	if ((m_f54Query.has_h_blank == 1) ||
919*a248dafdSChristopher Ferris 			(m_f54Query.has_v_blank == 1) ||
920*a248dafdSChristopher Ferris 			(m_f54Query.has_long_h_blank == 1))
921*a248dafdSChristopher Ferris 		reg_addr += CONTROL_60_62_SIZE;
922*a248dafdSChristopher Ferris 
923*a248dafdSChristopher Ferris 	/* control 63 */
924*a248dafdSChristopher Ferris 	if ((m_f54Query.has_h_blank == 1) ||
925*a248dafdSChristopher Ferris 			(m_f54Query.has_v_blank == 1) ||
926*a248dafdSChristopher Ferris 			(m_f54Query.has_long_h_blank == 1) ||
927*a248dafdSChristopher Ferris 			(m_f54Query.has_slew_metric == 1) ||
928*a248dafdSChristopher Ferris 			(m_f54Query.has_slew_option == 1) ||
929*a248dafdSChristopher Ferris 			(m_f54Query.has_noise_mitigation2 == 1))
930*a248dafdSChristopher Ferris 		reg_addr += CONTROL_63_SIZE;
931*a248dafdSChristopher Ferris 
932*a248dafdSChristopher Ferris 	/* controls 64 65 66 67 */
933*a248dafdSChristopher Ferris 	if (m_f54Query.has_h_blank == 1)
934*a248dafdSChristopher Ferris 		reg_addr += CONTROL_64_67_SIZE * 7;
935*a248dafdSChristopher Ferris 	else if ((m_f54Query.has_v_blank == 1) ||
936*a248dafdSChristopher Ferris 			(m_f54Query.has_long_h_blank == 1))
937*a248dafdSChristopher Ferris 		reg_addr += CONTROL_64_67_SIZE;
938*a248dafdSChristopher Ferris 
939*a248dafdSChristopher Ferris 	/* controls 68 69 70 71 72 73 */
940*a248dafdSChristopher Ferris 	if ((m_f54Query.has_h_blank == 1) ||
941*a248dafdSChristopher Ferris 			(m_f54Query.has_v_blank == 1) ||
942*a248dafdSChristopher Ferris 			(m_f54Query.has_long_h_blank == 1))
943*a248dafdSChristopher Ferris 		reg_addr += CONTROL_68_73_SIZE;
944*a248dafdSChristopher Ferris 
945*a248dafdSChristopher Ferris 	/* control 74 */
946*a248dafdSChristopher Ferris 	if (m_f54Query.has_slew_metric == 1)
947*a248dafdSChristopher Ferris 		reg_addr += CONTROL_74_SIZE;
948*a248dafdSChristopher Ferris 
949*a248dafdSChristopher Ferris 	/* control 75 */
950*a248dafdSChristopher Ferris 	if (m_f54Query.has_enhanced_stretch == 1)
951*a248dafdSChristopher Ferris 		reg_addr += CONTROL_75_SIZE * num_of_sensing_freqs;
952*a248dafdSChristopher Ferris 
953*a248dafdSChristopher Ferris 	/* control 76 */
954*a248dafdSChristopher Ferris 	if (m_f54Query.has_startup_fast_relaxation == 1)
955*a248dafdSChristopher Ferris 		reg_addr += CONTROL_76_SIZE;
956*a248dafdSChristopher Ferris 
957*a248dafdSChristopher Ferris 	/* controls 77 78 */
958*a248dafdSChristopher Ferris 	if (m_f54Query.has_esd_control == 1)
959*a248dafdSChristopher Ferris 		reg_addr += CONTROL_77_78_SIZE;
960*a248dafdSChristopher Ferris 
961*a248dafdSChristopher Ferris 	/* controls 79 80 81 82 83 */
962*a248dafdSChristopher Ferris 	if (m_f54Query.has_noise_mitigation2 == 1)
963*a248dafdSChristopher Ferris 		reg_addr += CONTROL_79_83_SIZE;
964*a248dafdSChristopher Ferris 
965*a248dafdSChristopher Ferris 	/* controls 84 85 */
966*a248dafdSChristopher Ferris 	if (m_f54Query.has_energy_ratio_relaxation == 1)
967*a248dafdSChristopher Ferris 		reg_addr += CONTROL_84_85_SIZE;
968*a248dafdSChristopher Ferris 
969*a248dafdSChristopher Ferris 	/* control 86 */
970*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query13 == 1) && (m_f54Query_13.has_ctrl86 == 1))
971*a248dafdSChristopher Ferris 		reg_addr += CONTROL_86_SIZE;
972*a248dafdSChristopher Ferris 
973*a248dafdSChristopher Ferris 	/* control 87 */
974*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query13 == 1) && (m_f54Query_13.has_ctrl87 == 1))
975*a248dafdSChristopher Ferris 		reg_addr += CONTROL_87_SIZE;
976*a248dafdSChristopher Ferris 
977*a248dafdSChristopher Ferris 	/* control 88 */
978*a248dafdSChristopher Ferris 	if (m_f54Query.has_ctrl88 == 1) {
979*a248dafdSChristopher Ferris 		m_f54Control.reg_88.address = reg_addr;
980*a248dafdSChristopher Ferris 		reg_addr += CONTROL_88_SIZE;
981*a248dafdSChristopher Ferris 	}
982*a248dafdSChristopher Ferris 
983*a248dafdSChristopher Ferris 	/* control 89 */
984*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query13 == 1) &&
985*a248dafdSChristopher Ferris 			(m_f54Query_13.has_cidim == 1 ||
986*a248dafdSChristopher Ferris 			m_f54Query_13.has_noise_mitigation_enhancement ||
987*a248dafdSChristopher Ferris 			m_f54Query_13.has_rail_im))
988*a248dafdSChristopher Ferris 		reg_addr += CONTROL_89_SIZE;
989*a248dafdSChristopher Ferris 
990*a248dafdSChristopher Ferris 	/* control 90 */
991*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) && (m_f54Query_15.has_ctrl90))
992*a248dafdSChristopher Ferris 		reg_addr += CONTROL_90_SIZE;
993*a248dafdSChristopher Ferris 
994*a248dafdSChristopher Ferris 	/* control 91 */
995*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
996*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query21) &&
997*a248dafdSChristopher Ferris 			(m_f54Query_21.has_ctrl91))
998*a248dafdSChristopher Ferris 		reg_addr += CONTROL_91_SIZE;
999*a248dafdSChristopher Ferris 
1000*a248dafdSChristopher Ferris 	/* control 92 */
1001*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1002*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query16) &&
1003*a248dafdSChristopher Ferris 			(m_f54Query_16.has_ctrl92))
1004*a248dafdSChristopher Ferris 		reg_addr += CONTROL_92_SIZE;
1005*a248dafdSChristopher Ferris 
1006*a248dafdSChristopher Ferris 	/* control 93 */
1007*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1008*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query16) &&
1009*a248dafdSChristopher Ferris 			(m_f54Query_16.has_ctrl93))
1010*a248dafdSChristopher Ferris 		reg_addr += CONTROL_93_SIZE;
1011*a248dafdSChristopher Ferris 
1012*a248dafdSChristopher Ferris 	/* control 94 */
1013*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1014*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query16) &&
1015*a248dafdSChristopher Ferris 			(m_f54Query_16.has_ctrl94_query18))
1016*a248dafdSChristopher Ferris 		reg_addr += CONTROL_94_SIZE;
1017*a248dafdSChristopher Ferris 
1018*a248dafdSChristopher Ferris 	/* control 95 */
1019*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1020*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query16) &&
1021*a248dafdSChristopher Ferris 			(m_f54Query_16.has_ctrl95_query19))
1022*a248dafdSChristopher Ferris 		reg_addr += CONTROL_95_SIZE;
1023*a248dafdSChristopher Ferris 
1024*a248dafdSChristopher Ferris 	/* control 96 */
1025*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1026*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query21) &&
1027*a248dafdSChristopher Ferris 			(m_f54Query_21.has_ctrl96))
1028*a248dafdSChristopher Ferris 		reg_addr += CONTROL_96_SIZE;
1029*a248dafdSChristopher Ferris 
1030*a248dafdSChristopher Ferris 	/* control 97 */
1031*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1032*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query21) &&
1033*a248dafdSChristopher Ferris 			(m_f54Query_21.has_ctrl97))
1034*a248dafdSChristopher Ferris 		reg_addr += CONTROL_97_SIZE;
1035*a248dafdSChristopher Ferris 
1036*a248dafdSChristopher Ferris 	/* control 98 */
1037*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1038*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query21) &&
1039*a248dafdSChristopher Ferris 			(m_f54Query_21.has_ctrl98))
1040*a248dafdSChristopher Ferris 		reg_addr += CONTROL_98_SIZE;
1041*a248dafdSChristopher Ferris 
1042*a248dafdSChristopher Ferris 	/* control 99 */
1043*a248dafdSChristopher Ferris 	if (m_f54Query.touch_controller_family == 2)
1044*a248dafdSChristopher Ferris 		reg_addr += CONTROL_99_SIZE;
1045*a248dafdSChristopher Ferris 
1046*a248dafdSChristopher Ferris 	/* control 100 */
1047*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1048*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query16) &&
1049*a248dafdSChristopher Ferris 			(m_f54Query_16.has_ctrl100))
1050*a248dafdSChristopher Ferris 		reg_addr += CONTROL_100_SIZE;
1051*a248dafdSChristopher Ferris 
1052*a248dafdSChristopher Ferris 	/* control 101 */
1053*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1054*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query22) &&
1055*a248dafdSChristopher Ferris 			(m_f54Query_22.has_ctrl101))
1056*a248dafdSChristopher Ferris 		reg_addr += CONTROL_101_SIZE;
1057*a248dafdSChristopher Ferris 
1058*a248dafdSChristopher Ferris 
1059*a248dafdSChristopher Ferris 	/* control 102 */
1060*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1061*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query22) &&
1062*a248dafdSChristopher Ferris 			(m_f54Query_22.has_query23) &&
1063*a248dafdSChristopher Ferris 			(m_f54Query_23.has_ctrl102))
1064*a248dafdSChristopher Ferris 		reg_addr += CONTROL_102_SIZE;
1065*a248dafdSChristopher Ferris 
1066*a248dafdSChristopher Ferris 	/* control 103 */
1067*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1068*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query22) &&
1069*a248dafdSChristopher Ferris 			(m_f54Query_22.has_ctrl103_query26))
1070*a248dafdSChristopher Ferris 		reg_addr += CONTROL_103_SIZE;
1071*a248dafdSChristopher Ferris 
1072*a248dafdSChristopher Ferris 	/* control 104 */
1073*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1074*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query22) &&
1075*a248dafdSChristopher Ferris 			(m_f54Query_22.has_ctrl104))
1076*a248dafdSChristopher Ferris 		reg_addr += CONTROL_104_SIZE;
1077*a248dafdSChristopher Ferris 
1078*a248dafdSChristopher Ferris 	/* control 105 */
1079*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1080*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query22) &&
1081*a248dafdSChristopher Ferris 			(m_f54Query_22.has_ctrl105))
1082*a248dafdSChristopher Ferris 		reg_addr += CONTROL_105_SIZE;
1083*a248dafdSChristopher Ferris 
1084*a248dafdSChristopher Ferris 	/* control 106 */
1085*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1086*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1087*a248dafdSChristopher Ferris 			(m_f54Query_25.has_ctrl106))
1088*a248dafdSChristopher Ferris 		reg_addr += CONTROL_106_SIZE;
1089*a248dafdSChristopher Ferris 
1090*a248dafdSChristopher Ferris 	/* control 107 */
1091*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1092*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1093*a248dafdSChristopher Ferris 			(m_f54Query_25.has_ctrl107))
1094*a248dafdSChristopher Ferris 		reg_addr += CONTROL_107_SIZE;
1095*a248dafdSChristopher Ferris 
1096*a248dafdSChristopher Ferris 	/* control 108 */
1097*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1098*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1099*a248dafdSChristopher Ferris 			(m_f54Query_25.has_ctrl108))
1100*a248dafdSChristopher Ferris 		reg_addr += CONTROL_108_SIZE;
1101*a248dafdSChristopher Ferris 
1102*a248dafdSChristopher Ferris 	/* control 109 */
1103*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1104*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1105*a248dafdSChristopher Ferris 			(m_f54Query_25.has_ctrl109))
1106*a248dafdSChristopher Ferris 		reg_addr += CONTROL_109_SIZE;
1107*a248dafdSChristopher Ferris 
1108*a248dafdSChristopher Ferris 	/* control 110 */
1109*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1110*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1111*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1112*a248dafdSChristopher Ferris 			(m_f54Query_27.has_ctrl110)) {
1113*a248dafdSChristopher Ferris 		m_f54Control.reg_110.address = reg_addr;
1114*a248dafdSChristopher Ferris 		reg_addr += CONTROL_110_SIZE;
1115*a248dafdSChristopher Ferris 	}
1116*a248dafdSChristopher Ferris 
1117*a248dafdSChristopher Ferris 	/* control 111 */
1118*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1119*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1120*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1121*a248dafdSChristopher Ferris 			(m_f54Query_27.has_ctrl111))
1122*a248dafdSChristopher Ferris 		reg_addr += CONTROL_111_SIZE;
1123*a248dafdSChristopher Ferris 
1124*a248dafdSChristopher Ferris 	/* control 112 */
1125*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1126*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1127*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1128*a248dafdSChristopher Ferris 			(m_f54Query_27.has_ctrl112))
1129*a248dafdSChristopher Ferris 		reg_addr += CONTROL_112_SIZE;
1130*a248dafdSChristopher Ferris 
1131*a248dafdSChristopher Ferris 	/* control 113 */
1132*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1133*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1134*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1135*a248dafdSChristopher Ferris 			(m_f54Query_27.has_ctrl113))
1136*a248dafdSChristopher Ferris 		reg_addr += CONTROL_113_SIZE;
1137*a248dafdSChristopher Ferris 
1138*a248dafdSChristopher Ferris 	/* control 114 */
1139*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1140*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1141*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1142*a248dafdSChristopher Ferris 			(m_f54Query_27.has_ctrl114))
1143*a248dafdSChristopher Ferris 		reg_addr += CONTROL_114_SIZE;
1144*a248dafdSChristopher Ferris 
1145*a248dafdSChristopher Ferris 	/* control 115 */
1146*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1147*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1148*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1149*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1150*a248dafdSChristopher Ferris 			(m_f54Query_29.has_ctrl115))
1151*a248dafdSChristopher Ferris 		reg_addr += CONTROL_115_SIZE;
1152*a248dafdSChristopher Ferris 
1153*a248dafdSChristopher Ferris 	/* control 116 */
1154*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1155*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1156*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1157*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1158*a248dafdSChristopher Ferris 			(m_f54Query_29.has_ctrl116))
1159*a248dafdSChristopher Ferris 		reg_addr += CONTROL_116_SIZE;
1160*a248dafdSChristopher Ferris 
1161*a248dafdSChristopher Ferris 	/* control 117 */
1162*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1163*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1164*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1165*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1166*a248dafdSChristopher Ferris 			(m_f54Query_29.has_ctrl117))
1167*a248dafdSChristopher Ferris 		reg_addr += CONTROL_117_SIZE;
1168*a248dafdSChristopher Ferris 
1169*a248dafdSChristopher Ferris 	/* control 118 */
1170*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1171*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1172*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1173*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1174*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1175*a248dafdSChristopher Ferris 			(m_f54Query_30.has_ctrl118))
1176*a248dafdSChristopher Ferris 		reg_addr += CONTROL_118_SIZE;
1177*a248dafdSChristopher Ferris 
1178*a248dafdSChristopher Ferris 	/* control 119 */
1179*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1180*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1181*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1182*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1183*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1184*a248dafdSChristopher Ferris 			(m_f54Query_30.has_ctrl119))
1185*a248dafdSChristopher Ferris 		reg_addr += CONTROL_119_SIZE;
1186*a248dafdSChristopher Ferris 
1187*a248dafdSChristopher Ferris 	/* control 120 */
1188*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1189*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1190*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1191*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1192*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1193*a248dafdSChristopher Ferris 			(m_f54Query_30.has_ctrl120))
1194*a248dafdSChristopher Ferris 		reg_addr += CONTROL_120_SIZE;
1195*a248dafdSChristopher Ferris 
1196*a248dafdSChristopher Ferris 	/* control 121 */
1197*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1198*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1199*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1200*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1201*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1202*a248dafdSChristopher Ferris 			(m_f54Query_30.has_ctrl121))
1203*a248dafdSChristopher Ferris 		reg_addr += CONTROL_121_SIZE;
1204*a248dafdSChristopher Ferris 
1205*a248dafdSChristopher Ferris 	/* control 122 */
1206*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1207*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1208*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1209*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1210*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1211*a248dafdSChristopher Ferris 			(m_f54Query_30.has_ctrl122_query31))
1212*a248dafdSChristopher Ferris 		reg_addr += CONTROL_122_SIZE;
1213*a248dafdSChristopher Ferris 
1214*a248dafdSChristopher Ferris 	/* control 123 */
1215*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1216*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1217*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1218*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1219*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1220*a248dafdSChristopher Ferris 			(m_f54Query_30.has_ctrl123))
1221*a248dafdSChristopher Ferris 		reg_addr += CONTROL_123_SIZE;
1222*a248dafdSChristopher Ferris 
1223*a248dafdSChristopher Ferris 	/* control 124 reserved */
1224*a248dafdSChristopher Ferris 
1225*a248dafdSChristopher Ferris 	/* control 125 */
1226*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1227*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1228*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1229*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1230*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1231*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
1232*a248dafdSChristopher Ferris 			(m_f54Query_32.has_ctrl125))
1233*a248dafdSChristopher Ferris 		reg_addr += CONTROL_125_SIZE;
1234*a248dafdSChristopher Ferris 
1235*a248dafdSChristopher Ferris 	/* control 126 */
1236*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1237*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1238*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1239*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1240*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1241*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
1242*a248dafdSChristopher Ferris 			(m_f54Query_32.has_ctrl126))
1243*a248dafdSChristopher Ferris 		reg_addr += CONTROL_126_SIZE;
1244*a248dafdSChristopher Ferris 
1245*a248dafdSChristopher Ferris 	/* control 127 */
1246*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1247*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1248*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1249*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1250*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1251*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
1252*a248dafdSChristopher Ferris 			(m_f54Query_32.has_ctrl127))
1253*a248dafdSChristopher Ferris 		reg_addr += CONTROL_127_SIZE;
1254*a248dafdSChristopher Ferris 
1255*a248dafdSChristopher Ferris 	/* controls 128 129 130 131 reserved */
1256*a248dafdSChristopher Ferris 
1257*a248dafdSChristopher Ferris 	/* control 132 */
1258*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1259*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1260*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1261*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1262*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1263*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
1264*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query33) &&
1265*a248dafdSChristopher Ferris 			(m_f54Query_33.has_ctrl132))
1266*a248dafdSChristopher Ferris 		reg_addr += CONTROL_132_SIZE;
1267*a248dafdSChristopher Ferris 
1268*a248dafdSChristopher Ferris 	/* control 133 */
1269*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1270*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1271*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1272*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1273*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1274*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
1275*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query33) &&
1276*a248dafdSChristopher Ferris 			(m_f54Query_33.has_ctrl133))
1277*a248dafdSChristopher Ferris 		reg_addr += CONTROL_133_SIZE;
1278*a248dafdSChristopher Ferris 
1279*a248dafdSChristopher Ferris 	/* control 134 */
1280*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1281*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1282*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1283*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1284*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1285*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
1286*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query33) &&
1287*a248dafdSChristopher Ferris 			(m_f54Query_33.has_ctrl134))
1288*a248dafdSChristopher Ferris 		reg_addr += CONTROL_134_SIZE;
1289*a248dafdSChristopher Ferris 
1290*a248dafdSChristopher Ferris 	/* controls 135 136 reserved */
1291*a248dafdSChristopher Ferris 
1292*a248dafdSChristopher Ferris 	/* control 137 */
1293*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1294*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1295*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1296*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1297*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1298*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
1299*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query35) &&
1300*a248dafdSChristopher Ferris 			(m_f54Query_35.has_ctrl137))
1301*a248dafdSChristopher Ferris 		reg_addr += CONTROL_137_SIZE;
1302*a248dafdSChristopher Ferris 
1303*a248dafdSChristopher Ferris 	/* control 138 */
1304*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1305*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1306*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1307*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1308*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1309*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
1310*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query35) &&
1311*a248dafdSChristopher Ferris 			(m_f54Query_35.has_ctrl138))
1312*a248dafdSChristopher Ferris 		reg_addr += CONTROL_138_SIZE;
1313*a248dafdSChristopher Ferris 
1314*a248dafdSChristopher Ferris 	/* control 139 */
1315*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1316*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1317*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1318*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1319*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1320*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
1321*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query35) &&
1322*a248dafdSChristopher Ferris 			(m_f54Query_35.has_ctrl139))
1323*a248dafdSChristopher Ferris 		reg_addr += CONTROL_139_SIZE;
1324*a248dafdSChristopher Ferris 
1325*a248dafdSChristopher Ferris 	/* control 140 */
1326*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1327*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1328*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1329*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1330*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1331*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
1332*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query35) &&
1333*a248dafdSChristopher Ferris 			(m_f54Query_35.has_ctrl140))
1334*a248dafdSChristopher Ferris 		reg_addr += CONTROL_140_SIZE;
1335*a248dafdSChristopher Ferris 
1336*a248dafdSChristopher Ferris 	/* control 141 reserved */
1337*a248dafdSChristopher Ferris 
1338*a248dafdSChristopher Ferris 	/* control 142 */
1339*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1340*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1341*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1342*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1343*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1344*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
1345*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query33) &&
1346*a248dafdSChristopher Ferris 			(m_f54Query_33.has_query36) &&
1347*a248dafdSChristopher Ferris 			(m_f54Query_36.has_ctrl142))
1348*a248dafdSChristopher Ferris 		reg_addr += CONTROL_142_SIZE;
1349*a248dafdSChristopher Ferris 
1350*a248dafdSChristopher Ferris 	/* control 143 */
1351*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1352*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1353*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1354*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1355*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1356*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
1357*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query33) &&
1358*a248dafdSChristopher Ferris 			(m_f54Query_33.has_query36) &&
1359*a248dafdSChristopher Ferris 			(m_f54Query_36.has_ctrl143))
1360*a248dafdSChristopher Ferris 		reg_addr += CONTROL_143_SIZE;
1361*a248dafdSChristopher Ferris 
1362*a248dafdSChristopher Ferris 	/* control 144 */
1363*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1364*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1365*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1366*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1367*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1368*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
1369*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query33) &&
1370*a248dafdSChristopher Ferris 			(m_f54Query_33.has_query36) &&
1371*a248dafdSChristopher Ferris 			(m_f54Query_36.has_ctrl144))
1372*a248dafdSChristopher Ferris 		reg_addr += CONTROL_144_SIZE;
1373*a248dafdSChristopher Ferris 
1374*a248dafdSChristopher Ferris 	/* control 145 */
1375*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1376*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1377*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1378*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1379*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1380*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
1381*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query33) &&
1382*a248dafdSChristopher Ferris 			(m_f54Query_33.has_query36) &&
1383*a248dafdSChristopher Ferris 			(m_f54Query_36.has_ctrl145))
1384*a248dafdSChristopher Ferris 		reg_addr += CONTROL_145_SIZE;
1385*a248dafdSChristopher Ferris 
1386*a248dafdSChristopher Ferris 	/* control 146 */
1387*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1388*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1389*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1390*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1391*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1392*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
1393*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query33) &&
1394*a248dafdSChristopher Ferris 			(m_f54Query_33.has_query36) &&
1395*a248dafdSChristopher Ferris 			(m_f54Query_36.has_ctrl146))
1396*a248dafdSChristopher Ferris 		reg_addr += CONTROL_146_SIZE;
1397*a248dafdSChristopher Ferris 
1398*a248dafdSChristopher Ferris 	/* control 147 */
1399*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1400*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1401*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1402*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1403*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1404*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
1405*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query33) &&
1406*a248dafdSChristopher Ferris 			(m_f54Query_33.has_query36) &&
1407*a248dafdSChristopher Ferris 			(m_f54Query_36.has_query38) &&
1408*a248dafdSChristopher Ferris 			(m_f54Query_38.has_ctrl147))
1409*a248dafdSChristopher Ferris 		reg_addr += CONTROL_147_SIZE;
1410*a248dafdSChristopher Ferris 
1411*a248dafdSChristopher Ferris 	/* control 148 */
1412*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1413*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1414*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1415*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1416*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1417*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
1418*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query33) &&
1419*a248dafdSChristopher Ferris 			(m_f54Query_33.has_query36) &&
1420*a248dafdSChristopher Ferris 			(m_f54Query_36.has_query38) &&
1421*a248dafdSChristopher Ferris 			(m_f54Query_38.has_ctrl148))
1422*a248dafdSChristopher Ferris 		reg_addr += CONTROL_148_SIZE;
1423*a248dafdSChristopher Ferris 
1424*a248dafdSChristopher Ferris 	/* control 149 */
1425*a248dafdSChristopher Ferris 	if ((m_f54Query.has_query15) &&
1426*a248dafdSChristopher Ferris 			(m_f54Query_15.has_query25) &&
1427*a248dafdSChristopher Ferris 			(m_f54Query_25.has_query27) &&
1428*a248dafdSChristopher Ferris 			(m_f54Query_27.has_query29) &&
1429*a248dafdSChristopher Ferris 			(m_f54Query_29.has_query30) &&
1430*a248dafdSChristopher Ferris 			(m_f54Query_30.has_query32) &&
1431*a248dafdSChristopher Ferris 			(m_f54Query_32.has_query33) &&
1432*a248dafdSChristopher Ferris 			(m_f54Query_33.has_query36) &&
1433*a248dafdSChristopher Ferris 			(m_f54Query_36.has_query38) &&
1434*a248dafdSChristopher Ferris 			(m_f54Query_38.has_ctrl149)) {
1435*a248dafdSChristopher Ferris 		m_f54Control.reg_149.address = reg_addr;
1436*a248dafdSChristopher Ferris 		reg_addr += CONTROL_149_SIZE;
1437*a248dafdSChristopher Ferris 	}
1438*a248dafdSChristopher Ferris 	/* control 150 */
1439*a248dafdSChristopher Ferris 	if (m_f54Query_38.has_ctrl150)
1440*a248dafdSChristopher Ferris 		reg_addr += CONTROL_150_SIZE;
1441*a248dafdSChristopher Ferris 
1442*a248dafdSChristopher Ferris 	/* control 151 */
1443*a248dafdSChristopher Ferris 	if (m_f54Query_38.has_ctrl151)
1444*a248dafdSChristopher Ferris 		reg_addr += CONTROL_151_SIZE;
1445*a248dafdSChristopher Ferris 
1446*a248dafdSChristopher Ferris 	/* control 152 */
1447*a248dafdSChristopher Ferris 	if (m_f54Query_38.has_ctrl152)
1448*a248dafdSChristopher Ferris 		reg_addr += CONTROL_152_SIZE;
1449*a248dafdSChristopher Ferris 
1450*a248dafdSChristopher Ferris 	/* control 153 */
1451*a248dafdSChristopher Ferris 	if (m_f54Query_38.has_ctrl153)
1452*a248dafdSChristopher Ferris 		reg_addr += CONTROL_153_SIZE;
1453*a248dafdSChristopher Ferris 
1454*a248dafdSChristopher Ferris 	/* control 154 */
1455*a248dafdSChristopher Ferris 	if (m_f54Query_39.has_ctrl154)
1456*a248dafdSChristopher Ferris 		reg_addr += CONTROL_154_SIZE;
1457*a248dafdSChristopher Ferris 
1458*a248dafdSChristopher Ferris 	/* control 155 */
1459*a248dafdSChristopher Ferris 	if (m_f54Query_39.has_ctrl155)
1460*a248dafdSChristopher Ferris 		reg_addr += CONTROL_155_SIZE;
1461*a248dafdSChristopher Ferris 
1462*a248dafdSChristopher Ferris 	/* control 156 */
1463*a248dafdSChristopher Ferris 	if (m_f54Query_39.has_ctrl156)
1464*a248dafdSChristopher Ferris 		reg_addr += CONTROL_156_SIZE;
1465*a248dafdSChristopher Ferris 
1466*a248dafdSChristopher Ferris 	/* controls 157 158 */
1467*a248dafdSChristopher Ferris 	if (m_f54Query_39.has_ctrl157_ctrl158)
1468*a248dafdSChristopher Ferris 		reg_addr += CONTROL_157_158_SIZE;
1469*a248dafdSChristopher Ferris 
1470*a248dafdSChristopher Ferris 	/* controls 159 to 162 reserved */
1471*a248dafdSChristopher Ferris 
1472*a248dafdSChristopher Ferris 	/* control 163 */
1473*a248dafdSChristopher Ferris 	if (m_f54Query_40.has_ctrl163_query41)
1474*a248dafdSChristopher Ferris 		reg_addr += CONTROL_163_SIZE;
1475*a248dafdSChristopher Ferris 
1476*a248dafdSChristopher Ferris 	/* control 164 reserved */
1477*a248dafdSChristopher Ferris 
1478*a248dafdSChristopher Ferris 	/* control 165 */
1479*a248dafdSChristopher Ferris 	if (m_f54Query_40.has_ctrl165_query42)
1480*a248dafdSChristopher Ferris 		reg_addr += CONTROL_165_SIZE;
1481*a248dafdSChristopher Ferris 
1482*a248dafdSChristopher Ferris 	/* control 166 */
1483*a248dafdSChristopher Ferris 	if (m_f54Query_40.has_ctrl166)
1484*a248dafdSChristopher Ferris 		reg_addr += CONTROL_166_SIZE;
1485*a248dafdSChristopher Ferris 
1486*a248dafdSChristopher Ferris 	/* control 167 */
1487*a248dafdSChristopher Ferris 	if (m_f54Query_40.has_ctrl167)
1488*a248dafdSChristopher Ferris 		reg_addr += CONTROL_167_SIZE;
1489*a248dafdSChristopher Ferris 
1490*a248dafdSChristopher Ferris 	/* control 168 */
1491*a248dafdSChristopher Ferris 	if (m_f54Query_40.has_ctrl168)
1492*a248dafdSChristopher Ferris 		reg_addr += CONTROL_168_SIZE;
1493*a248dafdSChristopher Ferris 
1494*a248dafdSChristopher Ferris 	/* control 169 */
1495*a248dafdSChristopher Ferris 	if (m_f54Query_40.has_ctrl169)
1496*a248dafdSChristopher Ferris 		reg_addr += CONTROL_169_SIZE;
1497*a248dafdSChristopher Ferris 
1498*a248dafdSChristopher Ferris 	/* control 170 reserved */
1499*a248dafdSChristopher Ferris 
1500*a248dafdSChristopher Ferris 	/* control 171 */
1501*a248dafdSChristopher Ferris 	if (m_f54Query_43.has_ctrl171)
1502*a248dafdSChristopher Ferris 		reg_addr += CONTROL_171_SIZE;
1503*a248dafdSChristopher Ferris 
1504*a248dafdSChristopher Ferris 	/* control 172 */
1505*a248dafdSChristopher Ferris 	if (m_f54Query_43.has_ctrl172_query44_query45)
1506*a248dafdSChristopher Ferris 		reg_addr += CONTROL_172_SIZE;
1507*a248dafdSChristopher Ferris 
1508*a248dafdSChristopher Ferris 	/* control 173 */
1509*a248dafdSChristopher Ferris 	if (m_f54Query_43.has_ctrl173)
1510*a248dafdSChristopher Ferris 		reg_addr += CONTROL_173_SIZE;
1511*a248dafdSChristopher Ferris 
1512*a248dafdSChristopher Ferris 	/* control 174 */
1513*a248dafdSChristopher Ferris 	if (m_f54Query_43.has_ctrl174)
1514*a248dafdSChristopher Ferris 		reg_addr += CONTROL_174_SIZE;
1515*a248dafdSChristopher Ferris 
1516*a248dafdSChristopher Ferris 	/* control 175 */
1517*a248dafdSChristopher Ferris 	if (m_f54Query_43.has_ctrl175)
1518*a248dafdSChristopher Ferris 		reg_addr += CONTROL_175_SIZE;
1519*a248dafdSChristopher Ferris 
1520*a248dafdSChristopher Ferris 	/* control 176 */
1521*a248dafdSChristopher Ferris 	if (m_f54Query_46.has_ctrl176)
1522*a248dafdSChristopher Ferris 		reg_addr += CONTROL_176_SIZE;
1523*a248dafdSChristopher Ferris 
1524*a248dafdSChristopher Ferris 	/* controls 177 178 */
1525*a248dafdSChristopher Ferris 	if (m_f54Query_46.has_ctrl177_ctrl178)
1526*a248dafdSChristopher Ferris 		reg_addr += CONTROL_177_178_SIZE;
1527*a248dafdSChristopher Ferris 
1528*a248dafdSChristopher Ferris 	/* control 179 */
1529*a248dafdSChristopher Ferris 	if (m_f54Query_46.has_ctrl179)
1530*a248dafdSChristopher Ferris 		reg_addr += CONTROL_179_SIZE;
1531*a248dafdSChristopher Ferris 
1532*a248dafdSChristopher Ferris 	/* controls 180 to 181 reserved */
1533*a248dafdSChristopher Ferris 
1534*a248dafdSChristopher Ferris 	/* control 182 */
1535*a248dafdSChristopher Ferris 	if (m_f54Query_47.has_ctrl182)
1536*a248dafdSChristopher Ferris 		reg_addr += CONTROL_182_SIZE;
1537*a248dafdSChristopher Ferris 
1538*a248dafdSChristopher Ferris 	/* control 183 */
1539*a248dafdSChristopher Ferris 	if (m_f54Query_47.has_ctrl183)
1540*a248dafdSChristopher Ferris 		reg_addr += CONTROL_183_SIZE;
1541*a248dafdSChristopher Ferris 
1542*a248dafdSChristopher Ferris 	/* control 184 reserved */
1543*a248dafdSChristopher Ferris 
1544*a248dafdSChristopher Ferris 	/* control 185 */
1545*a248dafdSChristopher Ferris 	if (m_f54Query_47.has_ctrl185)
1546*a248dafdSChristopher Ferris 		reg_addr += CONTROL_185_SIZE;
1547*a248dafdSChristopher Ferris 
1548*a248dafdSChristopher Ferris 	/* control 186 */
1549*a248dafdSChristopher Ferris 	if (m_f54Query_47.has_ctrl186)
1550*a248dafdSChristopher Ferris 		reg_addr += CONTROL_186_SIZE;
1551*a248dafdSChristopher Ferris 
1552*a248dafdSChristopher Ferris 	/* control 187 */
1553*a248dafdSChristopher Ferris 	if (m_f54Query_47.has_ctrl187)
1554*a248dafdSChristopher Ferris 		reg_addr += CONTROL_187_SIZE;
1555*a248dafdSChristopher Ferris 
1556*a248dafdSChristopher Ferris 	/* control 188 */
1557*a248dafdSChristopher Ferris 	if (m_f54Query_49.has_ctrl188) {
1558*a248dafdSChristopher Ferris 		m_f54Control.reg_188.address = reg_addr;
1559*a248dafdSChristopher Ferris 		reg_addr += CONTROL_188_SIZE;
1560*a248dafdSChristopher Ferris 	}
1561*a248dafdSChristopher Ferris 
1562*a248dafdSChristopher Ferris 	return TEST_SUCCESS;
1563*a248dafdSChristopher Ferris }
1564*a248dafdSChristopher Ferris 
ReadF55Queries()1565*a248dafdSChristopher Ferris int F54Test::ReadF55Queries()
1566*a248dafdSChristopher Ferris {
1567*a248dafdSChristopher Ferris 	int retval;
1568*a248dafdSChristopher Ferris 	unsigned char ii;
1569*a248dafdSChristopher Ferris 	unsigned char rx_electrodes = m_f54Query.num_of_rx_electrodes;
1570*a248dafdSChristopher Ferris 	unsigned char tx_electrodes = m_f54Query.num_of_tx_electrodes;
1571*a248dafdSChristopher Ferris 
1572*a248dafdSChristopher Ferris 	retval = m_device.Read(m_f55.GetQueryBase(),
1573*a248dafdSChristopher Ferris 			m_f55Query.data,
1574*a248dafdSChristopher Ferris 			sizeof(m_f55Query.data));
1575*a248dafdSChristopher Ferris 	if (retval < 0) {
1576*a248dafdSChristopher Ferris 		return retval;
1577*a248dafdSChristopher Ferris 	}
1578*a248dafdSChristopher Ferris 
1579*a248dafdSChristopher Ferris 	if (!m_f55Query.has_sensor_assignment)
1580*a248dafdSChristopher Ferris 	{
1581*a248dafdSChristopher Ferris 		m_txAssigned = tx_electrodes;
1582*a248dafdSChristopher Ferris 		m_rxAssigned = rx_electrodes;
1583*a248dafdSChristopher Ferris 		m_txAssignment = NULL;
1584*a248dafdSChristopher Ferris 		m_rxAssignment = NULL;
1585*a248dafdSChristopher Ferris 		return TEST_SUCCESS;
1586*a248dafdSChristopher Ferris 	}
1587*a248dafdSChristopher Ferris 
1588*a248dafdSChristopher Ferris 	if (m_txAssignment != NULL) delete [] m_txAssignment;
1589*a248dafdSChristopher Ferris 	if (m_rxAssignment != NULL) delete [] m_rxAssignment;
1590*a248dafdSChristopher Ferris 	m_txAssignment = new unsigned char[tx_electrodes];
1591*a248dafdSChristopher Ferris 	m_rxAssignment = new unsigned char[rx_electrodes];
1592*a248dafdSChristopher Ferris 
1593*a248dafdSChristopher Ferris 	retval = m_device.Read(m_f55.GetControlBase() + SENSOR_TX_MAPPING_OFFSET,
1594*a248dafdSChristopher Ferris 			m_txAssignment,
1595*a248dafdSChristopher Ferris 			tx_electrodes);
1596*a248dafdSChristopher Ferris 	if (retval < 0) {
1597*a248dafdSChristopher Ferris 		goto exit;
1598*a248dafdSChristopher Ferris 	}
1599*a248dafdSChristopher Ferris 
1600*a248dafdSChristopher Ferris 	retval = m_device.Read(m_f55.GetControlBase() + SENSOR_RX_MAPPING_OFFSET,
1601*a248dafdSChristopher Ferris 			m_rxAssignment,
1602*a248dafdSChristopher Ferris 			rx_electrodes);
1603*a248dafdSChristopher Ferris 	if (retval < 0) {
1604*a248dafdSChristopher Ferris 		goto exit;
1605*a248dafdSChristopher Ferris 	}
1606*a248dafdSChristopher Ferris 
1607*a248dafdSChristopher Ferris 	m_txAssigned = 0;
1608*a248dafdSChristopher Ferris 	for (ii = 0; ii < tx_electrodes; ii++) {
1609*a248dafdSChristopher Ferris 		if (m_txAssignment[ii] != 0xff)
1610*a248dafdSChristopher Ferris 			m_txAssigned++;
1611*a248dafdSChristopher Ferris 	}
1612*a248dafdSChristopher Ferris 
1613*a248dafdSChristopher Ferris 	m_rxAssigned = 0;
1614*a248dafdSChristopher Ferris 	for (ii = 0; ii < rx_electrodes; ii++) {
1615*a248dafdSChristopher Ferris 		if (m_rxAssignment[ii] != 0xff)
1616*a248dafdSChristopher Ferris 			m_rxAssigned++;
1617*a248dafdSChristopher Ferris 	}
1618*a248dafdSChristopher Ferris 
1619*a248dafdSChristopher Ferris 	return TEST_SUCCESS;
1620*a248dafdSChristopher Ferris 
1621*a248dafdSChristopher Ferris exit:
1622*a248dafdSChristopher Ferris 	if (m_txAssignment != NULL)
1623*a248dafdSChristopher Ferris 	{
1624*a248dafdSChristopher Ferris 		delete [] m_txAssignment;
1625*a248dafdSChristopher Ferris 		m_txAssignment = NULL;
1626*a248dafdSChristopher Ferris 	}
1627*a248dafdSChristopher Ferris 	if (m_rxAssignment != NULL)
1628*a248dafdSChristopher Ferris 	{
1629*a248dafdSChristopher Ferris 		delete [] m_rxAssignment;
1630*a248dafdSChristopher Ferris 		m_rxAssignment = NULL;
1631*a248dafdSChristopher Ferris 	}
1632*a248dafdSChristopher Ferris 
1633*a248dafdSChristopher Ferris 	return retval;
1634*a248dafdSChristopher Ferris }
1635*a248dafdSChristopher Ferris 
SetF54Interrupt()1636*a248dafdSChristopher Ferris int F54Test::SetF54Interrupt()
1637*a248dafdSChristopher Ferris {
1638*a248dafdSChristopher Ferris 	int retval;
1639*a248dafdSChristopher Ferris 	unsigned char mask = m_f54.GetInterruptMask();
1640*a248dafdSChristopher Ferris 	unsigned char zero = 0;
1641*a248dafdSChristopher Ferris 	unsigned int i;
1642*a248dafdSChristopher Ferris 
1643*a248dafdSChristopher Ferris 	for (i = 0; i < m_device.GetNumInterruptRegs(); i++)
1644*a248dafdSChristopher Ferris 	{
1645*a248dafdSChristopher Ferris 		if (i == m_f54.GetInterruptRegNum())
1646*a248dafdSChristopher Ferris 		{
1647*a248dafdSChristopher Ferris 			retval = m_device.Write(m_f54.GetControlBase() + 1 + i, &mask, 1);
1648*a248dafdSChristopher Ferris 		}
1649*a248dafdSChristopher Ferris 		else
1650*a248dafdSChristopher Ferris 		{
1651*a248dafdSChristopher Ferris 			retval = m_device.Write(m_f54.GetControlBase() + 1 + i, &zero, 1);
1652*a248dafdSChristopher Ferris 		}
1653*a248dafdSChristopher Ferris 
1654*a248dafdSChristopher Ferris 		if (retval < 0)
1655*a248dafdSChristopher Ferris 			return retval;
1656*a248dafdSChristopher Ferris 	}
1657*a248dafdSChristopher Ferris 	return TEST_SUCCESS;
1658*a248dafdSChristopher Ferris }
1659*a248dafdSChristopher Ferris 
DoF54Command(unsigned char command)1660*a248dafdSChristopher Ferris int F54Test::DoF54Command(unsigned char command)
1661*a248dafdSChristopher Ferris {
1662*a248dafdSChristopher Ferris 	int retval;
1663*a248dafdSChristopher Ferris 
1664*a248dafdSChristopher Ferris 	retval = m_device.Write(m_f54.GetCommandBase(), &command, 1);
1665*a248dafdSChristopher Ferris 	if (retval < 0)
1666*a248dafdSChristopher Ferris 		return retval;
1667*a248dafdSChristopher Ferris 
1668*a248dafdSChristopher Ferris 	retval = WaitForF54CommandCompletion();
1669*a248dafdSChristopher Ferris 	if (retval != TEST_SUCCESS)
1670*a248dafdSChristopher Ferris 		return retval;
1671*a248dafdSChristopher Ferris 
1672*a248dafdSChristopher Ferris 	return TEST_SUCCESS;
1673*a248dafdSChristopher Ferris }
1674*a248dafdSChristopher Ferris 
WaitForF54CommandCompletion()1675*a248dafdSChristopher Ferris int F54Test::WaitForF54CommandCompletion()
1676*a248dafdSChristopher Ferris {
1677*a248dafdSChristopher Ferris 	int retval;
1678*a248dafdSChristopher Ferris 	unsigned char value;
1679*a248dafdSChristopher Ferris 	unsigned char timeout_count;
1680*a248dafdSChristopher Ferris 
1681*a248dafdSChristopher Ferris 	timeout_count = 0;
1682*a248dafdSChristopher Ferris 	do {
1683*a248dafdSChristopher Ferris 		retval = m_device.Read(m_f54.GetCommandBase(),
1684*a248dafdSChristopher Ferris 				&value,
1685*a248dafdSChristopher Ferris 				sizeof(value));
1686*a248dafdSChristopher Ferris 		if (retval < 0)
1687*a248dafdSChristopher Ferris 			return retval;
1688*a248dafdSChristopher Ferris 
1689*a248dafdSChristopher Ferris 		if (value == 0x00)
1690*a248dafdSChristopher Ferris 			break;
1691*a248dafdSChristopher Ferris 
1692*a248dafdSChristopher Ferris 		Sleep(100);
1693*a248dafdSChristopher Ferris 		timeout_count++;
1694*a248dafdSChristopher Ferris 	} while (timeout_count < COMMAND_TIMEOUT_100MS);
1695*a248dafdSChristopher Ferris 
1696*a248dafdSChristopher Ferris 	if (timeout_count == COMMAND_TIMEOUT_100MS) {
1697*a248dafdSChristopher Ferris 		return -ETIMEDOUT;
1698*a248dafdSChristopher Ferris 	}
1699*a248dafdSChristopher Ferris 
1700*a248dafdSChristopher Ferris 	return TEST_SUCCESS;
1701*a248dafdSChristopher Ferris }
1702*a248dafdSChristopher Ferris 
ReadF54Report()1703*a248dafdSChristopher Ferris int F54Test::ReadF54Report()
1704*a248dafdSChristopher Ferris {
1705*a248dafdSChristopher Ferris 	int retval;
1706*a248dafdSChristopher Ferris 	unsigned char report_index[2];
1707*a248dafdSChristopher Ferris 
1708*a248dafdSChristopher Ferris 	if (m_reportBufferSize < m_reportSize) {
1709*a248dafdSChristopher Ferris 		if (m_reportData != NULL)
1710*a248dafdSChristopher Ferris 			delete [] m_reportData;
1711*a248dafdSChristopher Ferris 		m_reportData = new unsigned char[m_reportSize];
1712*a248dafdSChristopher Ferris 		if (!m_reportData) {
1713*a248dafdSChristopher Ferris 			m_reportBufferSize = 0;
1714*a248dafdSChristopher Ferris 			retval = TEST_FAIL_MEMORY_ALLOCATION;
1715*a248dafdSChristopher Ferris 			goto exit;
1716*a248dafdSChristopher Ferris 		}
1717*a248dafdSChristopher Ferris 		m_reportBufferSize = m_reportSize;
1718*a248dafdSChristopher Ferris 	}
1719*a248dafdSChristopher Ferris 
1720*a248dafdSChristopher Ferris 	report_index[0] = 0;
1721*a248dafdSChristopher Ferris 	report_index[1] = 0;
1722*a248dafdSChristopher Ferris 
1723*a248dafdSChristopher Ferris 	retval = m_device.Write(m_f54.GetDataBase() + REPORT_INDEX_OFFSET,
1724*a248dafdSChristopher Ferris 				report_index,
1725*a248dafdSChristopher Ferris 				sizeof(report_index));
1726*a248dafdSChristopher Ferris 
1727*a248dafdSChristopher Ferris 	if (retval < 0)
1728*a248dafdSChristopher Ferris 		goto exit;
1729*a248dafdSChristopher Ferris 
1730*a248dafdSChristopher Ferris 	retval = m_device.Read(m_f54.GetDataBase() + REPORT_DATA_OFFSET,
1731*a248dafdSChristopher Ferris 				m_reportData,
1732*a248dafdSChristopher Ferris 				m_reportSize);
1733*a248dafdSChristopher Ferris 	if (retval < 0)
1734*a248dafdSChristopher Ferris 		goto exit;
1735*a248dafdSChristopher Ferris 
1736*a248dafdSChristopher Ferris 	return TEST_SUCCESS;
1737*a248dafdSChristopher Ferris 
1738*a248dafdSChristopher Ferris exit:
1739*a248dafdSChristopher Ferris 	if (m_reportData != NULL)
1740*a248dafdSChristopher Ferris 	{
1741*a248dafdSChristopher Ferris 		delete [] m_reportData;
1742*a248dafdSChristopher Ferris 		m_reportData = NULL;
1743*a248dafdSChristopher Ferris 	}
1744*a248dafdSChristopher Ferris 
1745*a248dafdSChristopher Ferris 	return retval;
1746*a248dafdSChristopher Ferris }
1747*a248dafdSChristopher Ferris 
1748*a248dafdSChristopher Ferris #define disable_cbc(ctrl_num)\
1749*a248dafdSChristopher Ferris do {\
1750*a248dafdSChristopher Ferris 	retval = m_device.Read(\
1751*a248dafdSChristopher Ferris 			m_f54Control.ctrl_num.address,\
1752*a248dafdSChristopher Ferris 			m_f54Control.ctrl_num.data,\
1753*a248dafdSChristopher Ferris 			sizeof(m_f54Control.ctrl_num.data));\
1754*a248dafdSChristopher Ferris 	if (retval < 0) {\
1755*a248dafdSChristopher Ferris 		return retval;\
1756*a248dafdSChristopher Ferris 	} \
1757*a248dafdSChristopher Ferris 	m_f54Control.ctrl_num.cbc_tx_carrier_selection = 0;\
1758*a248dafdSChristopher Ferris 	retval = m_device.Write(\
1759*a248dafdSChristopher Ferris 			m_f54Control.ctrl_num.address,\
1760*a248dafdSChristopher Ferris 			m_f54Control.ctrl_num.data,\
1761*a248dafdSChristopher Ferris 			sizeof(m_f54Control.ctrl_num.data));\
1762*a248dafdSChristopher Ferris 	if (retval < 0) {\
1763*a248dafdSChristopher Ferris 		return retval;\
1764*a248dafdSChristopher Ferris 	} \
1765*a248dafdSChristopher Ferris } while (0)
1766*a248dafdSChristopher Ferris 
DoPreparation()1767*a248dafdSChristopher Ferris int F54Test::DoPreparation()
1768*a248dafdSChristopher Ferris {
1769*a248dafdSChristopher Ferris 	int retval;
1770*a248dafdSChristopher Ferris 	unsigned char value;
1771*a248dafdSChristopher Ferris 	unsigned char zero = 0x00;
1772*a248dafdSChristopher Ferris 	unsigned char device_ctrl;
1773*a248dafdSChristopher Ferris 
1774*a248dafdSChristopher Ferris 	retval = m_device.Read(m_f54.GetControlBase(),
1775*a248dafdSChristopher Ferris 			&device_ctrl,
1776*a248dafdSChristopher Ferris 			sizeof(device_ctrl));
1777*a248dafdSChristopher Ferris 	if (retval < 0) {
1778*a248dafdSChristopher Ferris 		return retval;
1779*a248dafdSChristopher Ferris 	}
1780*a248dafdSChristopher Ferris 
1781*a248dafdSChristopher Ferris 	device_ctrl |= NO_SLEEP_ON;
1782*a248dafdSChristopher Ferris 
1783*a248dafdSChristopher Ferris 	retval = m_device.Write(m_f54.GetControlBase(),
1784*a248dafdSChristopher Ferris 			&device_ctrl,
1785*a248dafdSChristopher Ferris 			sizeof(device_ctrl));
1786*a248dafdSChristopher Ferris 	if (retval < 0) {
1787*a248dafdSChristopher Ferris 		return retval;
1788*a248dafdSChristopher Ferris 	}
1789*a248dafdSChristopher Ferris 
1790*a248dafdSChristopher Ferris 	switch (m_reportType) {
1791*a248dafdSChristopher Ferris 	case F54_16BIT_IMAGE:
1792*a248dafdSChristopher Ferris 	case F54_RAW_16BIT_IMAGE:
1793*a248dafdSChristopher Ferris 	case F54_SENSOR_SPEED:
1794*a248dafdSChristopher Ferris 	case F54_ADC_RANGE:
1795*a248dafdSChristopher Ferris 	case F54_ABS_RAW_CAP:
1796*a248dafdSChristopher Ferris 	case F54_ABS_DELTA_CAP:
1797*a248dafdSChristopher Ferris 		break;
1798*a248dafdSChristopher Ferris 	default:
1799*a248dafdSChristopher Ferris 		if (m_f54Query.touch_controller_family == 1)
1800*a248dafdSChristopher Ferris 			disable_cbc(reg_7);
1801*a248dafdSChristopher Ferris 		else if (m_f54Query.has_ctrl88)
1802*a248dafdSChristopher Ferris 			disable_cbc(reg_88);
1803*a248dafdSChristopher Ferris 
1804*a248dafdSChristopher Ferris 		if (m_f54Query.has_0d_acquisition_control)
1805*a248dafdSChristopher Ferris 			disable_cbc(reg_57);
1806*a248dafdSChristopher Ferris 
1807*a248dafdSChristopher Ferris 		if ((m_f54Query.has_query15) &&
1808*a248dafdSChristopher Ferris 				(m_f54Query_15.has_query25) &&
1809*a248dafdSChristopher Ferris 				(m_f54Query_25.has_query27) &&
1810*a248dafdSChristopher Ferris 				(m_f54Query_27.has_query29) &&
1811*a248dafdSChristopher Ferris 				(m_f54Query_29.has_query30) &&
1812*a248dafdSChristopher Ferris 				(m_f54Query_30.has_query32) &&
1813*a248dafdSChristopher Ferris 				(m_f54Query_32.has_query33) &&
1814*a248dafdSChristopher Ferris 				(m_f54Query_33.has_query36) &&
1815*a248dafdSChristopher Ferris 				(m_f54Query_36.has_query38) &&
1816*a248dafdSChristopher Ferris 				(m_f54Query_38.has_ctrl149)) {
1817*a248dafdSChristopher Ferris 			retval = m_device.Write(m_f54Control.reg_149.address,
1818*a248dafdSChristopher Ferris 					&zero,
1819*a248dafdSChristopher Ferris 					sizeof(m_f54Control.reg_149.data));
1820*a248dafdSChristopher Ferris 			if (retval < 0) {
1821*a248dafdSChristopher Ferris 				return retval;
1822*a248dafdSChristopher Ferris 			}
1823*a248dafdSChristopher Ferris 		}
1824*a248dafdSChristopher Ferris 
1825*a248dafdSChristopher Ferris 		if (m_f54Query.has_signal_clarity) {
1826*a248dafdSChristopher Ferris 			retval = m_device.Read(m_f54Control.reg_41.address,
1827*a248dafdSChristopher Ferris 					&value,
1828*a248dafdSChristopher Ferris 					sizeof(m_f54Control.reg_41.data));
1829*a248dafdSChristopher Ferris 			if (retval < 0) {
1830*a248dafdSChristopher Ferris 				return retval;
1831*a248dafdSChristopher Ferris 			}
1832*a248dafdSChristopher Ferris 			value |= 0x01;
1833*a248dafdSChristopher Ferris 			retval = m_device.Write(m_f54Control.reg_41.address,
1834*a248dafdSChristopher Ferris 					&value,
1835*a248dafdSChristopher Ferris 					sizeof(m_f54Control.reg_41.data));
1836*a248dafdSChristopher Ferris 			if (retval < 0) {
1837*a248dafdSChristopher Ferris 				return retval;
1838*a248dafdSChristopher Ferris 			}
1839*a248dafdSChristopher Ferris 		}
1840*a248dafdSChristopher Ferris 
1841*a248dafdSChristopher Ferris 		retval = DoF54Command(COMMAND_FORCE_UPDATE);
1842*a248dafdSChristopher Ferris 		if (retval < 0) {
1843*a248dafdSChristopher Ferris 			return retval;
1844*a248dafdSChristopher Ferris 		}
1845*a248dafdSChristopher Ferris 
1846*a248dafdSChristopher Ferris 		retval = DoF54Command(COMMAND_FORCE_CAL);
1847*a248dafdSChristopher Ferris 		if (retval < 0) {
1848*a248dafdSChristopher Ferris 			return retval;
1849*a248dafdSChristopher Ferris 		}
1850*a248dafdSChristopher Ferris 	}
1851*a248dafdSChristopher Ferris 	return TEST_SUCCESS;
1852*a248dafdSChristopher Ferris }
1853*a248dafdSChristopher Ferris 
ShowF54Report()1854*a248dafdSChristopher Ferris int F54Test::ShowF54Report()
1855*a248dafdSChristopher Ferris {
1856*a248dafdSChristopher Ferris 	unsigned int ii;
1857*a248dafdSChristopher Ferris 	unsigned int jj;
1858*a248dafdSChristopher Ferris 	unsigned int kk;
1859*a248dafdSChristopher Ferris 	unsigned int tx_num = m_txAssigned;
1860*a248dafdSChristopher Ferris 	unsigned int rx_num = m_rxAssigned;
1861*a248dafdSChristopher Ferris 	char *report_data_8;
1862*a248dafdSChristopher Ferris 	short *report_data_16;
1863*a248dafdSChristopher Ferris 	int *report_data_32;
1864*a248dafdSChristopher Ferris 	unsigned int *report_data_u32;
1865*a248dafdSChristopher Ferris 	unsigned char *report_data_u8;
1866*a248dafdSChristopher Ferris 	char buf[256];
1867*a248dafdSChristopher Ferris 	bool rt26_result = true;
1868*a248dafdSChristopher Ferris 	unsigned char rt26_ng_num;
1869*a248dafdSChristopher Ferris 
1870*a248dafdSChristopher Ferris 	switch (m_reportType) {
1871*a248dafdSChristopher Ferris 	case F54_8BIT_IMAGE:
1872*a248dafdSChristopher Ferris 		report_data_8 = (char *)m_reportData;
1873*a248dafdSChristopher Ferris 		for (ii = 0; ii < m_reportSize; ii++) {
1874*a248dafdSChristopher Ferris 			sprintf(buf, "%03d: %d\n",
1875*a248dafdSChristopher Ferris 					ii, *report_data_8);
1876*a248dafdSChristopher Ferris 			m_display.Output(buf);
1877*a248dafdSChristopher Ferris 			report_data_8++;
1878*a248dafdSChristopher Ferris 		}
1879*a248dafdSChristopher Ferris 		break;
1880*a248dafdSChristopher Ferris 	case F54_16BIT_IMAGE:
1881*a248dafdSChristopher Ferris 	case F54_RAW_16BIT_IMAGE:
1882*a248dafdSChristopher Ferris 	case F54_TRUE_BASELINE:
1883*a248dafdSChristopher Ferris 	case F54_FULL_RAW_CAP:
1884*a248dafdSChristopher Ferris 	case F54_FULL_RAW_CAP_NO_RX_COUPLING:
1885*a248dafdSChristopher Ferris 	case F54_SENSOR_SPEED:
1886*a248dafdSChristopher Ferris 		report_data_16 = (short *)m_reportData;
1887*a248dafdSChristopher Ferris 		sprintf(buf, "tx = %d\nrx = %d\n",
1888*a248dafdSChristopher Ferris 				tx_num, rx_num);
1889*a248dafdSChristopher Ferris 		m_display.Output(buf);
1890*a248dafdSChristopher Ferris 
1891*a248dafdSChristopher Ferris 		for (ii = 0; ii < tx_num; ii++) {
1892*a248dafdSChristopher Ferris 			for (jj = 0; jj < (rx_num - 1); jj++) {
1893*a248dafdSChristopher Ferris 				sprintf(buf, "%-4d ",
1894*a248dafdSChristopher Ferris 						*report_data_16);
1895*a248dafdSChristopher Ferris 				report_data_16++;
1896*a248dafdSChristopher Ferris 				m_display.Output(buf);
1897*a248dafdSChristopher Ferris 			}
1898*a248dafdSChristopher Ferris 			sprintf(buf, "%-4d\n",
1899*a248dafdSChristopher Ferris 					*report_data_16);
1900*a248dafdSChristopher Ferris 			m_display.Output(buf);
1901*a248dafdSChristopher Ferris 			report_data_16++;
1902*a248dafdSChristopher Ferris 		}
1903*a248dafdSChristopher Ferris 		break;
1904*a248dafdSChristopher Ferris 	case F54_HIGH_RESISTANCE:
1905*a248dafdSChristopher Ferris 	case F54_FULL_RAW_CAP_MIN_MAX:
1906*a248dafdSChristopher Ferris 		report_data_16 = (short *)m_reportData;
1907*a248dafdSChristopher Ferris 		for (ii = 0; ii < m_reportSize; ii += 2) {
1908*a248dafdSChristopher Ferris 			sprintf(buf, "%03d: %d\n",
1909*a248dafdSChristopher Ferris 					ii / 2, *report_data_16);
1910*a248dafdSChristopher Ferris 			m_display.Output(buf);
1911*a248dafdSChristopher Ferris 			report_data_16++;
1912*a248dafdSChristopher Ferris 		}
1913*a248dafdSChristopher Ferris 		break;
1914*a248dafdSChristopher Ferris 	case F54_ABS_RAW_CAP:
1915*a248dafdSChristopher Ferris 		report_data_u32 = (unsigned int *)m_reportData;
1916*a248dafdSChristopher Ferris 		sprintf(buf, "rx ");
1917*a248dafdSChristopher Ferris 		m_display.Output(buf);
1918*a248dafdSChristopher Ferris 
1919*a248dafdSChristopher Ferris 		for (ii = 0; ii < rx_num; ii++) {
1920*a248dafdSChristopher Ferris 			sprintf(buf, "     %2d", ii);
1921*a248dafdSChristopher Ferris 			m_display.Output(buf);
1922*a248dafdSChristopher Ferris 		}
1923*a248dafdSChristopher Ferris 		sprintf(buf, "\n");
1924*a248dafdSChristopher Ferris 		m_display.Output(buf);
1925*a248dafdSChristopher Ferris 
1926*a248dafdSChristopher Ferris 		sprintf(buf, "   ");
1927*a248dafdSChristopher Ferris 		m_display.Output(buf);
1928*a248dafdSChristopher Ferris 
1929*a248dafdSChristopher Ferris 		for (ii = 0; ii < rx_num; ii++) {
1930*a248dafdSChristopher Ferris 			sprintf(buf, "  %5u",
1931*a248dafdSChristopher Ferris 					*report_data_u32);
1932*a248dafdSChristopher Ferris 			report_data_u32++;
1933*a248dafdSChristopher Ferris 			m_display.Output(buf);
1934*a248dafdSChristopher Ferris 		}
1935*a248dafdSChristopher Ferris 		sprintf(buf, "\n");
1936*a248dafdSChristopher Ferris 		m_display.Output(buf);
1937*a248dafdSChristopher Ferris 
1938*a248dafdSChristopher Ferris 		sprintf(buf, "tx ");
1939*a248dafdSChristopher Ferris 		m_display.Output(buf);
1940*a248dafdSChristopher Ferris 
1941*a248dafdSChristopher Ferris 		for (ii = 0; ii < tx_num; ii++) {
1942*a248dafdSChristopher Ferris 			sprintf(buf, "     %2d", ii);
1943*a248dafdSChristopher Ferris 			m_display.Output(buf);
1944*a248dafdSChristopher Ferris 		}
1945*a248dafdSChristopher Ferris 		sprintf(buf, "\n");
1946*a248dafdSChristopher Ferris 		m_display.Output(buf);
1947*a248dafdSChristopher Ferris 
1948*a248dafdSChristopher Ferris 		sprintf(buf, "   ");
1949*a248dafdSChristopher Ferris 		m_display.Output(buf);
1950*a248dafdSChristopher Ferris 
1951*a248dafdSChristopher Ferris 		for (ii = 0; ii < tx_num; ii++) {
1952*a248dafdSChristopher Ferris 			sprintf(buf, "  %5u",
1953*a248dafdSChristopher Ferris 					*report_data_u32);
1954*a248dafdSChristopher Ferris 			report_data_u32++;
1955*a248dafdSChristopher Ferris 			m_display.Output(buf);
1956*a248dafdSChristopher Ferris 		}
1957*a248dafdSChristopher Ferris 		sprintf(buf, "\n");
1958*a248dafdSChristopher Ferris 		m_display.Output(buf);
1959*a248dafdSChristopher Ferris 
1960*a248dafdSChristopher Ferris 		break;
1961*a248dafdSChristopher Ferris 	case F54_ABS_DELTA_CAP:
1962*a248dafdSChristopher Ferris 		report_data_32 = (int *)m_reportData;
1963*a248dafdSChristopher Ferris 		sprintf(buf, "rx ");
1964*a248dafdSChristopher Ferris 		m_display.Output(buf);
1965*a248dafdSChristopher Ferris 
1966*a248dafdSChristopher Ferris 		for (ii = 0; ii < rx_num; ii++) {
1967*a248dafdSChristopher Ferris 			sprintf(buf, "     %2d", ii);
1968*a248dafdSChristopher Ferris 			m_display.Output(buf);
1969*a248dafdSChristopher Ferris 		}
1970*a248dafdSChristopher Ferris 		sprintf(buf, "\n");
1971*a248dafdSChristopher Ferris 		m_display.Output(buf);
1972*a248dafdSChristopher Ferris 
1973*a248dafdSChristopher Ferris 		sprintf(buf, "   ");
1974*a248dafdSChristopher Ferris 		m_display.Output(buf);
1975*a248dafdSChristopher Ferris 
1976*a248dafdSChristopher Ferris 		for (ii = 0; ii < rx_num; ii++) {
1977*a248dafdSChristopher Ferris 			sprintf(buf, "  %5d",
1978*a248dafdSChristopher Ferris 					*report_data_32);
1979*a248dafdSChristopher Ferris 			report_data_32++;
1980*a248dafdSChristopher Ferris 			m_display.Output(buf);
1981*a248dafdSChristopher Ferris 		}
1982*a248dafdSChristopher Ferris 		sprintf(buf, "\n");
1983*a248dafdSChristopher Ferris 		m_display.Output(buf);
1984*a248dafdSChristopher Ferris 
1985*a248dafdSChristopher Ferris 		sprintf(buf, "tx ");
1986*a248dafdSChristopher Ferris 		m_display.Output(buf);
1987*a248dafdSChristopher Ferris 
1988*a248dafdSChristopher Ferris 		for (ii = 0; ii < tx_num; ii++) {
1989*a248dafdSChristopher Ferris 			sprintf(buf, "     %2d", ii);
1990*a248dafdSChristopher Ferris 			m_display.Output(buf);
1991*a248dafdSChristopher Ferris 		}
1992*a248dafdSChristopher Ferris 		sprintf(buf, "\n");
1993*a248dafdSChristopher Ferris 		m_display.Output(buf);
1994*a248dafdSChristopher Ferris 
1995*a248dafdSChristopher Ferris 		sprintf(buf, "   ");
1996*a248dafdSChristopher Ferris 		m_display.Output(buf);
1997*a248dafdSChristopher Ferris 
1998*a248dafdSChristopher Ferris 		for (ii = 0; ii < tx_num; ii++) {
1999*a248dafdSChristopher Ferris 			sprintf(buf, "  %5d",
2000*a248dafdSChristopher Ferris 					*report_data_32);
2001*a248dafdSChristopher Ferris 			report_data_32++;
2002*a248dafdSChristopher Ferris 			m_display.Output(buf);
2003*a248dafdSChristopher Ferris 		}
2004*a248dafdSChristopher Ferris 		sprintf(buf, "\n");
2005*a248dafdSChristopher Ferris 		m_display.Output(buf);
2006*a248dafdSChristopher Ferris 
2007*a248dafdSChristopher Ferris 		break;
2008*a248dafdSChristopher Ferris 	case F54_GUARD_PIN_SHORT:
2009*a248dafdSChristopher Ferris 		report_data_u8 = (unsigned char *)m_reportData;
2010*a248dafdSChristopher Ferris 		sprintf(buf, "Guard Pin Short Test:\n");
2011*a248dafdSChristopher Ferris 		m_display.Output(buf);
2012*a248dafdSChristopher Ferris 		for (ii = 0; ii < GUARD_PIN_SHORT_DATA_SIZE; ii++) {
2013*a248dafdSChristopher Ferris 			sprintf(buf, "%03d: 0x%02x\n", ii, *(report_data_u8 + ii));
2014*a248dafdSChristopher Ferris 			m_display.Output(buf);
2015*a248dafdSChristopher Ferris 		}
2016*a248dafdSChristopher Ferris 		sprintf(buf, "\n");
2017*a248dafdSChristopher Ferris 		m_display.Output(buf);
2018*a248dafdSChristopher Ferris 
2019*a248dafdSChristopher Ferris 		if (report_data_u8[GUARD_PIN_SHORT_DATA_SIZE - 1] & 0xC0)
2020*a248dafdSChristopher Ferris 			sprintf(buf, "Failed: pin %d\n",
2021*a248dafdSChristopher Ferris 					(report_data_u8[GUARD_PIN_SHORT_DATA_SIZE - 1] & 0xC0) >> 7);
2022*a248dafdSChristopher Ferris 		else
2023*a248dafdSChristopher Ferris 			sprintf(buf, "Pass\n");
2024*a248dafdSChristopher Ferris 		m_display.Output(buf);
2025*a248dafdSChristopher Ferris 
2026*a248dafdSChristopher Ferris 		break;
2027*a248dafdSChristopher Ferris 	case F54_TRX_SHORTS:
2028*a248dafdSChristopher Ferris 		report_data_u8 = (unsigned char *)m_reportData;
2029*a248dafdSChristopher Ferris 		sprintf(buf, "Trx Short Test:\n");
2030*a248dafdSChristopher Ferris 		m_display.Output(buf);
2031*a248dafdSChristopher Ferris 
2032*a248dafdSChristopher Ferris 		for (ii = 0; ii < m_reportSize; ii++) {
2033*a248dafdSChristopher Ferris 			sprintf(buf, "%03d: 0x%02x\n", ii, *(report_data_u8 + ii));
2034*a248dafdSChristopher Ferris 			m_display.Output(buf);
2035*a248dafdSChristopher Ferris 		}
2036*a248dafdSChristopher Ferris 		sprintf(buf, "\n");
2037*a248dafdSChristopher Ferris 		m_display.Output(buf);
2038*a248dafdSChristopher Ferris 
2039*a248dafdSChristopher Ferris 		for (ii = 0; ii < m_reportSize; ii++) {
2040*a248dafdSChristopher Ferris 			if (report_data_u8[ii] != 0) {
2041*a248dafdSChristopher Ferris 				for (jj = 0; jj < sizeof(char); jj++) {
2042*a248dafdSChristopher Ferris 					if (report_data_u8[ii] & (1 << jj)) {
2043*a248dafdSChristopher Ferris 						rt26_ng_num = ii * 8 + jj;
2044*a248dafdSChristopher Ferris 						for (kk = 0; kk < m_txAssigned; kk++) {
2045*a248dafdSChristopher Ferris 							if (rt26_ng_num == m_txAssignment[kk]) {
2046*a248dafdSChristopher Ferris 								rt26_result = false;
2047*a248dafdSChristopher Ferris 								sprintf(buf, "Failed on %d\n", rt26_ng_num);
2048*a248dafdSChristopher Ferris 								m_display.Output(buf);
2049*a248dafdSChristopher Ferris 							}
2050*a248dafdSChristopher Ferris 						}
2051*a248dafdSChristopher Ferris 						for (kk = 0; kk < m_rxAssigned; kk++) {
2052*a248dafdSChristopher Ferris 							if (rt26_ng_num == m_rxAssignment[kk]) {
2053*a248dafdSChristopher Ferris 								rt26_result = false;
2054*a248dafdSChristopher Ferris 								sprintf(buf, "Failed on %d\n", rt26_ng_num);
2055*a248dafdSChristopher Ferris 								m_display.Output(buf);
2056*a248dafdSChristopher Ferris 							}
2057*a248dafdSChristopher Ferris 						}
2058*a248dafdSChristopher Ferris 					}
2059*a248dafdSChristopher Ferris 				}
2060*a248dafdSChristopher Ferris 			}
2061*a248dafdSChristopher Ferris 		}
2062*a248dafdSChristopher Ferris 
2063*a248dafdSChristopher Ferris 		if (rt26_result) {
2064*a248dafdSChristopher Ferris 			sprintf(buf, "Pass\n");
2065*a248dafdSChristopher Ferris 			m_display.Output(buf);
2066*a248dafdSChristopher Ferris 		}
2067*a248dafdSChristopher Ferris 
2068*a248dafdSChristopher Ferris 		break;
2069*a248dafdSChristopher Ferris 
2070*a248dafdSChristopher Ferris 	default:
2071*a248dafdSChristopher Ferris 		for (ii = 0; ii < m_reportSize; ii++) {
2072*a248dafdSChristopher Ferris 			sprintf(buf, "%03d: 0x%02x\n",
2073*a248dafdSChristopher Ferris 					ii, m_reportData[ii]);
2074*a248dafdSChristopher Ferris 			m_display.Output(buf);
2075*a248dafdSChristopher Ferris 		}
2076*a248dafdSChristopher Ferris 		break;
2077*a248dafdSChristopher Ferris 	}
2078*a248dafdSChristopher Ferris 
2079*a248dafdSChristopher Ferris 	sprintf(buf, "\n");
2080*a248dafdSChristopher Ferris 	m_display.Output(buf);
2081*a248dafdSChristopher Ferris 
2082*a248dafdSChristopher Ferris 	m_display.Reflesh();
2083*a248dafdSChristopher Ferris 
2084*a248dafdSChristopher Ferris 	return TEST_SUCCESS;
2085*a248dafdSChristopher Ferris }
2086