Judging by the scores of headlines using the word “surprise,” Motorola has shocked the world by actually posting a profit in its second quarter.

The company made $4 million on $8 billion in revenue; a year ago it posted a second-quarter loss of $28 million.

Sales in the Home and Networks Mobility segment were $2.7 billion, up 7 percent compared with the year-ago quarter. Operating earnings were $245 million, which represents an increase of 28 percent as compared with operating earnings of $191 million in the year-ago quarter.

Results in the segment were driven by shipments of 4.9 million digital entertainment devices, due to continued strong demand for high-definition (HD), HD/DVR and IPTV devices, Motorola reported.

Consumer demand for HD content continued to drive the uptake of MPEG-4 equipment. The company said DirecTV, HBO LatAM and Starz were among its customers that began transitioning from MPEG-2 during the quarter.

Motorola also said it now has 19 contracts for commercial WiMAX systems in 16 countries.

Motorola’s weakness – its flagging handset operation – didn’t do as poorly as expected. The Mobile Devices segment’s sales were $3.3 billion, down 22 percent compared with the year-ago quarter. The segment reported an operating loss of $346 million, compared with an operating loss of $332 million in the year-ago quarter.

On the other hand, it maintained its share of the global handset market, after shipping 28.1 million handsets, including some new products the company has high hopes for.

“Motorola’s Home and Networks Mobility and Enterprise Mobility Solutions segments delivered strong results in the second quarter, driven by sales growth and operating margin expansion. These segments are well positioned to continue generating year-over-year sales and margin growth during the second half,” said Greg Brown, Motorola’s president and CEO.

“In the Mobile Devices segment,” Brown continued, “we launched ten new products and maintained market share, compared with the first quarter, while continuing to invest in our product portfolio. We also made progress on our plans to separate Motorola into two independent, publicly traded companies, generated positive operating cash flow and reduced our cost structure.”

Motorola three days ago announced a reorganization (story here). The company is also in the process of spinning off its handset business.

More Broadband Direct:

• Cablevision turns in a quarter of growth 

• Dish Network to offer 150 national HD channels

• Moto posts a profit

• Arris' Q2 revenue increases 3%

• Wave Broadband's Friedman elected chairman of ACA

• Knology shuffles, promotes execs

• LG Electronics builds device to deliver Netflix movies

• UEI launches DTA universal remote control

• Broadband Briefs for 7/31/08